idx int64 0 41.2k | question stringlengths 74 4.21k | target stringlengths 5 888 |
|---|---|---|
19,400 | private XHTMLText appendOpenBodyTag ( String style , String lang ) { text . halfOpenElement ( Message . BODY ) ; text . xmlnsAttribute ( NAMESPACE ) ; text . optElement ( STYLE , style ) ; text . xmllangAttribute ( lang ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that indicates that a body section begins . |
19,401 | public XHTMLText appendOpenHeaderTag ( int level , String style ) { if ( level > 3 || level < 1 ) { throw new IllegalArgumentException ( "Level must be between 1 and 3" ) ; } text . halfOpenElement ( H + Integer . toString ( level ) ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that indicates a header a title of a section of the message . |
19,402 | public XHTMLText appendCloseHeaderTag ( int level ) { if ( level > 3 || level < 1 ) { throw new IllegalArgumentException ( "Level must be between 1 and 3" ) ; } text . closeElement ( H + Integer . toBinaryString ( level ) ) ; return this ; } | Appends a tag that indicates that a header section ends . |
19,403 | public XHTMLText appendImageTag ( String align , String alt , String height , String src , String width ) { text . halfOpenElement ( IMG ) ; text . optAttribute ( "align" , align ) ; text . optAttribute ( "alt" , alt ) ; text . optAttribute ( "height" , height ) ; text . optAttribute ( "src" , src ) ; text . optAttribute ( "width" , width ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that indicates an image . |
19,404 | public XHTMLText appendLineItemTag ( String style ) { text . halfOpenElement ( LI ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that indicates the start of a new line item within a list . |
19,405 | public XHTMLText appendOpenOrderedListTag ( String style ) { text . halfOpenElement ( OL ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that creates an ordered list . Ordered means that the order of the items in the list is important . To show this browsers automatically number the list . |
19,406 | public XHTMLText appendOpenUnorderedListTag ( String style ) { text . halfOpenElement ( UL ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that creates an unordered list . The unordered part means that the items in the list are not in any particular order . |
19,407 | public XHTMLText appendOpenParagraphTag ( String style ) { text . halfOpenElement ( P ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that indicates the start of a new paragraph . This is usually rendered with two carriage returns producing a single blank line in between the two paragraphs . |
19,408 | public XHTMLText appendOpenInlinedQuoteTag ( String style ) { text . halfOpenElement ( Q ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that indicates that an inlined quote section begins . |
19,409 | public XHTMLText appendOpenSpanTag ( String style ) { text . halfOpenElement ( SPAN ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; } | Appends a tag that allows to set the fonts for a span of text . |
19,410 | public List < Subscription > getSubscriptions ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return getSubscriptions ( null , null ) ; } | Get the subscriptions currently associated with this node . |
19,411 | public List < Subscription > getSubscriptionsAsOwner ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return getSubscriptionsAsOwner ( null , null ) ; } | Get the subscriptions currently associated with this node as owner . |
19,412 | public List < Affiliation > getAffiliations ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return getAffiliations ( null , null ) ; } | Get the affiliations of this node . |
19,413 | public List < Affiliation > getAffiliationsAsOwner ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return getAffiliationsAsOwner ( null , null ) ; } | Retrieve the affiliation list for this node as owner . |
19,414 | public Subscription subscribe ( String jid ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub pubSub = createPubsubPacket ( Type . set , new SubscribeExtension ( jid , getId ( ) ) ) ; PubSub reply = sendPubsubPacket ( pubSub ) ; return reply . getExtension ( PubSubElementType . SUBSCRIPTION ) ; } | The user subscribes to the node using the supplied jid . The bare jid portion of this one must match the jid for the connection . |
19,415 | public Subscription subscribe ( String jid , SubscribeForm subForm ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub request = createPubsubPacket ( Type . set , new SubscribeExtension ( jid , getId ( ) ) ) ; request . addExtension ( new FormNode ( FormNodeType . OPTIONS , subForm ) ) ; PubSub reply = sendPubsubPacket ( request ) ; return reply . getExtension ( PubSubElementType . SUBSCRIPTION ) ; } | The user subscribes to the node using the supplied jid and subscription options . The bare jid portion of this one must match the jid for the connection . |
19,416 | public void unsubscribe ( String jid , String subscriptionId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { sendPubsubPacket ( createPubsubPacket ( Type . set , new UnsubscribeExtension ( jid , getId ( ) , subscriptionId ) ) ) ; } | Remove the specific subscription related to the specified JID . |
19,417 | public SubscribeForm getSubscriptionOptions ( String jid , String subscriptionId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub packet = sendPubsubPacket ( createPubsubPacket ( Type . get , new OptionsExtension ( jid , getId ( ) , subscriptionId ) ) ) ; FormNode ext = packet . getExtension ( PubSubElementType . OPTIONS ) ; return new SubscribeForm ( ext . getForm ( ) ) ; } | Get the options for configuring the specified subscription . |
19,418 | @ SuppressWarnings ( "unchecked" ) public void addItemEventListener ( @ SuppressWarnings ( "rawtypes" ) ItemEventListener listener ) { StanzaListener conListener = new ItemEventTranslator ( listener ) ; itemEventToListenerMap . put ( listener , conListener ) ; pubSubManager . getConnection ( ) . addSyncStanzaListener ( conListener , new EventContentFilter ( EventElementType . items . toString ( ) , "item" ) ) ; } | Register a listener for item publication events . This listener will get called whenever an item is published to this node . |
19,419 | public void removeItemEventListener ( @ SuppressWarnings ( "rawtypes" ) ItemEventListener listener ) { StanzaListener conListener = itemEventToListenerMap . remove ( listener ) ; if ( conListener != null ) pubSubManager . getConnection ( ) . removeSyncStanzaListener ( conListener ) ; } | Unregister a listener for publication events . |
19,420 | public void addConfigurationListener ( NodeConfigListener listener ) { StanzaListener conListener = new NodeConfigTranslator ( listener ) ; configEventToListenerMap . put ( listener , conListener ) ; pubSubManager . getConnection ( ) . addSyncStanzaListener ( conListener , new EventContentFilter ( EventElementType . configuration . toString ( ) ) ) ; } | Register a listener for configuration events . This listener will get called whenever the node s configuration changes . |
19,421 | public void removeConfigurationListener ( NodeConfigListener listener ) { StanzaListener conListener = configEventToListenerMap . remove ( listener ) ; if ( conListener != null ) pubSubManager . getConnection ( ) . removeSyncStanzaListener ( conListener ) ; } | Unregister a listener for configuration events . |
19,422 | public void addItemDeleteListener ( ItemDeleteListener listener ) { StanzaListener delListener = new ItemDeleteTranslator ( listener ) ; itemDeleteToListenerMap . put ( listener , delListener ) ; EventContentFilter deleteItem = new EventContentFilter ( EventElementType . items . toString ( ) , "retract" ) ; EventContentFilter purge = new EventContentFilter ( EventElementType . purge . toString ( ) ) ; pubSubManager . getConnection ( ) . addSyncStanzaListener ( delListener , new OrFilter ( deleteItem , purge ) ) ; } | Register an listener for item delete events . This listener gets called whenever an item is deleted from the node . |
19,423 | public void removeItemDeleteListener ( ItemDeleteListener listener ) { StanzaListener conListener = itemDeleteToListenerMap . remove ( listener ) ; if ( conListener != null ) pubSubManager . getConnection ( ) . removeSyncStanzaListener ( conListener ) ; } | Unregister a listener for item delete events . |
19,424 | private void setAcceptedLocalCandidate ( TransportCandidate bestLocalCandidate ) { for ( int i = 0 ; i < resolver . getCandidateCount ( ) ; i ++ ) { if ( resolver . getCandidate ( i ) . getIp ( ) . equals ( bestLocalCandidate . getIp ( ) ) && resolver . getCandidate ( i ) . getPort ( ) == bestLocalCandidate . getPort ( ) ) { acceptedLocalCandidate = resolver . getCandidate ( i ) ; return ; } } LOGGER . fine ( "BEST: ip=" + bestLocalCandidate . getIp ( ) + " port=" + bestLocalCandidate . getPort ( ) + " has not been offered." ) ; } | Set the best local transport candidate we have offered and accepted by the other endpoint . |
19,425 | protected void doStart ( ) { try { sendTransportCandidatesOffer ( ) ; setNegotiatorState ( JingleNegotiatorState . PENDING ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } } | Called from above to start the negotiator during a session - initiate . |
19,426 | private void addRemoteCandidate ( TransportCandidate rc ) { if ( rc != null ) { if ( acceptableTransportCandidate ( rc , offeredCandidates ) ) { synchronized ( remoteCandidates ) { remoteCandidates . add ( rc ) ; } checkRemoteCandidate ( rc ) ; } } } | Add a remote candidate to the list . The candidate will be checked in order to verify if it is usable . |
19,427 | private void checkRemoteCandidate ( final TransportCandidate offeredCandidate ) { offeredCandidate . addListener ( new TransportResolverListener . Checker ( ) { public void candidateChecked ( TransportCandidate cand , final boolean validCandidate ) { if ( validCandidate ) { if ( getNegotiatorState ( ) == JingleNegotiatorState . PENDING ) addValidRemoteCandidate ( offeredCandidate ) ; } } public void candidateChecking ( TransportCandidate cand ) { } } ) ; offeredCandidate . check ( resolver . getCandidatesList ( ) ) ; } | Check asynchronously the new transport candidate . |
19,428 | private void addValidRemoteCandidate ( TransportCandidate remoteCandidate ) { if ( remoteCandidate != null ) { synchronized ( validRemoteCandidates ) { LOGGER . fine ( "Added valid candidate: " + remoteCandidate . getIp ( ) + ":" + remoteCandidate . getPort ( ) ) ; validRemoteCandidates . add ( remoteCandidate ) ; } } } | Add a valid remote candidate to the list . The remote candidate has been checked and the remote |
19,429 | private List < TransportCandidate > obtainCandidatesList ( Jingle jingle ) { List < TransportCandidate > result = new ArrayList < > ( ) ; if ( jingle != null ) { for ( JingleContent jingleContent : jingle . getContentsList ( ) ) { if ( jingleContent . getName ( ) . equals ( parentNegotiator . getName ( ) ) ) { for ( JingleTransport jingleTransport : jingleContent . getJingleTransportsList ( ) ) { for ( JingleTransportCandidate jingleTransportCandidate : jingleTransport . getCandidatesList ( ) ) { TransportCandidate transCand = jingleTransportCandidate . getMediaTransport ( ) ; result . add ( transCand ) ; } } } } } return result ; } | Parse the list of transport candidates from a Jingle packet . |
19,430 | private synchronized void sendTransportCandidateOffer ( TransportCandidate cand ) throws NotConnectedException , InterruptedException { if ( ! cand . isNull ( ) ) { addOfferedCandidate ( cand ) ; JingleContent content = parentNegotiator . getJingleContent ( ) ; content . addJingleTransport ( getJingleTransport ( cand ) ) ; Jingle jingle = new Jingle ( JingleActionEnum . TRANSPORT_INFO ) ; jingle . addContent ( content ) ; session . sendFormattedJingle ( jingle ) ; } } | Send an offer for a transport candidate |
19,431 | private void sendTransportCandidatesOffer ( ) throws XMPPException , SmackException , InterruptedException { List < TransportCandidate > notOffered = resolver . getCandidatesList ( ) ; notOffered . removeAll ( offeredCandidates ) ; for ( Object aNotOffered : notOffered ) { sendTransportCandidateOffer ( ( TransportCandidate ) aNotOffered ) ; } if ( resolverListener == null ) { resolverListener = new TransportResolverListener . Resolver ( ) { public void candidateAdded ( TransportCandidate cand ) throws NotConnectedException , InterruptedException { sendTransportCandidateOffer ( cand ) ; } public void end ( ) { } public void init ( ) { } } ; resolver . addListener ( resolverListener ) ; } if ( ! ( resolver . isResolving ( ) || resolver . isResolved ( ) ) ) { LOGGER . fine ( "RESOLVER CALLED" ) ; resolver . resolve ( session ) ; } } | Create a Jingle stanza where we announce our transport candidates . |
19,432 | private IQ receiveContentAcceptAction ( Jingle jingle ) throws XMPPException { IQ response = null ; List < TransportCandidate > accepted = obtainCandidatesList ( jingle ) ; if ( ! accepted . isEmpty ( ) ) { for ( TransportCandidate cand : accepted ) { LOGGER . fine ( "Remote accepted candidate addr: " + cand . getIp ( ) ) ; } TransportCandidate cand = accepted . get ( 0 ) ; setAcceptedLocalCandidate ( cand ) ; if ( isEstablished ( ) ) { LOGGER . fine ( cand . getIp ( ) + " is set active" ) ; } } return response ; } | One of our transport candidates has been accepted . |
19,433 | private void triggerTransportEstablished ( TransportCandidate local , TransportCandidate remote ) throws NotConnectedException , InterruptedException { List < JingleListener > listeners = getListenersList ( ) ; for ( JingleListener li : listeners ) { if ( li instanceof JingleTransportListener ) { JingleTransportListener mli = ( JingleTransportListener ) li ; LOGGER . fine ( "triggerTransportEstablished " + local . getLocalIp ( ) + ":" + local . getPort ( ) + " <-> " + remote . getIp ( ) + ":" + remote . getPort ( ) ) ; mli . transportEstablished ( local , remote ) ; } } } | Trigger a Transport session established event . |
19,434 | private void triggerTransportClosed ( TransportCandidate cand ) { List < JingleListener > listeners = getListenersList ( ) ; for ( JingleListener li : listeners ) { if ( li instanceof JingleTransportListener ) { JingleTransportListener mli = ( JingleTransportListener ) li ; mli . transportClosed ( cand ) ; } } } | Trigger a Transport closed event . |
19,435 | public synchronized void cancel ( ) { if ( cancelled ) { return ; } cancelled = true ; connection . removeStanzaCollector ( this ) ; notifyAll ( ) ; if ( collectorToReset != null ) { collectorToReset . cancel ( ) ; } } | Explicitly cancels the stanza collector so that no more results are queued up . Once a stanza collector has been cancelled it cannot be re - enabled . Instead a new stanza collector must be created . |
19,436 | public List < Stanza > getCollectedStanzasAfterCancelled ( ) { if ( ! cancelled ) { throw new IllegalStateException ( "Stanza collector was not yet cancelled" ) ; } if ( collectedCache == null ) { collectedCache = new ArrayList < > ( getCollectedCount ( ) ) ; collectedCache . addAll ( resultQueue ) ; } return collectedCache ; } | Return a list of all collected stanzas . This method must be invoked after the collector has been cancelled . |
19,437 | protected void processStanza ( Stanza packet ) { if ( packetFilter == null || packetFilter . accept ( packet ) ) { synchronized ( this ) { if ( resultQueue . size ( ) == maxQueueSize ) { Stanza rolledOverStanza = resultQueue . poll ( ) ; assert rolledOverStanza != null ; } resultQueue . add ( packet ) ; notifyAll ( ) ; } if ( collectorToReset != null ) { collectorToReset . waitStart = System . currentTimeMillis ( ) ; } } } | Processes a stanza to see if it meets the criteria for this stanza collector . If so the stanza is added to the result queue . |
19,438 | public static void onCreate ( Context context ) { sContext = context ; context . registerReceiver ( ALARM_BROADCAST_RECEIVER , new IntentFilter ( PING_ALARM_ACTION ) ) ; sAlarmManager = ( AlarmManager ) context . getSystemService ( Context . ALARM_SERVICE ) ; sPendingIntent = PendingIntent . getBroadcast ( context , 0 , new Intent ( PING_ALARM_ACTION ) , 0 ) ; sAlarmManager . setInexactRepeating ( AlarmManager . ELAPSED_REALTIME_WAKEUP , SystemClock . elapsedRealtime ( ) + AlarmManager . INTERVAL_HALF_HOUR , AlarmManager . INTERVAL_HALF_HOUR , sPendingIntent ) ; } | Register a pending intent with the AlarmManager to be broadcasted every half hour and register the alarm broadcast receiver to receive this intent . The receiver will check all known questions if a ping is Necessary when invoked by the alarm intent . |
19,439 | public synchronized Collection < String > getNames ( ) { if ( map == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( new HashMap < String , String > ( map ) . keySet ( ) ) ; } | Returns an unmodifiable collection of the names that can be used to get values of the stanza extension . |
19,440 | public synchronized String getValue ( String name ) { if ( map == null ) { return null ; } return map . get ( name ) ; } | Returns a stanza extension value given a name . |
19,441 | public synchronized void setValue ( String name , String value ) { if ( map == null ) { map = new HashMap < String , String > ( ) ; } map . put ( name , value ) ; } | Sets a stanza extension value using the given name . |
19,442 | public void rootWindowClosing ( WindowEvent evt ) { ( ( ObservableReader ) reader ) . removeReaderListener ( readerListener ) ; ( ( ObservableWriter ) writer ) . removeWriterListener ( writerListener ) ; } | Notification that the root window is closing . Stop listening for received and transmitted packets . |
19,443 | protected static String generateSessionId ( ) { return String . valueOf ( randomGenerator . nextInt ( Integer . MAX_VALUE ) + randomGenerator . nextInt ( Integer . MAX_VALUE ) ) ; } | Generate a unique session ID . |
19,444 | public void setSessionState ( JingleSessionState stateIs ) { LOGGER . fine ( "Session state change: " + sessionState + "->" + stateIs ) ; stateIs . enter ( ) ; sessionState = stateIs ; } | Validate the state changes . |
19,445 | public boolean isFullyEstablished ( ) { boolean result = true ; for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( ! contentNegotiator . isFullyEstablished ( ) ) result = false ; } return result ; } | Return true if all of the media managers have finished . |
19,446 | public synchronized void receivePacketAndRespond ( IQ iq ) throws XMPPException , SmackException , InterruptedException { List < IQ > responses = new ArrayList < > ( ) ; String responseId ; LOGGER . fine ( "Packet: " + iq . toXML ( ) ) ; try { responses . addAll ( dispatchIncomingPacket ( iq , null ) ) ; if ( iq != null ) { responseId = iq . getStanzaId ( ) ; for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( ! contentNegotiator . isStarted ( ) ) { contentNegotiator . start ( ) ; } responses . addAll ( contentNegotiator . dispatchIncomingPacket ( iq , responseId ) ) ; } } } catch ( JingleException e ) { JingleError error = e . getError ( ) ; if ( error != null ) { responses . add ( createJingleError ( iq , error ) ) ; } triggerSessionClosedOnError ( e ) ; } for ( IQ response : responses ) { sendStanza ( response ) ; } } | Process and respond to an incoming packet . This method is called from the stanza listener dispatcher when a new stanza has arrived . The method is responsible for recognizing the stanza type and depending on the current state delivering it to the right event handler and wait for a response . The response will be another Jingle stanza that will be sent to the other end point . |
19,447 | public Jingle sendFormattedJingle ( IQ iq , Jingle jout ) throws NotConnectedException , InterruptedException { if ( jout != null ) { if ( jout . getInitiator ( ) == null ) { jout . setInitiator ( getInitiator ( ) ) ; } if ( jout . getResponder ( ) == null ) { jout . setResponder ( getResponder ( ) ) ; } if ( jout . getSid ( ) == null ) { jout . setSid ( getSid ( ) ) ; } Jid me = getConnection ( ) . getUser ( ) ; Jid other = getResponder ( ) . equals ( me ) ? getInitiator ( ) : getResponder ( ) ; if ( jout . getTo ( ) == null ) { if ( iq != null ) { jout . setTo ( iq . getFrom ( ) ) ; } else { jout . setTo ( other ) ; } } if ( jout . getFrom ( ) == null ) { if ( iq != null ) { jout . setFrom ( iq . getTo ( ) ) ; } else { jout . setFrom ( me ) ; } } if ( ( getConnection ( ) != null ) && getConnection ( ) . isConnected ( ) ) getConnection ( ) . sendStanza ( jout ) ; } return jout ; } | Complete and send a packet . Complete all the null fields in a Jingle reponse using the session information we have or some info from the incoming packet . |
19,448 | public IQ createAck ( IQ iq ) { IQ result = null ; if ( iq != null ) { if ( iq . getType ( ) . equals ( IQ . Type . set ) ) { IQ ack = IQ . createResultIQ ( iq ) ; result = ack ; } } return result ; } | Acknowledge a IQ packet . |
19,449 | public static synchronized JingleSession getInstanceFor ( XMPPConnection con ) { if ( con == null ) { throw new IllegalArgumentException ( "XMPPConnection cannot be null" ) ; } JingleSession result = null ; synchronized ( sessions ) { if ( sessions . containsKey ( con ) ) { result = sessions . get ( con ) ; } } return result ; } | Returns the JingleSession related to a particular connection . |
19,450 | private void installConnectionListeners ( final XMPPConnection connection ) { if ( connection != null ) { connectionListener = new AbstractConnectionClosedListener ( ) { public void connectionTerminated ( ) { unregisterInstanceFor ( connection ) ; } } ; connection . addConnectionListener ( connectionListener ) ; } } | Configure a session setting some action listeners ... |
19,451 | protected void updatePacketListener ( ) { removeAsyncPacketListener ( ) ; LOGGER . fine ( "UpdatePacketListener" ) ; packetListener = new StanzaListener ( ) { public void processStanza ( Stanza packet ) { try { receivePacketAndRespond ( ( IQ ) packet ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } } } ; packetFilter = new StanzaFilter ( ) { public boolean accept ( Stanza packet ) { if ( packet instanceof IQ ) { IQ iq = ( IQ ) packet ; Jid me = getConnection ( ) . getUser ( ) ; if ( ! iq . getTo ( ) . equals ( me ) ) { return false ; } Jid other = getResponder ( ) . equals ( me ) ? getInitiator ( ) : getResponder ( ) ; if ( iq . getFrom ( ) == null || ! iq . getFrom ( ) . equals ( other == null ? "" : other ) ) { return false ; } if ( iq instanceof Jingle ) { Jingle jin = ( Jingle ) iq ; String sid = jin . getSid ( ) ; if ( sid == null || ! sid . equals ( getSid ( ) ) ) { LOGGER . fine ( "Ignored Jingle(SID) " + sid + "|" + getSid ( ) + " :" + iq . toXML ( ) ) ; return false ; } Jid ini = jin . getInitiator ( ) ; if ( ! ini . equals ( getInitiator ( ) ) ) { LOGGER . fine ( "Ignored Jingle(INI): " + iq . toXML ( ) ) ; return false ; } } else { if ( iq . getType ( ) . equals ( IQ . Type . set ) ) { LOGGER . fine ( "Ignored Jingle(TYPE): " + iq . toXML ( ) ) ; return false ; } else if ( iq . getType ( ) . equals ( IQ . Type . get ) ) { LOGGER . fine ( "Ignored Jingle(TYPE): " + iq . toXML ( ) ) ; return false ; } } return true ; } return false ; } } ; getConnection ( ) . addAsyncStanzaListener ( packetListener , packetFilter ) ; } | Install the stanza listener . The listener is responsible for responding to any stanza that we receive ... |
19,452 | public void addMediaListener ( JingleMediaListener li ) { for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getMediaNegotiator ( ) != null ) { contentNegotiator . getMediaNegotiator ( ) . addListener ( li ) ; } } } | Add a listener for jmf negotiation events . |
19,453 | public void removeMediaListener ( JingleMediaListener li ) { for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getMediaNegotiator ( ) != null ) { contentNegotiator . getMediaNegotiator ( ) . removeListener ( li ) ; } } } | Remove a listener for jmf negotiation events . |
19,454 | public void addTransportListener ( JingleTransportListener li ) { for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getTransportNegotiator ( ) != null ) { contentNegotiator . getTransportNegotiator ( ) . addListener ( li ) ; } } } | Add a listener for transport negotiation events . |
19,455 | public void removeTransportListener ( JingleTransportListener li ) { for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getTransportNegotiator ( ) != null ) { contentNegotiator . getTransportNegotiator ( ) . removeListener ( li ) ; } } } | Remove a listener for transport negotiation events . |
19,456 | public void setupListeners ( ) { JingleMediaListener jingleMediaListener = new JingleMediaListener ( ) { public void mediaClosed ( PayloadType cand ) { } public void mediaEstablished ( PayloadType pt ) throws NotConnectedException , InterruptedException { if ( isFullyEstablished ( ) ) { Jingle jout = new Jingle ( JingleActionEnum . SESSION_ACCEPT ) ; for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getNegotiatorState ( ) == JingleNegotiatorState . SUCCEEDED ) jout . addContent ( contentNegotiator . getJingleContent ( ) ) ; } addExpectedId ( jout . getStanzaId ( ) ) ; sendStanza ( jout ) ; } } } ; JingleTransportListener jingleTransportListener = new JingleTransportListener ( ) { public void transportEstablished ( TransportCandidate local , TransportCandidate remote ) throws NotConnectedException , InterruptedException { if ( isFullyEstablished ( ) ) { setSessionState ( JingleSessionStateActive . getInstance ( ) ) ; for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getNegotiatorState ( ) == JingleNegotiatorState . SUCCEEDED ) contentNegotiator . triggerContentEstablished ( ) ; } if ( getSessionState ( ) . equals ( JingleSessionStatePending . getInstance ( ) ) ) { Jingle jout = new Jingle ( JingleActionEnum . SESSION_ACCEPT ) ; for ( ContentNegotiator contentNegotiator : contentNegotiators ) { if ( contentNegotiator . getNegotiatorState ( ) == JingleNegotiatorState . SUCCEEDED ) jout . addContent ( contentNegotiator . getJingleContent ( ) ) ; } addExpectedId ( jout . getStanzaId ( ) ) ; sendStanza ( jout ) ; } } } public void transportClosed ( TransportCandidate cand ) { } public void transportClosedOnError ( XMPPException e ) { } } ; addMediaListener ( jingleMediaListener ) ; addTransportListener ( jingleTransportListener ) ; } | Setup the listeners that act on events coming from the lower level negotiators . |
19,457 | protected void triggerSessionClosed ( String reason ) { List < JingleListener > listeners = getListenersList ( ) ; for ( JingleListener li : listeners ) { if ( li instanceof JingleSessionListener ) { JingleSessionListener sli = ( JingleSessionListener ) li ; sli . sessionClosed ( reason , this ) ; } } close ( ) ; } | Trigger a session closed event . |
19,458 | protected void triggerSessionClosedOnError ( XMPPException exc ) { for ( ContentNegotiator contentNegotiator : contentNegotiators ) { contentNegotiator . stopJingleMediaSession ( ) ; for ( TransportCandidate candidate : contentNegotiator . getTransportNegotiator ( ) . getOfferedCandidates ( ) ) candidate . removeCandidateEcho ( ) ; } List < JingleListener > listeners = getListenersList ( ) ; for ( JingleListener li : listeners ) { if ( li instanceof JingleSessionListener ) { JingleSessionListener sli = ( JingleSessionListener ) li ; sli . sessionClosedOnError ( exc , this ) ; } } close ( ) ; } | Trigger a session closed event due to an error . |
19,459 | protected void triggerMediaReceived ( String participant ) { List < JingleListener > listeners = getListenersList ( ) ; for ( JingleListener li : listeners ) { if ( li instanceof JingleSessionListener ) { JingleSessionListener sli = ( JingleSessionListener ) li ; sli . sessionMediaReceived ( this , participant ) ; } } } | Trigger a media received event . |
19,460 | public void terminate ( String reason ) throws XMPPException , NotConnectedException , InterruptedException { if ( isClosed ( ) ) return ; LOGGER . fine ( "Terminate " + reason ) ; Jingle jout = new Jingle ( JingleActionEnum . SESSION_TERMINATE ) ; jout . setType ( IQ . Type . set ) ; sendStanza ( jout ) ; triggerSessionClosed ( reason ) ; } | Terminates the session with a custom reason . |
19,461 | public void close ( ) { if ( isClosed ( ) ) return ; setSessionState ( JingleSessionStateEnded . getInstance ( ) ) ; for ( ContentNegotiator contentNegotiator : contentNegotiators ) { contentNegotiator . stopJingleMediaSession ( ) ; for ( TransportCandidate candidate : contentNegotiator . getTransportNegotiator ( ) . getOfferedCandidates ( ) ) candidate . removeCandidateEcho ( ) ; contentNegotiator . close ( ) ; } removeAsyncPacketListener ( ) ; removeConnectionListener ( ) ; getConnection ( ) . removeConnectionListener ( connectionListener ) ; LOGGER . fine ( "Negotiation Closed: " + getConnection ( ) . getUser ( ) + " " + sid ) ; super . close ( ) ; } | Terminate negotiations . |
19,462 | public IQ createJingleError ( IQ iq , JingleError jingleError ) { IQ errorPacket = null ; if ( jingleError != null ) { StanzaError . Builder builder = StanzaError . getBuilder ( StanzaError . Condition . undefined_condition ) ; builder . addExtension ( jingleError ) ; errorPacket = IQ . createErrorResponse ( iq , builder ) ; LOGGER . severe ( "Error sent: " + errorPacket . toXML ( ) ) ; } return errorPacket ; } | Complete and send an error . Complete all the null fields in an IQ error response using the session information we have or some info from the incoming packet . |
19,463 | public void startOutgoing ( ) throws IllegalStateException , SmackException , InterruptedException { updatePacketListener ( ) ; setSessionState ( JingleSessionStatePending . getInstance ( ) ) ; Jingle jingle = new Jingle ( JingleActionEnum . SESSION_INITIATE ) ; for ( JingleMediaManager mediaManager : getMediaManagers ( ) ) { ContentNegotiator contentNeg = new ContentNegotiator ( this , ContentNegotiator . INITIATOR , mediaManager . getName ( ) ) ; contentNeg . setMediaNegotiator ( new MediaNegotiator ( this , mediaManager , mediaManager . getPayloads ( ) , contentNeg ) ) ; JingleTransportManager transportManager = mediaManager . getTransportManager ( ) ; TransportResolver resolver = null ; try { resolver = transportManager . getResolver ( this ) ; } catch ( XMPPException e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } if ( resolver . getType ( ) . equals ( TransportResolver . Type . rawupd ) ) { contentNeg . setTransportNegotiator ( new TransportNegotiator . RawUdp ( this , resolver , contentNeg ) ) ; } if ( resolver . getType ( ) . equals ( TransportResolver . Type . ice ) ) { contentNeg . setTransportNegotiator ( new TransportNegotiator . Ice ( this , resolver , contentNeg ) ) ; } addContentNegotiator ( contentNeg ) ; } for ( ContentNegotiator contentNegotiator : contentNegotiators ) { jingle . addContent ( contentNegotiator . getJingleContent ( ) ) ; } sessionInitPacketID = jingle . getStanzaId ( ) ; sendStanza ( jingle ) ; setupListeners ( ) ; } | This is the starting point for intitiating a new session . |
19,464 | private void startNegotiators ( ) { for ( ContentNegotiator contentNegotiator : contentNegotiators ) { TransportNegotiator transNeg = contentNegotiator . getTransportNegotiator ( ) ; transNeg . start ( ) ; } } | When we initiate a session we need to start a bunch of negotiators right after we receive the result stanza for our session - initiate . This is where we start them . |
19,465 | public Presence cloneWithNewId ( ) { Presence clone = clone ( ) ; clone . setStanzaId ( StanzaIdUtil . newStanzaId ( ) ) ; return clone ; } | Clone this presence and set a newly generated stanza ID as the clone s ID . |
19,466 | public synchronized OutputStream sendFile ( String fileName , long fileSize , String description ) throws XMPPException , SmackException , InterruptedException { if ( isDone ( ) || outputStream != null ) { throw new IllegalStateException ( "The negotiation process has already" + " been attempted on this file transfer" ) ; } try { setFileInfo ( fileName , fileSize ) ; this . outputStream = negotiateStream ( fileName , fileSize , description ) ; } catch ( XMPPErrorException e ) { handleXMPPException ( e ) ; throw e ; } return outputStream ; } | This method handles the negotiation of the file transfer and the stream it only returns the created stream after the negotiation has been completed . |
19,467 | public static void registerSASLMechanism ( SASLMechanism mechanism ) { synchronized ( REGISTERED_MECHANISMS ) { REGISTERED_MECHANISMS . add ( mechanism ) ; Collections . sort ( REGISTERED_MECHANISMS ) ; } } | Registers a new SASL mechanism . |
19,468 | public static Map < String , String > getRegisterdSASLMechanisms ( ) { Map < String , String > answer = new LinkedHashMap < > ( ) ; synchronized ( REGISTERED_MECHANISMS ) { for ( SASLMechanism mechanism : REGISTERED_MECHANISMS ) { answer . put ( mechanism . getClass ( ) . getName ( ) , mechanism . toString ( ) ) ; } } return answer ; } | Returns the registered SASLMechanism sorted by the level of preference . |
19,469 | public static boolean unregisterSASLMechanism ( String clazz ) { synchronized ( REGISTERED_MECHANISMS ) { Iterator < SASLMechanism > it = REGISTERED_MECHANISMS . iterator ( ) ; while ( it . hasNext ( ) ) { SASLMechanism mechanism = it . next ( ) ; if ( mechanism . getClass ( ) . getName ( ) . equals ( clazz ) ) { it . remove ( ) ; return true ; } } } return false ; } | Unregister a SASLMechanism by it s full class name . For example org . jivesoftware . smack . sasl . javax . SASLCramMD5Mechanism . |
19,470 | public void challengeReceived ( String challenge , boolean finalChallenge ) throws SmackSaslException , NotConnectedException , InterruptedException { try { currentMechanism . challengeReceived ( challenge , finalChallenge ) ; } catch ( InterruptedException | SmackSaslException | NotConnectedException e ) { authenticationFailed ( e ) ; throw e ; } } | The server is challenging the SASL authentication we just sent . Forward the challenge to the current SASLMechanism we are using . The SASLMechanism will eventually send a response to the server . The length of the challenge - response sequence varies according to the SASLMechanism in use . |
19,471 | public void authenticated ( Success success ) throws SmackException , InterruptedException { if ( success . getData ( ) != null ) { challengeReceived ( success . getData ( ) , true ) ; } currentMechanism . checkIfSuccessfulOrThrow ( ) ; authenticationSuccessful = true ; synchronized ( this ) { notify ( ) ; } } | Notification message saying that SASL authentication was successful . The next step would be to bind the resource . |
19,472 | public void addAddress ( Type type , Jid jid , String node , String desc , boolean delivered , String uri ) { Address address = new Address ( type ) ; address . setJid ( jid ) ; address . setNode ( node ) ; address . setDescription ( desc ) ; address . setDelivered ( delivered ) ; address . setUri ( uri ) ; addresses . add ( address ) ; } | Adds a new address to which the stanza is going to be sent or was sent . |
19,473 | public void publish ( Item item , String node ) throws NotConnectedException , InterruptedException , NoResponseException , XMPPErrorException , NotAPubSubNodeException , NotALeafNodeException { LeafNode pubSubNode = pepPubSubManager . getLeafNode ( node ) ; pubSubNode . publish ( item ) ; } | Publish an event . |
19,474 | public void addTransports ( final List < JingleTransport > transports ) { synchronized ( transports ) { for ( JingleTransport transport : transports ) { addJingleTransport ( transport ) ; } } } | Adds a list of transports to add to the packet . |
19,475 | public RemoteCommand getRemoteCommand ( Jid jid , String node ) { return new RemoteCommand ( connection ( ) , node , jid ) ; } | Returns a command that represents an instance of a command in a remote host . It is used to execute remote commands . The concept is similar to RMI . Every invocation on this command is equivalent to an invocation in the remote command . |
19,476 | private static IQ respondError ( AdHocCommandData response , StanzaError . Builder error ) { response . setType ( IQ . Type . error ) ; response . setError ( error ) ; return response ; } | Responds an error with an specific error . |
19,477 | private LocalCommand newInstanceOfCmd ( String commandNode , String sessionID ) throws XMPPErrorException , InstantiationException , IllegalAccessException , IllegalArgumentException , InvocationTargetException , NoSuchMethodException , SecurityException { AdHocCommandInfo commandInfo = commands . get ( commandNode ) ; LocalCommand command = commandInfo . getCommandInstance ( ) ; command . setSessionID ( sessionID ) ; command . setName ( commandInfo . getName ( ) ) ; command . setNode ( commandInfo . getNode ( ) ) ; return command ; } | Creates a new instance of a command to be used by a new execution request |
19,478 | public synchronized Set < String > getNames ( ) { if ( map == null ) { return Collections . emptySet ( ) ; } return Collections . unmodifiableSet ( map . keySet ( ) ) ; } | Returns a Set of the names that can be used to get values of the private data . |
19,479 | public boolean isFullyEstablished ( ) { boolean result = true ; MediaNegotiator mediaNeg = getMediaNegotiator ( ) ; if ( ( mediaNeg == null ) || ! mediaNeg . isFullyEstablished ( ) ) { result = false ; } TransportNegotiator transNeg = getTransportNegotiator ( ) ; if ( ( transNeg == null ) || ! transNeg . isFullyEstablished ( ) ) { result = false ; } return result ; } | Return true if the transport and content negotiators have finished . |
19,480 | public JingleNegotiatorState getNegotiatorState ( ) { JingleNegotiatorState result = JingleNegotiatorState . PENDING ; if ( ( mediaNeg != null ) && ( transNeg != null ) ) { if ( ( mediaNeg . getNegotiatorState ( ) == JingleNegotiatorState . SUCCEEDED ) || ( transNeg . getNegotiatorState ( ) == JingleNegotiatorState . SUCCEEDED ) ) result = JingleNegotiatorState . SUCCEEDED ; if ( ( mediaNeg . getNegotiatorState ( ) == JingleNegotiatorState . FAILED ) || ( transNeg . getNegotiatorState ( ) == JingleNegotiatorState . FAILED ) ) result = JingleNegotiatorState . FAILED ; } setNegotiatorState ( result ) ; return result ; } | The negotiator state for the ContentNegotiators is a special case . It is a roll - up of the sub - negotiator states . |
19,481 | public static Boolean getBooleanAttribute ( XmlPullParser parser , String name ) { String valueString = parser . getAttributeValue ( "" , name ) ; if ( valueString == null ) return null ; valueString = valueString . toLowerCase ( Locale . US ) ; return parseXmlBoolean ( valueString ) ; } | Get the boolean value of an argument . |
19,482 | public String getAttributes ( ) { StringBuilder str = new StringBuilder ( ) ; if ( getSid ( ) != null ) str . append ( " sid='" ) . append ( getSid ( ) ) . append ( '\'' ) ; if ( getPass ( ) != null ) str . append ( " pass='" ) . append ( getPass ( ) ) . append ( '\'' ) ; if ( getPortA ( ) != - 1 ) str . append ( " porta='" ) . append ( getPortA ( ) ) . append ( '\'' ) ; if ( getPortB ( ) != - 1 ) str . append ( " portb='" ) . append ( getPortB ( ) ) . append ( '\'' ) ; if ( getHostA ( ) != null ) str . append ( " hosta='" ) . append ( getHostA ( ) ) . append ( '\'' ) ; if ( getHostB ( ) != null ) str . append ( " hostb='" ) . append ( getHostB ( ) ) . append ( '\'' ) ; return str . toString ( ) ; } | Get the attributes string . |
19,483 | protected IQChildElementXmlStringBuilder getIQChildElementBuilder ( IQChildElementXmlStringBuilder str ) { str . attribute ( "sid" , sid ) ; str . rightAngleBracket ( ) ; if ( bridgeAction . equals ( BridgeAction . create ) ) str . append ( "<candidate/>" ) ; else if ( bridgeAction . equals ( BridgeAction . change ) ) str . append ( "<relay " ) . append ( getAttributes ( ) ) . append ( " />" ) ; else str . append ( "<publicip " ) . append ( getAttributes ( ) ) . append ( " />" ) ; return str ; } | Get the Child Element XML of the Packet |
19,484 | @ SuppressWarnings ( "deprecation" ) public static RTPBridge getRTPBridge ( XMPPConnection connection , String sessionID ) throws NotConnectedException , InterruptedException { if ( ! connection . isConnected ( ) ) { return null ; } RTPBridge rtpPacket = new RTPBridge ( sessionID ) ; rtpPacket . setTo ( RTPBridge . NAME + "." + connection . getXMPPServiceDomain ( ) ) ; StanzaCollector collector = connection . createStanzaCollectorAndSend ( rtpPacket ) ; RTPBridge response = collector . nextResult ( ) ; collector . cancel ( ) ; return response ; } | Get a new RTPBridge Candidate from the server . If a error occurs or the server don t support RTPBridge Service null is returned . |
19,485 | @ SuppressWarnings ( "deprecation" ) public static String getPublicIP ( XMPPConnection xmppConnection ) throws NotConnectedException , InterruptedException { if ( ! xmppConnection . isConnected ( ) ) { return null ; } RTPBridge rtpPacket = new RTPBridge ( RTPBridge . BridgeAction . publicip ) ; rtpPacket . setTo ( RTPBridge . NAME + "." + xmppConnection . getXMPPServiceDomain ( ) ) ; rtpPacket . setType ( Type . set ) ; StanzaCollector collector = xmppConnection . createStanzaCollectorAndSend ( rtpPacket ) ; RTPBridge response = collector . nextResult ( ) ; collector . cancel ( ) ; if ( response == null ) return null ; if ( response . getIp ( ) == null || response . getIp ( ) . equals ( "" ) ) return null ; Enumeration < NetworkInterface > ifaces = null ; try { ifaces = NetworkInterface . getNetworkInterfaces ( ) ; } catch ( SocketException e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } while ( ifaces != null && ifaces . hasMoreElements ( ) ) { NetworkInterface iface = ifaces . nextElement ( ) ; Enumeration < InetAddress > iaddresses = iface . getInetAddresses ( ) ; while ( iaddresses . hasMoreElements ( ) ) { InetAddress iaddress = iaddresses . nextElement ( ) ; if ( ! iaddress . isLoopbackAddress ( ) ) if ( iaddress . getHostAddress ( ) . indexOf ( response . getIp ( ) ) >= 0 ) return null ; } } return response . getIp ( ) ; } | Get Public Address from the Server . |
19,486 | public synchronized String start ( ) { if ( started ) return null ; String result = createProcessor ( ) ; if ( result != null ) { started = false ; } result = createTransmitter ( ) ; if ( result != null ) { processor . close ( ) ; processor = null ; started = false ; } else { started = true ; } processor . start ( ) ; return null ; } | Starts the transmission . Returns null if transmission started ok . Otherwise it returns a string with the reason why the setup failed . Starts receive also . |
19,487 | public void stop ( ) { if ( ! started ) return ; synchronized ( this ) { try { started = false ; if ( processor != null ) { processor . stop ( ) ; processor = null ; for ( RTPManager rtpMgr : rtpMgrs ) { rtpMgr . removeReceiveStreamListener ( audioReceiver ) ; rtpMgr . removeSessionListener ( audioReceiver ) ; rtpMgr . removeTargets ( "Session ended." ) ; rtpMgr . dispose ( ) ; } sendStreams . clear ( ) ; } } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } } } | Stops the transmission if already started . Stops the receiver also . |
19,488 | private int getPacketSize ( Format codecFormat , int milliseconds ) throws IllegalArgumentException { String encoding = codecFormat . getEncoding ( ) ; if ( encoding . equalsIgnoreCase ( AudioFormat . GSM ) || encoding . equalsIgnoreCase ( AudioFormat . GSM_RTP ) ) { return milliseconds * 4 ; } else if ( encoding . equalsIgnoreCase ( AudioFormat . ULAW ) || encoding . equalsIgnoreCase ( AudioFormat . ULAW_RTP ) ) { return milliseconds * 8 ; } else { throw new IllegalArgumentException ( "Unknown codec type" ) ; } } | Get the best stanza size for a given codec and a codec rate |
19,489 | private String createTransmitter ( ) { PushBufferDataSource pbds = ( PushBufferDataSource ) dataOutput ; PushBufferStream [ ] pbss = pbds . getStreams ( ) ; rtpMgrs = new RTPManager [ pbss . length ] ; SessionAddress localAddr , destAddr ; InetAddress ipAddr ; SendStream sendStream ; audioReceiver = new AudioReceiver ( this , jingleMediaSession ) ; int port ; for ( int i = 0 ; i < pbss . length ; i ++ ) { try { rtpMgrs [ i ] = RTPManager . newInstance ( ) ; port = portBase + 2 * i ; ipAddr = InetAddress . getByName ( remoteIpAddress ) ; localAddr = new SessionAddress ( InetAddress . getByName ( this . localIpAddress ) , localPort ) ; destAddr = new SessionAddress ( ipAddr , port ) ; rtpMgrs [ i ] . addReceiveStreamListener ( audioReceiver ) ; rtpMgrs [ i ] . addSessionListener ( audioReceiver ) ; BufferControl bc = ( BufferControl ) rtpMgrs [ i ] . getControl ( "javax.media.control.BufferControl" ) ; if ( bc != null ) { int bl = 160 ; bc . setBufferLength ( bl ) ; } try { rtpMgrs [ i ] . initialize ( localAddr ) ; } catch ( InvalidSessionAddressException e ) { SessionAddress sessAddr = new SessionAddress ( ) ; localAddr = new SessionAddress ( sessAddr . getDataAddress ( ) , localPort ) ; rtpMgrs [ i ] . initialize ( localAddr ) ; } rtpMgrs [ i ] . addTarget ( destAddr ) ; LOGGER . severe ( "Created RTP session at " + localPort + " to: " + remoteIpAddress + " " + port ) ; sendStream = rtpMgrs [ i ] . createSendStream ( dataOutput , i ) ; sendStreams . add ( sendStream ) ; sendStream . start ( ) ; } catch ( Exception e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; return e . getMessage ( ) ; } } return null ; } | Use the RTPManager API to create sessions for each jmf track of the processor . |
19,490 | public void setTrasmit ( boolean active ) { for ( SendStream sendStream : sendStreams ) { try { if ( active ) { sendStream . start ( ) ; LOGGER . fine ( "START" ) ; } else { sendStream . stop ( ) ; LOGGER . fine ( "STOP" ) ; } } catch ( IOException e ) { LOGGER . log ( Level . WARNING , "exception" , e ) ; } } } | Set transmit activity . If the active is true the instance should transmit . If it is set to false the instance should pause transmit . |
19,491 | public void sendGeolocation ( GeoLocation geoLocation ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotALeafNodeException { getNode ( ) . publish ( new PayloadItem < GeoLocation > ( geoLocation ) ) ; } | Send geolocation through the PubSub node . |
19,492 | public void stopPublishingGeolocation ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException , NotALeafNodeException { GeoLocation emptyGeolocation = new GeoLocation . Builder ( ) . build ( ) ; getNode ( ) . publish ( new PayloadItem < GeoLocation > ( emptyGeolocation ) ) ; } | Send empty geolocation through the PubSub node . |
19,493 | @ SuppressWarnings ( "unused" ) public void setOmemoStoreBackend ( OmemoStore < T_IdKeyPair , T_IdKey , T_PreKey , T_SigPreKey , T_Sess , T_Addr , T_ECPub , T_Bundle , T_Ciph > omemoStore ) { if ( this . omemoStore != null ) { throw new IllegalStateException ( "An OmemoStore backend has already been set." ) ; } this . omemoStore = omemoStore ; } | Set an omemoStore as backend . Throws an IllegalStateException if there is already a backend set . |
19,494 | protected OmemoRatchet < T_IdKeyPair , T_IdKey , T_PreKey , T_SigPreKey , T_Sess , T_Addr , T_ECPub , T_Bundle , T_Ciph > getOmemoRatchet ( OmemoManager manager ) { OmemoRatchet < T_IdKeyPair , T_IdKey , T_PreKey , T_SigPreKey , T_Sess , T_Addr , T_ECPub , T_Bundle , T_Ciph > omemoRatchet = omemoRatchets . get ( manager ) ; if ( omemoRatchet == null ) { omemoRatchet = instantiateOmemoRatchet ( manager , omemoStore ) ; omemoRatchets . put ( manager , omemoRatchet ) ; } return omemoRatchet ; } | Return the deposited instance of the OmemoRatchet for the given manager . If there is none yet create a new one deposit it and return it . |
19,495 | void init ( OmemoManager . LoggedInOmemoManager managerGuard ) throws InterruptedException , CorruptedOmemoKeyException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException , PubSubException . NotALeafNodeException { OmemoManager manager = managerGuard . get ( ) ; OmemoDevice userDevice = manager . getOwnDevice ( ) ; getOmemoStoreBackend ( ) . replenishKeys ( userDevice ) ; if ( shouldRotateSignedPreKey ( userDevice ) ) { getOmemoStoreBackend ( ) . changeSignedPreKey ( userDevice ) ; } OmemoBundleElement bundle = getOmemoStoreBackend ( ) . packOmemoBundle ( userDevice ) ; publishBundle ( manager . getConnection ( ) , userDevice , bundle ) ; refreshAndRepublishDeviceList ( manager . getConnection ( ) , userDevice ) ; } | Initialize OMEMO functionality for OmemoManager omemoManager . |
19,496 | OmemoElement createRatchetUpdateElement ( OmemoManager . LoggedInOmemoManager managerGuard , OmemoDevice contactsDevice ) throws InterruptedException , SmackException . NoResponseException , CorruptedOmemoKeyException , SmackException . NotConnectedException , CannotEstablishOmemoSessionException , NoSuchAlgorithmException , CryptoFailedException { OmemoManager manager = managerGuard . get ( ) ; OmemoDevice userDevice = manager . getOwnDevice ( ) ; if ( contactsDevice . equals ( userDevice ) ) { throw new IllegalArgumentException ( "\"Thou shall not update thy own ratchet!\" - William Shakespeare" ) ; } if ( ! hasSession ( userDevice , contactsDevice ) ) { buildFreshSessionWithDevice ( manager . getConnection ( ) , userDevice , contactsDevice ) ; } byte [ ] messageKey = OmemoMessageBuilder . generateKey ( KEYTYPE , KEYLENGTH ) ; byte [ ] iv = OmemoMessageBuilder . generateIv ( ) ; OmemoMessageBuilder < T_IdKeyPair , T_IdKey , T_PreKey , T_SigPreKey , T_Sess , T_Addr , T_ECPub , T_Bundle , T_Ciph > builder ; try { builder = new OmemoMessageBuilder < > ( userDevice , gullibleTrustCallback , getOmemoRatchet ( manager ) , messageKey , iv , null ) ; } catch ( InvalidKeyException | InvalidAlgorithmParameterException | NoSuchPaddingException | BadPaddingException | UnsupportedEncodingException | IllegalBlockSizeException e ) { throw new CryptoFailedException ( e ) ; } try { builder . addRecipient ( contactsDevice ) ; } catch ( UndecidedOmemoIdentityException | UntrustedOmemoIdentityException e ) { throw new AssertionError ( "Gullible Trust Callback reported undecided or untrusted device, " + "even though it MUST NOT do that." ) ; } catch ( NoIdentityKeyException e ) { throw new AssertionError ( "We MUST have an identityKey for " + contactsDevice + " since we built a session." + e ) ; } return builder . finish ( ) ; } | Create an empty OMEMO message which is used to forward the ratchet of the recipient . This message type is typically used to create stable sessions . Note that trust decisions are ignored for the creation of this message . |
19,497 | OmemoMessage . Sent createOmemoMessage ( OmemoManager . LoggedInOmemoManager managerGuard , Set < OmemoDevice > contactsDevices , String message ) throws InterruptedException , UndecidedOmemoIdentityException , CryptoFailedException , SmackException . NotConnectedException , SmackException . NoResponseException { byte [ ] key , iv ; iv = OmemoMessageBuilder . generateIv ( ) ; try { key = OmemoMessageBuilder . generateKey ( KEYTYPE , KEYLENGTH ) ; } catch ( NoSuchAlgorithmException e ) { throw new CryptoFailedException ( e ) ; } return encrypt ( managerGuard , contactsDevices , key , iv , message ) ; } | Create an OmemoMessage . |
19,498 | private static OmemoBundleElement fetchBundle ( XMPPConnection connection , OmemoDevice contactsDevice ) throws SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException , XMPPException . XMPPErrorException , PubSubException . NotALeafNodeException , PubSubException . NotAPubSubNodeException { PubSubManager pm = PubSubManager . getInstanceFor ( connection , contactsDevice . getJid ( ) ) ; LeafNode node = pm . getLeafNode ( contactsDevice . getBundleNodeName ( ) ) ; if ( node == null ) { return null ; } List < PayloadItem < OmemoBundleElement > > bundleItems = node . getItems ( ) ; if ( bundleItems . isEmpty ( ) ) { return null ; } return bundleItems . get ( bundleItems . size ( ) - 1 ) . getPayload ( ) ; } | Retrieve a users OMEMO bundle . |
19,499 | static void publishBundle ( XMPPConnection connection , OmemoDevice userDevice , OmemoBundleElement bundle ) throws XMPPException . XMPPErrorException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException { PubSubManager pm = PubSubManager . getInstanceFor ( connection , connection . getUser ( ) . asBareJid ( ) ) ; pm . tryToPublishAndPossibleAutoCreate ( userDevice . getBundleNodeName ( ) , new PayloadItem < > ( bundle ) ) ; } | Publish the given OMEMO bundle to the server using PubSub . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.