idx
int64
0
41.2k
question
stringlengths
74
4.21k
target
stringlengths
5
888
19,300
public static Map < String , Object > getProperties ( Stanza packet ) { JivePropertiesExtension jpe = ( JivePropertiesExtension ) packet . getExtension ( JivePropertiesExtension . NAMESPACE ) ; if ( jpe == null ) { return Collections . emptyMap ( ) ; } return jpe . getProperties ( ) ; }
Return a map of all properties of the given packet . If the stanza contains no properties extension an empty map will be returned .
19,301
public MetaData parse ( XmlPullParser parser , int initialDepth , XmlEnvironment xmlEnvironment ) throws XmlPullParserException , IOException { Map < String , List < String > > metaData = MetaDataUtils . parseMetaData ( parser ) ; return new MetaData ( metaData ) ; }
PacketExtensionProvider implementation .
19,302
public Exception sendAndWaitForResponse ( TopLevelStreamElement request ) throws NoResponseException , NotConnectedException , InterruptedException { assert ( state == State . Initial ) ; connectionLock . lock ( ) ; try { if ( request != null ) { if ( request instanceof Stanza ) { connection . sendStanza ( ( Stanza ) request ) ; } else if ( request instanceof Nonza ) { connection . sendNonza ( ( Nonza ) request ) ; } else { throw new IllegalStateException ( "Unsupported element type" ) ; } state = State . RequestSent ; } waitForConditionOrTimeout ( ) ; } finally { connectionLock . unlock ( ) ; } return checkForResponse ( ) ; }
Send the given top level stream element and wait for a response .
19,303
public void sendAndWaitForResponseOrThrow ( Nonza request ) throws E , NoResponseException , NotConnectedException , InterruptedException , SmackWrappedException { sendAndWaitForResponse ( request ) ; switch ( state ) { case Failure : throwException ( ) ; break ; default : } }
Send the given plain stream element and wait for a response .
19,304
public void reportSuccess ( ) { connectionLock . lock ( ) ; try { state = State . Success ; condition . signalAll ( ) ; } finally { connectionLock . unlock ( ) ; } }
Report this synchronization point as successful .
19,305
public static synchronized PrivacyListManager getInstanceFor ( XMPPConnection connection ) { PrivacyListManager plm = INSTANCES . get ( connection ) ; if ( plm == null ) { plm = new PrivacyListManager ( connection ) ; INSTANCES . put ( connection , plm ) ; } return plm ; }
Returns the PrivacyListManager instance associated with a given XMPPConnection .
19,306
public String getActiveListName ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { if ( cachedActiveListName != null ) { return cachedActiveListName ; } return getPrivacyWithListNames ( ) . getActiveName ( ) ; }
Get the name of the active list .
19,307
public String getDefaultListName ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { if ( cachedDefaultListName != null ) { return cachedDefaultListName ; } return getPrivacyWithListNames ( ) . getDefaultName ( ) ; }
Get the name of the default list .
19,308
public List < PrivacyList > getPrivacyLists ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Privacy privacyAnswer = getPrivacyWithListNames ( ) ; Set < String > names = privacyAnswer . getPrivacyListNames ( ) ; List < PrivacyList > lists = new ArrayList < > ( names . size ( ) ) ; for ( String listName : names ) { boolean isActiveList = listName . equals ( privacyAnswer . getActiveName ( ) ) ; boolean isDefaultList = listName . equals ( privacyAnswer . getDefaultName ( ) ) ; lists . add ( new PrivacyList ( isActiveList , isDefaultList , listName , getPrivacyListItems ( listName ) ) ) ; } return lists ; }
Answer every privacy list with the allowed and blocked permissions .
19,309
public void setActiveListName ( String listName ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Privacy request = new Privacy ( ) ; request . setActiveName ( listName ) ; setRequest ( request ) ; }
Set or change the active list to listName .
19,310
public void declineActiveList ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Privacy request = new Privacy ( ) ; request . setDeclineActiveList ( true ) ; setRequest ( request ) ; }
Client declines the use of active lists .
19,311
public void setDefaultListName ( String listName ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Privacy request = new Privacy ( ) ; request . setDefaultName ( listName ) ; setRequest ( request ) ; }
Set or change the default list to listName .
19,312
public void declineDefaultList ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Privacy request = new Privacy ( ) ; request . setDeclineDefaultList ( true ) ; setRequest ( request ) ; }
Client declines the use of default lists .
19,313
public void createPrivacyList ( String listName , List < PrivacyItem > privacyItems ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { updatePrivacyList ( listName , privacyItems ) ; }
The client has created a new list . It send the new one to the server .
19,314
public void deletePrivacyList ( String listName ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Privacy request = new Privacy ( ) ; request . setPrivacyList ( listName , new ArrayList < PrivacyItem > ( ) ) ; setRequest ( request ) ; }
Remove a privacy list .
19,315
public List < BookmarkedConference > getBookmarkedConferences ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { retrieveBookmarks ( ) ; return Collections . unmodifiableList ( bookmarks . getBookmarkedConferences ( ) ) ; }
Returns all currently bookmarked conferences .
19,316
public void addBookmarkedConference ( String name , EntityBareJid jid , boolean isAutoJoin , Resourcepart nickname , String password ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { retrieveBookmarks ( ) ; BookmarkedConference bookmark = new BookmarkedConference ( name , jid , isAutoJoin , nickname , password ) ; List < BookmarkedConference > conferences = bookmarks . getBookmarkedConferences ( ) ; if ( conferences . contains ( bookmark ) ) { BookmarkedConference oldConference = conferences . get ( conferences . indexOf ( bookmark ) ) ; if ( oldConference . isShared ( ) ) { throw new IllegalArgumentException ( "Cannot modify shared bookmark" ) ; } oldConference . setAutoJoin ( isAutoJoin ) ; oldConference . setName ( name ) ; oldConference . setNickname ( nickname ) ; oldConference . setPassword ( password ) ; } else { bookmarks . addBookmarkedConference ( bookmark ) ; } privateDataManager . setPrivateData ( bookmarks ) ; }
Adds or updates a conference in the bookmarks .
19,317
public void removeBookmarkedConference ( EntityBareJid jid ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { retrieveBookmarks ( ) ; Iterator < BookmarkedConference > it = bookmarks . getBookmarkedConferences ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { BookmarkedConference conference = it . next ( ) ; if ( conference . getJid ( ) . equals ( jid ) ) { if ( conference . isShared ( ) ) { throw new IllegalArgumentException ( "Conference is shared and can't be removed" ) ; } it . remove ( ) ; privateDataManager . setPrivateData ( bookmarks ) ; return ; } } }
Removes a conference from the bookmarks .
19,318
public List < BookmarkedURL > getBookmarkedURLs ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { retrieveBookmarks ( ) ; return Collections . unmodifiableList ( bookmarks . getBookmarkedURLS ( ) ) ; }
Returns an unmodifiable collection of all bookmarked urls .
19,319
public void addBookmarkedURL ( String URL , String name , boolean isRSS ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { retrieveBookmarks ( ) ; BookmarkedURL bookmark = new BookmarkedURL ( URL , name , isRSS ) ; List < BookmarkedURL > urls = bookmarks . getBookmarkedURLS ( ) ; if ( urls . contains ( bookmark ) ) { BookmarkedURL oldURL = urls . get ( urls . indexOf ( bookmark ) ) ; if ( oldURL . isShared ( ) ) { throw new IllegalArgumentException ( "Cannot modify shared bookmarks" ) ; } oldURL . setName ( name ) ; oldURL . setRss ( isRSS ) ; } else { bookmarks . addBookmarkedURL ( bookmark ) ; } privateDataManager . setPrivateData ( bookmarks ) ; }
Adds a new url or updates an already existing url in the bookmarks .
19,320
public void removeBookmarkedURL ( String bookmarkURL ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { retrieveBookmarks ( ) ; Iterator < BookmarkedURL > it = bookmarks . getBookmarkedURLS ( ) . iterator ( ) ; while ( it . hasNext ( ) ) { BookmarkedURL bookmark = it . next ( ) ; if ( bookmark . getURL ( ) . equalsIgnoreCase ( bookmarkURL ) ) { if ( bookmark . isShared ( ) ) { throw new IllegalArgumentException ( "Cannot delete a shared bookmark." ) ; } it . remove ( ) ; privateDataManager . setPrivateData ( bookmarks ) ; return ; } } }
Removes a url from the bookmarks .
19,321
public void setAccessModel ( AccessModel accessModel ) { addField ( ConfigureNodeFields . access_model , FormField . Type . list_single ) ; setAnswer ( ConfigureNodeFields . access_model . getFieldName ( ) , getListSingle ( accessModel . toString ( ) ) ) ; }
Sets the value of access model .
19,322
public void setBodyXSLT ( String bodyXslt ) { addField ( ConfigureNodeFields . body_xslt , FormField . Type . text_single ) ; setAnswer ( ConfigureNodeFields . body_xslt . getFieldName ( ) , bodyXslt ) ; }
Set the URL of an XSL transformation which can be applied to payloads in order to generate an appropriate message body element .
19,323
public void setChildren ( List < String > children ) { addField ( ConfigureNodeFields . children , FormField . Type . text_multi ) ; setAnswer ( ConfigureNodeFields . children . getFieldName ( ) , children ) ; }
Set the list of child node ids that are associated with a collection node .
19,324
public ChildrenAssociationPolicy getChildrenAssociationPolicy ( ) { String value = getFieldValue ( ConfigureNodeFields . children_association_policy ) ; if ( value == null ) return null ; else return ChildrenAssociationPolicy . valueOf ( value ) ; }
Returns the policy that determines who may associate children with the node .
19,325
public void setChildrenAssociationPolicy ( ChildrenAssociationPolicy policy ) { addField ( ConfigureNodeFields . children_association_policy , FormField . Type . list_single ) ; List < String > values = new ArrayList < > ( 1 ) ; values . add ( policy . toString ( ) ) ; setAnswer ( ConfigureNodeFields . children_association_policy . getFieldName ( ) , values ) ; }
Sets the policy that determines who may associate children with the node .
19,326
public void setChildrenMax ( int max ) { addField ( ConfigureNodeFields . children_max , FormField . Type . text_single ) ; setAnswer ( ConfigureNodeFields . children_max . getFieldName ( ) , max ) ; }
Set the maximum number of child nodes that can be associated with a collection node .
19,327
public void setCollection ( String collection ) { addField ( ConfigureNodeFields . collection , FormField . Type . text_single ) ; setAnswer ( ConfigureNodeFields . collection . getFieldName ( ) , collection ) ; }
Sets the collection node which the node is affiliated with .
19,328
public void setDataformXSLT ( String url ) { addField ( ConfigureNodeFields . dataform_xslt , FormField . Type . text_single ) ; setAnswer ( ConfigureNodeFields . dataform_xslt . getFieldName ( ) , url ) ; }
Sets the URL of an XSL transformation which can be applied to the payload format in order to generate a valid Data Forms result that the client could display using a generic Data Forms rendering engine .
19,329
public void setDeliverPayloads ( boolean deliver ) { addField ( ConfigureNodeFields . deliver_payloads , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . deliver_payloads . getFieldName ( ) , deliver ) ; }
Sets whether the node will deliver payloads with event notifications .
19,330
public ItemReply getItemReply ( ) { String value = getFieldValue ( ConfigureNodeFields . itemreply ) ; if ( value == null ) return null ; else return ItemReply . valueOf ( value ) ; }
Determines who should get replies to items .
19,331
public void setItemReply ( ItemReply reply ) { addField ( ConfigureNodeFields . itemreply , FormField . Type . list_single ) ; setAnswer ( ConfigureNodeFields . itemreply . getFieldName ( ) , getListSingle ( reply . toString ( ) ) ) ; }
Sets who should get the replies to items .
19,332
public void setMaxPayloadSize ( int max ) { addField ( ConfigureNodeFields . max_payload_size , FormField . Type . text_single ) ; setAnswer ( ConfigureNodeFields . max_payload_size . getFieldName ( ) , max ) ; }
Sets the maximum payload size in bytes .
19,333
public NodeType getNodeType ( ) { String value = getFieldValue ( ConfigureNodeFields . node_type ) ; if ( value == null ) return null ; else return NodeType . valueOf ( value ) ; }
Gets the node type .
19,334
public void setNotifyConfig ( boolean notify ) { addField ( ConfigureNodeFields . notify_config , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . notify_config . getFieldName ( ) , notify ) ; }
Sets whether subscribers should be notified when the configuration changes .
19,335
public void setNotifyDelete ( boolean notify ) { addField ( ConfigureNodeFields . notify_delete , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . notify_delete . getFieldName ( ) , notify ) ; }
Sets whether subscribers should be notified when the node is deleted .
19,336
public void setNotifyRetract ( boolean notify ) { addField ( ConfigureNodeFields . notify_retract , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . notify_retract . getFieldName ( ) , notify ) ; }
Sets whether subscribers should be notified when items are deleted from the node .
19,337
public NotificationType getNotificationType ( ) { String value = getFieldValue ( ConfigureNodeFields . notification_type ) ; if ( value == null ) return null ; return NotificationType . valueOf ( value ) ; }
Determines the type of notifications which are sent .
19,338
public void setNotificationType ( NotificationType notificationType ) { addField ( ConfigureNodeFields . notification_type , FormField . Type . list_single ) ; setAnswer ( ConfigureNodeFields . notification_type . getFieldName ( ) , getListSingle ( notificationType . toString ( ) ) ) ; }
Sets the NotificationType for the node .
19,339
public void setPersistentItems ( boolean persist ) { addField ( ConfigureNodeFields . persist_items , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . persist_items . getFieldName ( ) , persist ) ; }
Sets whether items should be persisted in the node .
19,340
public void setPresenceBasedDelivery ( boolean presenceBased ) { addField ( ConfigureNodeFields . presence_based_delivery , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . presence_based_delivery . getFieldName ( ) , presenceBased ) ; }
Sets whether to deliver notifications to available users only .
19,341
public PublishModel getPublishModel ( ) { String value = getFieldValue ( ConfigureNodeFields . publish_model ) ; if ( value == null ) return null ; else return PublishModel . valueOf ( value ) ; }
Gets the publishing model for the node which determines who may publish to it .
19,342
public void setPublishModel ( PublishModel publish ) { addField ( ConfigureNodeFields . publish_model , FormField . Type . list_single ) ; setAnswer ( ConfigureNodeFields . publish_model . getFieldName ( ) , getListSingle ( publish . toString ( ) ) ) ; }
Sets the publishing model for the node which determines who may publish to it .
19,343
public void setReplyRoom ( List < String > replyRooms ) { addField ( ConfigureNodeFields . replyroom , FormField . Type . list_multi ) ; setAnswer ( ConfigureNodeFields . replyroom . getFieldName ( ) , replyRooms ) ; }
Sets the multi user chat rooms that are specified as reply rooms .
19,344
public void setReplyTo ( List < String > replyTos ) { addField ( ConfigureNodeFields . replyto , FormField . Type . list_multi ) ; setAnswer ( ConfigureNodeFields . replyto . getFieldName ( ) , replyTos ) ; }
Sets the specific JID s for reply to .
19,345
public void setRosterGroupsAllowed ( List < String > groups ) { addField ( ConfigureNodeFields . roster_groups_allowed , FormField . Type . list_multi ) ; setAnswer ( ConfigureNodeFields . roster_groups_allowed . getFieldName ( ) , groups ) ; }
Sets the roster groups that are allowed to subscribe and retrieve items .
19,346
public void setSubscribe ( boolean subscribe ) { addField ( ConfigureNodeFields . subscribe , FormField . Type . bool ) ; setAnswer ( ConfigureNodeFields . subscribe . getFieldName ( ) , subscribe ) ; }
Sets whether subscriptions are allowed .
19,347
public void setTitle ( String title ) { addField ( ConfigureNodeFields . title , FormField . Type . text_single ) ; setAnswer ( ConfigureNodeFields . title . getFieldName ( ) , title ) ; }
Sets a human readable title for the node .
19,348
OmemoCachedDeviceList mergeCachedDeviceList ( OmemoDevice userDevice , BareJid contact , OmemoDeviceListElement list ) { OmemoCachedDeviceList cached = loadCachedDeviceList ( userDevice , contact ) ; if ( cached == null ) { cached = new OmemoCachedDeviceList ( ) ; } if ( list == null ) { return cached ; } for ( int devId : list . getDeviceIds ( ) ) { if ( ! cached . contains ( devId ) ) { setDateOfLastDeviceIdPublication ( userDevice , new OmemoDevice ( contact , devId ) , new Date ( ) ) ; } } cached . merge ( list . getDeviceIds ( ) ) ; storeCachedDeviceList ( userDevice , contact , cached ) ; return cached ; }
Merge the received OmemoDeviceListElement with the one we already have . If we had none the received one is saved .
19,349
private void removeOldSignedPreKeys ( OmemoDevice userDevice ) { if ( OmemoConfiguration . getMaxNumberOfStoredSignedPreKeys ( ) <= 0 ) { return ; } TreeMap < Integer , T_SigPreKey > signedPreKeys = loadOmemoSignedPreKeys ( userDevice ) ; for ( int i = 0 ; i < signedPreKeys . keySet ( ) . size ( ) - OmemoConfiguration . getMaxNumberOfStoredSignedPreKeys ( ) ; i ++ ) { int keyId = signedPreKeys . firstKey ( ) ; LOGGER . log ( Level . INFO , "Remove signedPreKey " + keyId + "." ) ; removeOmemoSignedPreKey ( userDevice , i ) ; signedPreKeys = loadOmemoSignedPreKeys ( userDevice ) ; } }
Remove the oldest signedPreKey until there are only MAX_NUMBER_OF_STORED_SIGNED_PREKEYS left .
19,350
OmemoBundleElement_VAxolotl packOmemoBundle ( OmemoDevice userDevice ) throws CorruptedOmemoKeyException { int currentSignedPreKeyId = loadCurrentOmemoSignedPreKeyId ( userDevice ) ; T_SigPreKey currentSignedPreKey = loadOmemoSignedPreKeys ( userDevice ) . get ( currentSignedPreKeyId ) ; return new OmemoBundleElement_VAxolotl ( currentSignedPreKeyId , keyUtil ( ) . signedPreKeyPublicForBundle ( currentSignedPreKey ) , keyUtil ( ) . signedPreKeySignatureFromKey ( currentSignedPreKey ) , keyUtil ( ) . identityKeyForBundle ( keyUtil ( ) . identityKeyFromPair ( loadOmemoIdentityKeyPair ( userDevice ) ) ) , keyUtil ( ) . preKeyPublicKeysForBundle ( loadOmemoPreKeys ( userDevice ) ) ) ; }
Pack a OmemoBundleElement containing our key material .
19,351
public void replenishKeys ( OmemoDevice userDevice ) throws CorruptedOmemoKeyException { T_IdKeyPair identityKeyPair = loadOmemoIdentityKeyPair ( userDevice ) ; if ( identityKeyPair == null ) { identityKeyPair = generateOmemoIdentityKeyPair ( ) ; storeOmemoIdentityKeyPair ( userDevice , identityKeyPair ) ; } TreeMap < Integer , T_SigPreKey > signedPreKeys = loadOmemoSignedPreKeys ( userDevice ) ; if ( signedPreKeys . size ( ) == 0 ) { changeSignedPreKey ( userDevice ) ; } TreeMap < Integer , T_PreKey > preKeys = loadOmemoPreKeys ( userDevice ) ; int newKeysCount = PRE_KEY_COUNT_PER_BUNDLE - preKeys . size ( ) ; int startId = preKeys . size ( ) == 0 ? 0 : preKeys . lastKey ( ) ; if ( newKeysCount > 0 ) { TreeMap < Integer , T_PreKey > newKeys = generateOmemoPreKeys ( startId + 1 , newKeysCount ) ; storeOmemoPreKeys ( userDevice , newKeys ) ; } }
Replenish our supply of keys . If we are missing any type of keys generate them fresh .
19,352
public TreeMap < Integer , T_PreKey > generateOmemoPreKeys ( int startId , int count ) { return keyUtil ( ) . generateOmemoPreKeys ( startId , count ) ; }
Generate count new PreKeys beginning with id startId . These preKeys are published and can be used by contacts to establish sessions with us .
19,353
public void storeOmemoPreKeys ( OmemoDevice userDevice , TreeMap < Integer , T_PreKey > preKeyHashMap ) { for ( Map . Entry < Integer , T_PreKey > entry : preKeyHashMap . entrySet ( ) ) { storeOmemoPreKey ( userDevice , entry . getKey ( ) , entry . getValue ( ) ) ; } }
Store a whole bunch of preKeys .
19,354
public T_SigPreKey generateOmemoSignedPreKey ( T_IdKeyPair identityKeyPair , int signedPreKeyId ) throws CorruptedOmemoKeyException { return keyUtil ( ) . generateOmemoSignedPreKey ( identityKeyPair , signedPreKeyId ) ; }
Generate a new signed preKey .
19,355
public OmemoFingerprint getFingerprint ( OmemoDevice userDevice ) throws CorruptedOmemoKeyException { T_IdKeyPair keyPair = loadOmemoIdentityKeyPair ( userDevice ) ; if ( keyPair == null ) { return null ; } return keyUtil ( ) . getFingerprintOfIdentityKey ( keyUtil ( ) . identityKeyFromPair ( keyPair ) ) ; }
Return our identityKeys fingerprint .
19,356
public OmemoFingerprint getFingerprint ( OmemoDevice userDevice , OmemoDevice contactsDevice ) throws CorruptedOmemoKeyException , NoIdentityKeyException { T_IdKey identityKey = loadOmemoIdentityKey ( userDevice , contactsDevice ) ; if ( identityKey == null ) { throw new NoIdentityKeyException ( contactsDevice ) ; } return keyUtil ( ) . getFingerprintOfIdentityKey ( identityKey ) ; }
Return the fingerprint of the identityKey belonging to contactsDevice .
19,357
public OmemoFingerprint getFingerprintAndMaybeBuildSession ( OmemoManager . LoggedInOmemoManager managerGuard , OmemoDevice contactsDevice ) throws CannotEstablishOmemoSessionException , CorruptedOmemoKeyException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException { OmemoManager omemoManager = managerGuard . get ( ) ; T_IdKey identityKey = loadOmemoIdentityKey ( omemoManager . getOwnDevice ( ) , contactsDevice ) ; if ( identityKey == null ) { OmemoService . getInstance ( ) . buildFreshSessionWithDevice ( omemoManager . getConnection ( ) , omemoManager . getOwnDevice ( ) , contactsDevice ) ; } identityKey = loadOmemoIdentityKey ( omemoManager . getOwnDevice ( ) , contactsDevice ) ; if ( identityKey == null ) { return null ; } return keyUtil ( ) . getFingerprintOfIdentityKey ( identityKey ) ; }
Return the fingerprint of the given devices announced identityKey . If we have no local copy of the identityKey of the contact build a fresh session in order to get the key .
19,358
public List < PrivacyItem > setPrivacyList ( String listName , List < PrivacyItem > listItem ) { this . getItemLists ( ) . put ( listName , listItem ) ; return listItem ; }
Set or update a privacy list with privacy items .
19,359
public void deletePrivacyList ( String listName ) { this . getItemLists ( ) . remove ( listName ) ; if ( this . getDefaultName ( ) != null && listName . equals ( this . getDefaultName ( ) ) ) { this . setDefaultName ( null ) ; } }
Deletes an existing privacy list . If the privacy list being deleted was the default list then the user will end up with no default list . Therefore the user will have to set a new default list .
19,360
public PrivacyItem getItem ( String listName , int order ) { Iterator < PrivacyItem > values = getPrivacyList ( listName ) . iterator ( ) ; PrivacyItem itemFound = null ; while ( itemFound == null && values . hasNext ( ) ) { PrivacyItem element = values . next ( ) ; if ( element . getOrder ( ) == order ) { itemFound = element ; } } return itemFound ; }
Returns the privacy item in the specified order .
19,361
public boolean changeDefaultList ( String newDefault ) { if ( this . getItemLists ( ) . containsKey ( newDefault ) ) { this . setDefaultName ( newDefault ) ; return true ; } else { return false ; } }
Sets a given privacy list as the new user default list .
19,362
public static synchronized DeliveryReceiptManager getInstanceFor ( XMPPConnection connection ) { DeliveryReceiptManager receiptManager = instances . get ( connection ) ; if ( receiptManager == null ) { receiptManager = new DeliveryReceiptManager ( connection ) ; instances . put ( connection , receiptManager ) ; } return receiptManager ; }
Obtain the DeliveryReceiptManager responsible for a connection .
19,363
public boolean isSupported ( Jid jid ) throws SmackException , XMPPException , InterruptedException { return ServiceDiscoveryManager . getInstanceFor ( connection ( ) ) . supportsFeature ( jid , DeliveryReceipt . NAMESPACE ) ; }
Returns true if Delivery Receipts are supported by a given JID .
19,364
public void addAudioPayloadTypes ( final List < PayloadType . Audio > pts ) { synchronized ( payloads ) { Iterator < PayloadType . Audio > ptIter = pts . iterator ( ) ; while ( ptIter . hasNext ( ) ) { PayloadType . Audio pt = ptIter . next ( ) ; addJinglePayloadType ( new JinglePayloadType . Audio ( pt ) ) ; } } }
Adds a list of payloads to the packet .
19,365
private static CharSequence escapeForXml ( final CharSequence input , final XmlEscapeMode xmlEscapeMode ) { if ( input == null ) { return null ; } final int len = input . length ( ) ; final StringBuilder out = new StringBuilder ( ( int ) ( len * 1.3 ) ) ; CharSequence toAppend ; char ch ; int last = 0 ; int i = 0 ; while ( i < len ) { toAppend = null ; ch = input . charAt ( i ) ; switch ( xmlEscapeMode ) { case safe : switch ( ch ) { case '<' : toAppend = LT_ENCODE ; break ; case '>' : toAppend = GT_ENCODE ; break ; case '&' : toAppend = AMP_ENCODE ; break ; case '"' : toAppend = QUOTE_ENCODE ; break ; case '\'' : toAppend = APOS_ENCODE ; break ; default : break ; } break ; case forAttribute : switch ( ch ) { case '<' : toAppend = LT_ENCODE ; break ; case '&' : toAppend = AMP_ENCODE ; break ; case '"' : toAppend = QUOTE_ENCODE ; break ; case '\'' : toAppend = APOS_ENCODE ; break ; default : break ; } break ; case forAttributeApos : switch ( ch ) { case '<' : toAppend = LT_ENCODE ; break ; case '&' : toAppend = AMP_ENCODE ; break ; case '\'' : toAppend = APOS_ENCODE ; break ; default : break ; } break ; case forText : switch ( ch ) { case '<' : toAppend = LT_ENCODE ; break ; case '&' : toAppend = AMP_ENCODE ; break ; default : break ; } break ; } if ( toAppend != null ) { if ( i > last ) { out . append ( input , last , i ) ; } out . append ( toAppend ) ; last = ++ i ; } else { i ++ ; } } if ( last == 0 ) { return input ; } if ( i > last ) { out . append ( input , last , i ) ; } return out ; }
Escapes all necessary characters in the CharSequence so that it can be used in an XML doc .
19,366
public static String encodeHex ( byte [ ] bytes ) { char [ ] hexChars = new char [ bytes . length * 2 ] ; for ( int j = 0 ; j < bytes . length ; j ++ ) { int v = bytes [ j ] & 0xFF ; hexChars [ j * 2 ] = HEX_CHARS [ v >>> 4 ] ; hexChars [ j * 2 + 1 ] = HEX_CHARS [ v & 0x0F ] ; } return new String ( hexChars ) ; }
Encodes an array of bytes as String representation of hexadecimal .
19,367
public static boolean isNotEmpty ( CharSequence ... css ) { for ( CharSequence cs : css ) { if ( StringUtils . isNullOrEmpty ( cs ) ) { return false ; } } return true ; }
Returns true if all given CharSequences are not empty .
19,368
public static StringBuilder toStringBuilder ( Collection < ? extends Object > collection , String delimiter ) { StringBuilder sb = new StringBuilder ( collection . size ( ) * 20 ) ; for ( Iterator < ? extends Object > it = collection . iterator ( ) ; it . hasNext ( ) ; ) { Object cs = it . next ( ) ; sb . append ( cs ) ; if ( it . hasNext ( ) ) { sb . append ( delimiter ) ; } } return sb ; }
Transform a collection of objects to a delimited String .
19,369
public static FromMatchesFilter create ( Jid address ) { return new FromMatchesFilter ( address , address != null ? address . hasNoResource ( ) : false ) ; }
Creates a filter matching on the from 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,370
public static synchronized XDataManager getInstanceFor ( XMPPConnection connection ) { XDataManager xDataManager = INSTANCES . get ( connection ) ; if ( xDataManager == null ) { xDataManager = new XDataManager ( connection ) ; INSTANCES . put ( connection , xDataManager ) ; } return xDataManager ; }
Get the XDataManager for the given XMPP connection .
19,371
public static float [ ] RGBFrom ( CharSequence input , ConsistentColorSettings settings ) { double angle = createAngle ( input ) ; double correctedAngle = applyColorDeficiencyCorrection ( angle , settings . getDeficiency ( ) ) ; double [ ] CbCr = angleToCbCr ( correctedAngle ) ; float [ ] rgb = CbCrToRGB ( CbCr , Y ) ; return rgb ; }
Return the consistent RGB color value for the input . This method respects the color vision deficiency mode set by the user .
19,372
public < T extends Item > List < T > getItems ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return getItems ( ( List < ExtensionElement > ) null , null ) ; }
Get the current items stored in the node .
19,373
public < T extends Item > List < T > getItems ( String subscriptionId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub request = createPubsubPacket ( Type . get , new GetItemsRequest ( getId ( ) , subscriptionId ) ) ; return getItems ( request ) ; }
Get the current items stored in the node based on the subscription associated with the provided subscription id .
19,374
@ SuppressWarnings ( "unchecked" ) public < T extends Item > void send ( T item ) throws NotConnectedException , InterruptedException , NoResponseException , XMPPErrorException { publish ( item ) ; }
Publishes an event to the node . This is a simple item with no payload .
19,375
public void publish ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub packet = createPubsubPacket ( Type . set , new NodeExtension ( PubSubElementType . PUBLISH , getId ( ) ) ) ; pubSubManager . getConnection ( ) . createStanzaCollectorAndSend ( packet ) . nextResultOrThrow ( ) ; }
Publishes an event to the node . This is an empty event with no item .
19,376
@ SuppressWarnings ( "unchecked" ) public < T extends Item > void publish ( T item ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Collection < T > items = new ArrayList < > ( 1 ) ; items . add ( ( item == null ? ( T ) new Item ( ) : item ) ) ; publish ( items ) ; }
Publishes an event to the node . This can be either a simple item with no payload or one with it . This is determined by the Node configuration .
19,377
public void deleteAllItems ( ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { PubSub request = createPubsubPacket ( Type . set , new NodeExtension ( PubSubElementType . PURGE_OWNER , getId ( ) ) ) ; pubSubManager . getConnection ( ) . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; }
Purges the node of all items .
19,378
public void deleteItem ( String itemId ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { Collection < String > items = new ArrayList < > ( 1 ) ; items . add ( itemId ) ; deleteItem ( items ) ; }
Delete the item with the specified id from the node .
19,379
public void deleteItem ( Collection < String > itemIds ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { List < Item > items = new ArrayList < > ( itemIds . size ( ) ) ; for ( String id : itemIds ) { items . add ( new Item ( id ) ) ; } PubSub request = createPubsubPacket ( Type . set , new ItemsExtension ( ItemsExtension . ItemsElementType . retract , getId ( ) , items ) ) ; pubSubManager . getConnection ( ) . createStanzaCollectorAndSend ( request ) . nextResultOrThrow ( ) ; }
Delete the items with the specified id s from the node .
19,380
public OpenPgpV4Fingerprint generateAndImportKeyPair ( BareJid ourJid ) throws NoSuchAlgorithmException , InvalidAlgorithmParameterException , NoSuchProviderException , PGPException , IOException { throwIfNoProviderSet ( ) ; OpenPgpStore store = provider . getStore ( ) ; PGPKeyRing keys = store . generateKeyRing ( ourJid ) ; try { store . importSecretKey ( ourJid , keys . getSecretKeys ( ) ) ; store . importPublicKey ( ourJid , keys . getPublicKeys ( ) ) ; } catch ( MissingUserIdOnKeyException e ) { throw new AssertionError ( e ) ; } OpenPgpV4Fingerprint fingerprint = new OpenPgpV4Fingerprint ( keys . getSecretKeys ( ) ) ; store . setTrust ( ourJid , fingerprint , OpenPgpTrustStore . Trust . trusted ) ; return fingerprint ; }
Generate a fresh OpenPGP key pair and import it .
19,381
public static boolean serverSupportsSecretKeyBackups ( XMPPConnection connection ) throws XMPPException . XMPPErrorException , SmackException . NotConnectedException , InterruptedException , SmackException . NoResponseException { return ServiceDiscoveryManager . getInstanceFor ( connection ) . serverSupportsFeature ( PubSubFeature . access_whitelist . toString ( ) ) ; }
Determine if we can sync secret keys using private PEP nodes as described in the XEP . Requirements on the server side are support for PEP and support for the whitelist access model of PubSub .
19,382
public void backupSecretKeyToServer ( DisplayBackupCodeCallback displayCodeCallback , SecretKeyBackupSelectionCallback selectKeyCallback ) throws InterruptedException , PubSubException . NotALeafNodeException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException , SmackException . NotLoggedInException , IOException , SmackException . FeatureNotSupportedException , PGPException , MissingOpenPgpKeyException { throwIfNoProviderSet ( ) ; throwIfNotAuthenticated ( ) ; BareJid ownJid = connection ( ) . getUser ( ) . asBareJid ( ) ; String backupCode = SecretKeyBackupHelper . generateBackupPassword ( ) ; PGPSecretKeyRingCollection secretKeyRings = provider . getStore ( ) . getSecretKeysOf ( ownJid ) ; Set < OpenPgpV4Fingerprint > availableKeyPairs = new HashSet < > ( ) ; for ( PGPSecretKeyRing ring : secretKeyRings ) { availableKeyPairs . add ( new OpenPgpV4Fingerprint ( ring ) ) ; } Set < OpenPgpV4Fingerprint > selectedKeyPairs = selectKeyCallback . selectKeysToBackup ( availableKeyPairs ) ; SecretkeyElement secretKey = SecretKeyBackupHelper . createSecretkeyElement ( provider , ownJid , selectedKeyPairs , backupCode ) ; OpenPgpPubSubUtil . depositSecretKey ( connection ( ) , secretKey ) ; displayCodeCallback . displayBackupCode ( backupCode ) ; }
Upload the encrypted secret key to a private PEP node .
19,383
public OpenPgpV4Fingerprint restoreSecretKeyServerBackup ( AskForBackupCodeCallback codeCallback ) throws InterruptedException , PubSubException . NotALeafNodeException , XMPPException . XMPPErrorException , SmackException . NotConnectedException , SmackException . NoResponseException , InvalidBackupCodeException , SmackException . NotLoggedInException , IOException , MissingUserIdOnKeyException , NoBackupFoundException , PGPException { throwIfNoProviderSet ( ) ; throwIfNotAuthenticated ( ) ; SecretkeyElement backup = OpenPgpPubSubUtil . fetchSecretKey ( pepManager ) ; if ( backup == null ) { throw new NoBackupFoundException ( ) ; } String backupCode = codeCallback . askForBackupCode ( ) ; PGPSecretKeyRing secretKeys = SecretKeyBackupHelper . restoreSecretKeyBackup ( backup , backupCode ) ; provider . getStore ( ) . importSecretKey ( getJidOrThrow ( ) , secretKeys ) ; provider . getStore ( ) . importPublicKey ( getJidOrThrow ( ) , BCUtil . publicKeyRingFromSecretKeyRing ( secretKeys ) ) ; ByteArrayOutputStream buffer = new ByteArrayOutputStream ( 2048 ) ; for ( PGPSecretKey sk : secretKeys ) { PGPPublicKey pk = sk . getPublicKey ( ) ; if ( pk != null ) pk . encode ( buffer ) ; } PGPPublicKeyRing publicKeys = new PGPPublicKeyRing ( buffer . toByteArray ( ) , new BcKeyFingerprintCalculator ( ) ) ; provider . getStore ( ) . importPublicKey ( getJidOrThrow ( ) , publicKeys ) ; return new OpenPgpV4Fingerprint ( secretKeys ) ; }
Fetch a secret key backup from the server and try to restore a selected secret key from it .
19,384
public String toXML ( ) { StringBuilder buf = new StringBuilder ( ) ; buf . append ( "<item" ) ; if ( this . isAllow ( ) ) { buf . append ( " action=\"allow\"" ) ; } else { buf . append ( " action=\"deny\"" ) ; } buf . append ( " order=\"" ) . append ( getOrder ( ) ) . append ( '"' ) ; if ( getType ( ) != null ) { buf . append ( " type=\"" ) . append ( getType ( ) ) . append ( '"' ) ; } if ( getValue ( ) != null ) { buf . append ( " value=\"" ) . append ( getValue ( ) ) . append ( '"' ) ; } if ( isFilterEverything ( ) ) { buf . append ( "/>" ) ; } else { buf . append ( '>' ) ; if ( this . isFilterIQ ( ) ) { buf . append ( "<iq/>" ) ; } if ( this . isFilterMessage ( ) ) { buf . append ( "<message/>" ) ; } if ( this . isFilterPresenceIn ( ) ) { buf . append ( "<presence-in/>" ) ; } if ( this . isFilterPresenceOut ( ) ) { buf . append ( "<presence-out/>" ) ; } buf . append ( "</item>" ) ; } return buf . toString ( ) ; }
Answer an xml representation of the receiver according to the RFC 3921 .
19,385
private static Object decode ( Class < ? > type , String value ) throws ClassNotFoundException { String name = type . getName ( ) ; switch ( name ) { case "java.lang.String" : return value ; case "boolean" : return Boolean . valueOf ( value ) ; case "int" : return Integer . valueOf ( value ) ; case "long" : return Long . valueOf ( value ) ; case "float" : return Float . valueOf ( value ) ; case "double" : return Double . valueOf ( value ) ; case "short" : return Short . valueOf ( value ) ; case "byte" : return Byte . valueOf ( value ) ; case "java.lang.Class" : return Class . forName ( value ) ; } return null ; }
Decodes a String into an object of the specified type . If the object type is not supported null will be returned .
19,386
public static List < CharSequence > getBodies ( Message message ) { XHTMLExtension xhtmlExtension = XHTMLExtension . from ( message ) ; if ( xhtmlExtension != null ) return xhtmlExtension . getBodies ( ) ; else return null ; }
Returns an Iterator for the XHTML bodies in the message . Returns null if the message does not contain an XHTML extension .
19,387
public static void addBody ( Message message , XHTMLText xhtmlText ) { XHTMLExtension xhtmlExtension = XHTMLExtension . from ( message ) ; if ( xhtmlExtension == null ) { xhtmlExtension = new XHTMLExtension ( ) ; message . addExtension ( xhtmlExtension ) ; } xhtmlExtension . addBody ( xhtmlText . toXML ( ) ) ; }
Adds an XHTML body to the message .
19,388
public static boolean isXHTMLMessage ( Message message ) { return message . getExtension ( XHTMLExtension . ELEMENT , XHTMLExtension . NAMESPACE ) != null ; }
Returns true if the message contains an XHTML extension .
19,389
public static boolean isServiceEnabled ( XMPPConnection connection , Jid userID ) throws NoResponseException , XMPPErrorException , NotConnectedException , InterruptedException { return ServiceDiscoveryManager . getInstanceFor ( connection ) . supportsFeature ( userID , XHTMLExtension . NAMESPACE ) ; }
Returns true if the specified user handles XHTML messages .
19,390
public static void deleteDirectory ( File root ) { File [ ] currList ; Stack < File > stack = new Stack < > ( ) ; stack . push ( root ) ; while ( ! stack . isEmpty ( ) ) { if ( stack . lastElement ( ) . isDirectory ( ) ) { currList = stack . lastElement ( ) . listFiles ( ) ; if ( currList != null && currList . length > 0 ) { for ( File curr : currList ) { stack . push ( curr ) ; } } else { stack . pop ( ) . delete ( ) ; } } else { stack . pop ( ) . delete ( ) ; } } }
Delete a directory with all subdirectories .
19,391
public List < CharSequence > getAsList ( ) { if ( cache != null ) { return Collections . singletonList ( ( CharSequence ) cache ) ; } return Collections . unmodifiableList ( list ) ; }
Get the List of CharSequences representation of this instance . The list is unmodifiable . If the resulting String was already cached a list with a single String entry will be returned .
19,392
public XmlStringBuilder attribute ( String name , String value ) { assert value != null ; sb . append ( ' ' ) . append ( name ) . append ( "='" ) ; escapeAttributeValue ( value ) ; sb . append ( '\'' ) ; return this ; }
Does nothing if value is null .
19,393
public boolean isDone ( ) { return status == Status . cancelled || status == Status . error || status == Status . complete || status == Status . refused ; }
Returns true if the transfer has been cancelled if it has stopped because of a an error or the transfer completed successfully .
19,394
private static void writeInfoToFile ( File file , DiscoverInfo info ) throws IOException { try ( DataOutputStream dos = new DataOutputStream ( new FileOutputStream ( file ) ) ) { dos . writeUTF ( info . toXML ( ) . toString ( ) ) ; } }
Writes the DiscoverInfo stanza to an file
19,395
private static DiscoverInfo restoreInfoFromFile ( File file ) throws Exception { String fileContent ; try ( DataInputStream dis = new DataInputStream ( new FileInputStream ( file ) ) ) { fileContent = dis . readUTF ( ) ; } if ( fileContent == null ) { return null ; } return PacketParserUtils . parseStanza ( fileContent ) ; }
Tries to restore an DiscoverInfo stanza from a file .
19,396
public IQ processJingle ( JingleSession session , Jingle jingle , JingleActionEnum action ) { IQ response ; response = session . createJingleError ( jingle , JingleError . MALFORMED_STANZA ) ; return response ; }
Pretty much nothing is valid for receiving once we ve ended the session .
19,397
public void merge ( Set < Integer > deviceListUpdate ) { inactiveDevices . addAll ( activeDevices ) ; activeDevices . clear ( ) ; activeDevices . addAll ( deviceListUpdate ) ; inactiveDevices . removeAll ( activeDevices ) ; }
Merge a device list update into the CachedDeviceList . The source code should be self explanatory .
19,398
public XHTMLText appendOpenAnchorTag ( String href , String style ) { text . halfOpenElement ( A ) ; text . optAttribute ( HREF , href ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; }
Appends a tag that indicates that an anchor section begins .
19,399
public XHTMLText appendOpenBlockQuoteTag ( String style ) { text . halfOpenElement ( BLOCKQUOTE ) ; text . optAttribute ( STYLE , style ) ; text . rightAngleBracket ( ) ; return this ; }
Appends a tag that indicates that a blockquote section begins .