id
int32
0
165k
repo
stringlengths
7
58
path
stringlengths
12
218
func_name
stringlengths
3
140
original_string
stringlengths
73
34.1k
language
stringclasses
1 value
code
stringlengths
73
34.1k
code_tokens
list
docstring
stringlengths
3
16k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
105
339
26,900
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.init
void init(OmemoManager.LoggedInOmemoManager managerGuard) throws InterruptedException, CorruptedOmemoKeyException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, PubSubException.NotALeafNodeException { OmemoManager manager = managerGuard.get(); OmemoDevice userDevice = manager.getOwnDevice(); // Create new keys if necessary and publish to the server. getOmemoStoreBackend().replenishKeys(userDevice); // Rotate signed preKey if necessary. if (shouldRotateSignedPreKey(userDevice)) { getOmemoStoreBackend().changeSignedPreKey(userDevice); } // Pack and publish bundle OmemoBundleElement bundle = getOmemoStoreBackend().packOmemoBundle(userDevice); publishBundle(manager.getConnection(), userDevice, bundle); // Fetch device list and republish deviceId if necessary refreshAndRepublishDeviceList(manager.getConnection(), userDevice); }
java
void init(OmemoManager.LoggedInOmemoManager managerGuard) throws InterruptedException, CorruptedOmemoKeyException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException, PubSubException.NotALeafNodeException { OmemoManager manager = managerGuard.get(); OmemoDevice userDevice = manager.getOwnDevice(); // Create new keys if necessary and publish to the server. getOmemoStoreBackend().replenishKeys(userDevice); // Rotate signed preKey if necessary. if (shouldRotateSignedPreKey(userDevice)) { getOmemoStoreBackend().changeSignedPreKey(userDevice); } // Pack and publish bundle OmemoBundleElement bundle = getOmemoStoreBackend().packOmemoBundle(userDevice); publishBundle(manager.getConnection(), userDevice, bundle); // Fetch device list and republish deviceId if necessary refreshAndRepublishDeviceList(manager.getConnection(), userDevice); }
[ "void", "init", "(", "OmemoManager", ".", "LoggedInOmemoManager", "managerGuard", ")", "throws", "InterruptedException", ",", "CorruptedOmemoKeyException", ",", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ".", "NotConnectedException", ",", "SmackException", ".", "NoResponseException", ",", "PubSubException", ".", "NotALeafNodeException", "{", "OmemoManager", "manager", "=", "managerGuard", ".", "get", "(", ")", ";", "OmemoDevice", "userDevice", "=", "manager", ".", "getOwnDevice", "(", ")", ";", "// Create new keys if necessary and publish to the server.", "getOmemoStoreBackend", "(", ")", ".", "replenishKeys", "(", "userDevice", ")", ";", "// Rotate signed preKey if necessary.", "if", "(", "shouldRotateSignedPreKey", "(", "userDevice", ")", ")", "{", "getOmemoStoreBackend", "(", ")", ".", "changeSignedPreKey", "(", "userDevice", ")", ";", "}", "// Pack and publish bundle", "OmemoBundleElement", "bundle", "=", "getOmemoStoreBackend", "(", ")", ".", "packOmemoBundle", "(", "userDevice", ")", ";", "publishBundle", "(", "manager", ".", "getConnection", "(", ")", ",", "userDevice", ",", "bundle", ")", ";", "// Fetch device list and republish deviceId if necessary", "refreshAndRepublishDeviceList", "(", "manager", ".", "getConnection", "(", ")", ",", "userDevice", ")", ";", "}" ]
Initialize OMEMO functionality for OmemoManager omemoManager. @param managerGuard OmemoManager we'd like to initialize. @throws InterruptedException @throws CorruptedOmemoKeyException @throws XMPPException.XMPPErrorException @throws SmackException.NotConnectedException @throws SmackException.NoResponseException @throws PubSubException.NotALeafNodeException
[ "Initialize", "OMEMO", "functionality", "for", "OmemoManager", "omemoManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L244-L266
26,901
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.createRatchetUpdateElement
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"); } // Establish session if necessary if (!hasSession(userDevice, contactsDevice)) { buildFreshSessionWithDevice(manager.getConnection(), userDevice, contactsDevice); } // Generate fresh AES key and IV byte[] messageKey = OmemoMessageBuilder.generateKey(KEYTYPE, KEYLENGTH); byte[] iv = OmemoMessageBuilder.generateIv(); // Create message builder 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); } // Add recipient 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); } // Note: We don't need to update our message counter for a ratchet update message. return builder.finish(); }
java
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"); } // Establish session if necessary if (!hasSession(userDevice, contactsDevice)) { buildFreshSessionWithDevice(manager.getConnection(), userDevice, contactsDevice); } // Generate fresh AES key and IV byte[] messageKey = OmemoMessageBuilder.generateKey(KEYTYPE, KEYLENGTH); byte[] iv = OmemoMessageBuilder.generateIv(); // Create message builder 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); } // Add recipient 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); } // Note: We don't need to update our message counter for a ratchet update message. return builder.finish(); }
[ "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\"", ")", ";", "}", "// Establish session if necessary", "if", "(", "!", "hasSession", "(", "userDevice", ",", "contactsDevice", ")", ")", "{", "buildFreshSessionWithDevice", "(", "manager", ".", "getConnection", "(", ")", ",", "userDevice", ",", "contactsDevice", ")", ";", "}", "// Generate fresh AES key and IV", "byte", "[", "]", "messageKey", "=", "OmemoMessageBuilder", ".", "generateKey", "(", "KEYTYPE", ",", "KEYLENGTH", ")", ";", "byte", "[", "]", "iv", "=", "OmemoMessageBuilder", ".", "generateIv", "(", ")", ";", "// Create message builder", "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", ")", ";", "}", "// Add recipient", "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", ")", ";", "}", "// Note: We don't need to update our message counter for a ratchet update message.", "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. @param managerGuard Logged in OmemoManager @param contactsDevice OmemoDevice of the contact @return ratchet update message @throws NoSuchAlgorithmException if AES algorithms are not supported on this system. @throws InterruptedException @throws SmackException.NoResponseException @throws CorruptedOmemoKeyException if our IdentityKeyPair is corrupted. @throws SmackException.NotConnectedException @throws CannotEstablishOmemoSessionException if session negotiation fails.
[ "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", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L283-L327
26,902
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.createOmemoMessage
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); }
java
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); }
[ "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. @param managerGuard initialized OmemoManager @param contactsDevices set of recipient devices @param message message we want to send @return encrypted OmemoMessage @throws InterruptedException @throws UndecidedOmemoIdentityException if the list of recipient devices contains an undecided device. @throws CryptoFailedException if we are lacking some cryptographic algorithms @throws SmackException.NotConnectedException @throws SmackException.NoResponseException
[ "Create", "an", "OmemoMessage", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L521-L537
26,903
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.fetchBundle
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(); }
java
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(); }
[ "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. @param connection authenticated XMPP connection. @param contactsDevice device of which we want to retrieve the bundle. @return OmemoBundle of the device or null, if it doesn't exist. @throws SmackException.NotConnectedException @throws InterruptedException @throws SmackException.NoResponseException @throws XMPPException.XMPPErrorException @throws PubSubException.NotALeafNodeException @throws PubSubException.NotAPubSubNodeException
[ "Retrieve", "a", "users", "OMEMO", "bundle", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L553-L572
26,904
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.publishBundle
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)); }
java
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)); }
[ "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. @param connection our connection. @param userDevice our device @param bundle the bundle we want to publish @throws XMPPException.XMPPErrorException @throws SmackException.NotConnectedException @throws InterruptedException @throws SmackException.NoResponseException
[ "Publish", "the", "given", "OMEMO", "bundle", "to", "the", "server", "using", "PubSub", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L584-L589
26,905
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.fetchDeviceList
private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException { PubSubManager pm = PubSubManager.getInstanceFor(connection, contact); String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST; LeafNode node = pm.getLeafNode(nodeName); if (node == null) { return null; } List<PayloadItem<OmemoDeviceListElement>> items = node.getItems(); if (items.isEmpty()) { return null; } return items.get(items.size() - 1).getPayload(); }
java
private static OmemoDeviceListElement fetchDeviceList(XMPPConnection connection, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException, PubSubException.NotAPubSubNodeException { PubSubManager pm = PubSubManager.getInstanceFor(connection, contact); String nodeName = OmemoConstants.PEP_NODE_DEVICE_LIST; LeafNode node = pm.getLeafNode(nodeName); if (node == null) { return null; } List<PayloadItem<OmemoDeviceListElement>> items = node.getItems(); if (items.isEmpty()) { return null; } return items.get(items.size() - 1).getPayload(); }
[ "private", "static", "OmemoDeviceListElement", "fetchDeviceList", "(", "XMPPConnection", "connection", ",", "BareJid", "contact", ")", "throws", "InterruptedException", ",", "PubSubException", ".", "NotALeafNodeException", ",", "SmackException", ".", "NoResponseException", ",", "SmackException", ".", "NotConnectedException", ",", "XMPPException", ".", "XMPPErrorException", ",", "PubSubException", ".", "NotAPubSubNodeException", "{", "PubSubManager", "pm", "=", "PubSubManager", ".", "getInstanceFor", "(", "connection", ",", "contact", ")", ";", "String", "nodeName", "=", "OmemoConstants", ".", "PEP_NODE_DEVICE_LIST", ";", "LeafNode", "node", "=", "pm", ".", "getLeafNode", "(", "nodeName", ")", ";", "if", "(", "node", "==", "null", ")", "{", "return", "null", ";", "}", "List", "<", "PayloadItem", "<", "OmemoDeviceListElement", ">", ">", "items", "=", "node", ".", "getItems", "(", ")", ";", "if", "(", "items", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "return", "items", ".", "get", "(", "items", ".", "size", "(", ")", "-", "1", ")", ".", "getPayload", "(", ")", ";", "}" ]
Retrieve the OMEMO device list of a contact. @param connection authenticated XMPP connection. @param contact BareJid of the contact of which we want to retrieve the device list from. @return @throws InterruptedException @throws PubSubException.NotALeafNodeException @throws SmackException.NoResponseException @throws SmackException.NotConnectedException @throws XMPPException.XMPPErrorException @throws PubSubException.NotAPubSubNodeException
[ "Retrieve", "the", "OMEMO", "device", "list", "of", "a", "contact", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L604-L623
26,906
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.publishDeviceList
static void publishDeviceList(XMPPConnection connection, OmemoDeviceListElement deviceList) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { PubSubManager.getInstanceFor(connection, connection.getUser().asBareJid()) .tryToPublishAndPossibleAutoCreate(OmemoConstants.PEP_NODE_DEVICE_LIST, new PayloadItem<>(deviceList)); }
java
static void publishDeviceList(XMPPConnection connection, OmemoDeviceListElement deviceList) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { PubSubManager.getInstanceFor(connection, connection.getUser().asBareJid()) .tryToPublishAndPossibleAutoCreate(OmemoConstants.PEP_NODE_DEVICE_LIST, new PayloadItem<>(deviceList)); }
[ "static", "void", "publishDeviceList", "(", "XMPPConnection", "connection", ",", "OmemoDeviceListElement", "deviceList", ")", "throws", "InterruptedException", ",", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ".", "NotConnectedException", ",", "SmackException", ".", "NoResponseException", "{", "PubSubManager", ".", "getInstanceFor", "(", "connection", ",", "connection", ".", "getUser", "(", ")", ".", "asBareJid", "(", ")", ")", ".", "tryToPublishAndPossibleAutoCreate", "(", "OmemoConstants", ".", "PEP_NODE_DEVICE_LIST", ",", "new", "PayloadItem", "<>", "(", "deviceList", ")", ")", ";", "}" ]
Publish the given device list to the server. @param connection authenticated XMPP connection. @param deviceList users deviceList. @throws InterruptedException @throws XMPPException.XMPPErrorException @throws SmackException.NotConnectedException @throws SmackException.NoResponseException @throws PubSubException.NotALeafNodeException
[ "Publish", "the", "given", "device", "list", "to", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L635-L641
26,907
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.cleanUpDeviceList
OmemoCachedDeviceList cleanUpDeviceList(OmemoDevice userDevice) { OmemoCachedDeviceList cachedDeviceList; // Delete stale devices if allowed and necessary if (OmemoConfiguration.getDeleteStaleDevices()) { cachedDeviceList = deleteStaleDevices(userDevice); } else { cachedDeviceList = getOmemoStoreBackend().loadCachedDeviceList(userDevice); } // Add back our device if necessary if (!cachedDeviceList.getActiveDevices().contains(userDevice.getDeviceId())) { cachedDeviceList.addDevice(userDevice.getDeviceId()); } getOmemoStoreBackend().storeCachedDeviceList(userDevice, userDevice.getJid(), cachedDeviceList); return cachedDeviceList; }
java
OmemoCachedDeviceList cleanUpDeviceList(OmemoDevice userDevice) { OmemoCachedDeviceList cachedDeviceList; // Delete stale devices if allowed and necessary if (OmemoConfiguration.getDeleteStaleDevices()) { cachedDeviceList = deleteStaleDevices(userDevice); } else { cachedDeviceList = getOmemoStoreBackend().loadCachedDeviceList(userDevice); } // Add back our device if necessary if (!cachedDeviceList.getActiveDevices().contains(userDevice.getDeviceId())) { cachedDeviceList.addDevice(userDevice.getDeviceId()); } getOmemoStoreBackend().storeCachedDeviceList(userDevice, userDevice.getJid(), cachedDeviceList); return cachedDeviceList; }
[ "OmemoCachedDeviceList", "cleanUpDeviceList", "(", "OmemoDevice", "userDevice", ")", "{", "OmemoCachedDeviceList", "cachedDeviceList", ";", "// Delete stale devices if allowed and necessary", "if", "(", "OmemoConfiguration", ".", "getDeleteStaleDevices", "(", ")", ")", "{", "cachedDeviceList", "=", "deleteStaleDevices", "(", "userDevice", ")", ";", "}", "else", "{", "cachedDeviceList", "=", "getOmemoStoreBackend", "(", ")", ".", "loadCachedDeviceList", "(", "userDevice", ")", ";", "}", "// Add back our device if necessary", "if", "(", "!", "cachedDeviceList", ".", "getActiveDevices", "(", ")", ".", "contains", "(", "userDevice", ".", "getDeviceId", "(", ")", ")", ")", "{", "cachedDeviceList", ".", "addDevice", "(", "userDevice", ".", "getDeviceId", "(", ")", ")", ";", "}", "getOmemoStoreBackend", "(", ")", ".", "storeCachedDeviceList", "(", "userDevice", ",", "userDevice", ".", "getJid", "(", ")", ",", "cachedDeviceList", ")", ";", "return", "cachedDeviceList", ";", "}" ]
Add our load the deviceList of the user from cache, delete stale devices if needed, add the users device back if necessary, store the refurbished list in cache and return it. @param userDevice @return
[ "Add", "our", "load", "the", "deviceList", "of", "the", "user", "from", "cache", "delete", "stale", "devices", "if", "needed", "add", "the", "users", "device", "back", "if", "necessary", "store", "the", "refurbished", "list", "in", "cache", "and", "return", "it", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L695-L713
26,908
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.refreshDeviceList
OmemoCachedDeviceList refreshDeviceList(XMPPConnection connection, OmemoDevice userDevice, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { // refreshOmemoDeviceList; OmemoDeviceListElement publishedList; try { publishedList = fetchDeviceList(connection, contact); } catch (PubSubException.NotAPubSubNodeException e) { LOGGER.log(Level.WARNING, "Error refreshing deviceList: ", e); publishedList = null; } if (publishedList == null) { publishedList = new OmemoDeviceListElement_VAxolotl(Collections.<Integer>emptySet()); } return getOmemoStoreBackend().mergeCachedDeviceList( userDevice, contact, publishedList); }
java
OmemoCachedDeviceList refreshDeviceList(XMPPConnection connection, OmemoDevice userDevice, BareJid contact) throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { // refreshOmemoDeviceList; OmemoDeviceListElement publishedList; try { publishedList = fetchDeviceList(connection, contact); } catch (PubSubException.NotAPubSubNodeException e) { LOGGER.log(Level.WARNING, "Error refreshing deviceList: ", e); publishedList = null; } if (publishedList == null) { publishedList = new OmemoDeviceListElement_VAxolotl(Collections.<Integer>emptySet()); } return getOmemoStoreBackend().mergeCachedDeviceList( userDevice, contact, publishedList); }
[ "OmemoCachedDeviceList", "refreshDeviceList", "(", "XMPPConnection", "connection", ",", "OmemoDevice", "userDevice", ",", "BareJid", "contact", ")", "throws", "InterruptedException", ",", "PubSubException", ".", "NotALeafNodeException", ",", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ".", "NotConnectedException", ",", "SmackException", ".", "NoResponseException", "{", "// refreshOmemoDeviceList;", "OmemoDeviceListElement", "publishedList", ";", "try", "{", "publishedList", "=", "fetchDeviceList", "(", "connection", ",", "contact", ")", ";", "}", "catch", "(", "PubSubException", ".", "NotAPubSubNodeException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Error refreshing deviceList: \"", ",", "e", ")", ";", "publishedList", "=", "null", ";", "}", "if", "(", "publishedList", "==", "null", ")", "{", "publishedList", "=", "new", "OmemoDeviceListElement_VAxolotl", "(", "Collections", ".", "<", "Integer", ">", "emptySet", "(", ")", ")", ";", "}", "return", "getOmemoStoreBackend", "(", ")", ".", "mergeCachedDeviceList", "(", "userDevice", ",", "contact", ",", "publishedList", ")", ";", "}" ]
Refresh and merge device list of contact. @param connection authenticated XMPP connection @param userDevice our OmemoDevice @param contact contact we want to fetch the deviceList from @return cached device list after refresh. @throws InterruptedException @throws PubSubException.NotALeafNodeException @throws XMPPException.XMPPErrorException @throws SmackException.NotConnectedException @throws SmackException.NoResponseException
[ "Refresh", "and", "merge", "device", "list", "of", "contact", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L729-L746
26,909
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.buildFreshSessionWithDevice
void buildFreshSessionWithDevice(XMPPConnection connection, OmemoDevice userDevice, OmemoDevice contactsDevice) throws CannotEstablishOmemoSessionException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException { if (contactsDevice.equals(userDevice)) { // Do not build a session with yourself. return; } OmemoBundleElement bundleElement; try { bundleElement = fetchBundle(connection, contactsDevice); } catch (XMPPException.XMPPErrorException | PubSubException.NotALeafNodeException | PubSubException.NotAPubSubNodeException e) { throw new CannotEstablishOmemoSessionException(contactsDevice, e); } // Select random Bundle HashMap<Integer, T_Bundle> bundlesList = getOmemoStoreBackend().keyUtil().BUNDLE.bundles(bundleElement, contactsDevice); int randomIndex = new Random().nextInt(bundlesList.size()); T_Bundle randomPreKeyBundle = new ArrayList<>(bundlesList.values()).get(randomIndex); // build the session OmemoManager omemoManager = OmemoManager.getInstanceFor(connection, userDevice.getDeviceId()); processBundle(omemoManager, randomPreKeyBundle, contactsDevice); }
java
void buildFreshSessionWithDevice(XMPPConnection connection, OmemoDevice userDevice, OmemoDevice contactsDevice) throws CannotEstablishOmemoSessionException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException { if (contactsDevice.equals(userDevice)) { // Do not build a session with yourself. return; } OmemoBundleElement bundleElement; try { bundleElement = fetchBundle(connection, contactsDevice); } catch (XMPPException.XMPPErrorException | PubSubException.NotALeafNodeException | PubSubException.NotAPubSubNodeException e) { throw new CannotEstablishOmemoSessionException(contactsDevice, e); } // Select random Bundle HashMap<Integer, T_Bundle> bundlesList = getOmemoStoreBackend().keyUtil().BUNDLE.bundles(bundleElement, contactsDevice); int randomIndex = new Random().nextInt(bundlesList.size()); T_Bundle randomPreKeyBundle = new ArrayList<>(bundlesList.values()).get(randomIndex); // build the session OmemoManager omemoManager = OmemoManager.getInstanceFor(connection, userDevice.getDeviceId()); processBundle(omemoManager, randomPreKeyBundle, contactsDevice); }
[ "void", "buildFreshSessionWithDevice", "(", "XMPPConnection", "connection", ",", "OmemoDevice", "userDevice", ",", "OmemoDevice", "contactsDevice", ")", "throws", "CannotEstablishOmemoSessionException", ",", "SmackException", ".", "NotConnectedException", ",", "InterruptedException", ",", "SmackException", ".", "NoResponseException", ",", "CorruptedOmemoKeyException", "{", "if", "(", "contactsDevice", ".", "equals", "(", "userDevice", ")", ")", "{", "// Do not build a session with yourself.", "return", ";", "}", "OmemoBundleElement", "bundleElement", ";", "try", "{", "bundleElement", "=", "fetchBundle", "(", "connection", ",", "contactsDevice", ")", ";", "}", "catch", "(", "XMPPException", ".", "XMPPErrorException", "|", "PubSubException", ".", "NotALeafNodeException", "|", "PubSubException", ".", "NotAPubSubNodeException", "e", ")", "{", "throw", "new", "CannotEstablishOmemoSessionException", "(", "contactsDevice", ",", "e", ")", ";", "}", "// Select random Bundle", "HashMap", "<", "Integer", ",", "T_Bundle", ">", "bundlesList", "=", "getOmemoStoreBackend", "(", ")", ".", "keyUtil", "(", ")", ".", "BUNDLE", ".", "bundles", "(", "bundleElement", ",", "contactsDevice", ")", ";", "int", "randomIndex", "=", "new", "Random", "(", ")", ".", "nextInt", "(", "bundlesList", ".", "size", "(", ")", ")", ";", "T_Bundle", "randomPreKeyBundle", "=", "new", "ArrayList", "<>", "(", "bundlesList", ".", "values", "(", ")", ")", ".", "get", "(", "randomIndex", ")", ";", "// build the session", "OmemoManager", "omemoManager", "=", "OmemoManager", ".", "getInstanceFor", "(", "connection", ",", "userDevice", ".", "getDeviceId", "(", ")", ")", ";", "processBundle", "(", "omemoManager", ",", "randomPreKeyBundle", ",", "contactsDevice", ")", ";", "}" ]
Fetch the bundle of a contact and build a fresh OMEMO session with the contacts device. Note that this builds a fresh session, regardless if we have had a session before or not. @param connection authenticated XMPP connection @param userDevice our OmemoDevice @param contactsDevice OmemoDevice of a contact. @throws CannotEstablishOmemoSessionException if we cannot establish a session (because of missing bundle etc.) @throws SmackException.NotConnectedException @throws InterruptedException @throws SmackException.NoResponseException @throws CorruptedOmemoKeyException if our IdentityKeyPair is corrupted.
[ "Fetch", "the", "bundle", "of", "a", "contact", "and", "build", "a", "fresh", "OMEMO", "session", "with", "the", "contacts", "device", ".", "Note", "that", "this", "builds", "a", "fresh", "session", "regardless", "if", "we", "have", "had", "a", "session", "before", "or", "not", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L761-L786
26,910
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.getUndecidedDevices
private Set<OmemoDevice> getUndecidedDevices(OmemoDevice userDevice, OmemoTrustCallback callback, Set<OmemoDevice> devices) { Set<OmemoDevice> undecidedDevices = new HashSet<>(); for (OmemoDevice device : devices) { OmemoFingerprint fingerprint; try { fingerprint = getOmemoStoreBackend().getFingerprint(userDevice, device); } catch (CorruptedOmemoKeyException | NoIdentityKeyException e) { // TODO: Best solution? LOGGER.log(Level.WARNING, "Could not load fingerprint of " + device, e); undecidedDevices.add(device); continue; } if (callback.getTrust(device, fingerprint) == TrustState.undecided) { undecidedDevices.add(device); } } return undecidedDevices; }
java
private Set<OmemoDevice> getUndecidedDevices(OmemoDevice userDevice, OmemoTrustCallback callback, Set<OmemoDevice> devices) { Set<OmemoDevice> undecidedDevices = new HashSet<>(); for (OmemoDevice device : devices) { OmemoFingerprint fingerprint; try { fingerprint = getOmemoStoreBackend().getFingerprint(userDevice, device); } catch (CorruptedOmemoKeyException | NoIdentityKeyException e) { // TODO: Best solution? LOGGER.log(Level.WARNING, "Could not load fingerprint of " + device, e); undecidedDevices.add(device); continue; } if (callback.getTrust(device, fingerprint) == TrustState.undecided) { undecidedDevices.add(device); } } return undecidedDevices; }
[ "private", "Set", "<", "OmemoDevice", ">", "getUndecidedDevices", "(", "OmemoDevice", "userDevice", ",", "OmemoTrustCallback", "callback", ",", "Set", "<", "OmemoDevice", ">", "devices", ")", "{", "Set", "<", "OmemoDevice", ">", "undecidedDevices", "=", "new", "HashSet", "<>", "(", ")", ";", "for", "(", "OmemoDevice", "device", ":", "devices", ")", "{", "OmemoFingerprint", "fingerprint", ";", "try", "{", "fingerprint", "=", "getOmemoStoreBackend", "(", ")", ".", "getFingerprint", "(", "userDevice", ",", "device", ")", ";", "}", "catch", "(", "CorruptedOmemoKeyException", "|", "NoIdentityKeyException", "e", ")", "{", "// TODO: Best solution?", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Could not load fingerprint of \"", "+", "device", ",", "e", ")", ";", "undecidedDevices", ".", "add", "(", "device", ")", ";", "continue", ";", "}", "if", "(", "callback", ".", "getTrust", "(", "device", ",", "fingerprint", ")", "==", "TrustState", ".", "undecided", ")", "{", "undecidedDevices", ".", "add", "(", "device", ")", ";", "}", "}", "return", "undecidedDevices", ";", "}" ]
Return a set of all devices from the provided set, which trust level is undecided. A device is also considered undecided, if its fingerprint cannot be loaded. @param userDevice our OmemoDevice @param callback OmemoTrustCallback to query the trust decisions from @param devices set of OmemoDevices @return set of OmemoDevices which contains all devices from the set devices, which are undecided
[ "Return", "a", "set", "of", "all", "devices", "from", "the", "provided", "set", "which", "trust", "level", "is", "undecided", ".", "A", "device", "is", "also", "considered", "undecided", "if", "its", "fingerprint", "cannot", "be", "loaded", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L838-L859
26,911
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.hasSession
private boolean hasSession(OmemoDevice userDevice, OmemoDevice contactsDevice) { return getOmemoStoreBackend().loadRawSession(userDevice, contactsDevice) != null; }
java
private boolean hasSession(OmemoDevice userDevice, OmemoDevice contactsDevice) { return getOmemoStoreBackend().loadRawSession(userDevice, contactsDevice) != null; }
[ "private", "boolean", "hasSession", "(", "OmemoDevice", "userDevice", ",", "OmemoDevice", "contactsDevice", ")", "{", "return", "getOmemoStoreBackend", "(", ")", ".", "loadRawSession", "(", "userDevice", ",", "contactsDevice", ")", "!=", "null", ";", "}" ]
Return true, if the OmemoManager of userDevice has a session with the contactsDevice. @param userDevice our OmemoDevice. @param contactsDevice OmemoDevice of the contact. @return true if userDevice has session with contactsDevice.
[ "Return", "true", "if", "the", "OmemoManager", "of", "userDevice", "has", "a", "session", "with", "the", "contactsDevice", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L868-L870
26,912
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.shouldRotateSignedPreKey
private boolean shouldRotateSignedPreKey(OmemoDevice userDevice) { if (!OmemoConfiguration.getRenewOldSignedPreKeys()) { return false; } Date now = new Date(); Date lastRenewal = getOmemoStoreBackend().getDateOfLastSignedPreKeyRenewal(userDevice); if (lastRenewal == null) { lastRenewal = new Date(); getOmemoStoreBackend().setDateOfLastSignedPreKeyRenewal(userDevice, lastRenewal); } long allowedAgeMillis = MILLIS_PER_HOUR * OmemoConfiguration.getRenewOldSignedPreKeysAfterHours(); return now.getTime() - lastRenewal.getTime() > allowedAgeMillis; }
java
private boolean shouldRotateSignedPreKey(OmemoDevice userDevice) { if (!OmemoConfiguration.getRenewOldSignedPreKeys()) { return false; } Date now = new Date(); Date lastRenewal = getOmemoStoreBackend().getDateOfLastSignedPreKeyRenewal(userDevice); if (lastRenewal == null) { lastRenewal = new Date(); getOmemoStoreBackend().setDateOfLastSignedPreKeyRenewal(userDevice, lastRenewal); } long allowedAgeMillis = MILLIS_PER_HOUR * OmemoConfiguration.getRenewOldSignedPreKeysAfterHours(); return now.getTime() - lastRenewal.getTime() > allowedAgeMillis; }
[ "private", "boolean", "shouldRotateSignedPreKey", "(", "OmemoDevice", "userDevice", ")", "{", "if", "(", "!", "OmemoConfiguration", ".", "getRenewOldSignedPreKeys", "(", ")", ")", "{", "return", "false", ";", "}", "Date", "now", "=", "new", "Date", "(", ")", ";", "Date", "lastRenewal", "=", "getOmemoStoreBackend", "(", ")", ".", "getDateOfLastSignedPreKeyRenewal", "(", "userDevice", ")", ";", "if", "(", "lastRenewal", "==", "null", ")", "{", "lastRenewal", "=", "new", "Date", "(", ")", ";", "getOmemoStoreBackend", "(", ")", ".", "setDateOfLastSignedPreKeyRenewal", "(", "userDevice", ",", "lastRenewal", ")", ";", "}", "long", "allowedAgeMillis", "=", "MILLIS_PER_HOUR", "*", "OmemoConfiguration", ".", "getRenewOldSignedPreKeysAfterHours", "(", ")", ";", "return", "now", ".", "getTime", "(", ")", "-", "lastRenewal", ".", "getTime", "(", ")", ">", "allowedAgeMillis", ";", "}" ]
Returns true, if a rotation of the signed preKey is necessary. @param userDevice our OmemoDevice @return true if rotation is necessary
[ "Returns", "true", "if", "a", "rotation", "of", "the", "signed", "preKey", "is", "necessary", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L891-L906
26,913
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.removeStaleDevicesFromDeviceList
private OmemoCachedDeviceList removeStaleDevicesFromDeviceList(OmemoDevice userDevice, BareJid contact, OmemoCachedDeviceList contactsDeviceList, int maxAgeHours) { OmemoCachedDeviceList deviceList = new OmemoCachedDeviceList(contactsDeviceList); // Don't work on original list. // Iterate through original list, but modify copy instead for (int deviceId : contactsDeviceList.getActiveDevices()) { OmemoDevice device = new OmemoDevice(contact, deviceId); Date lastDeviceIdPublication = getOmemoStoreBackend().getDateOfLastDeviceIdPublication(userDevice, device); if (lastDeviceIdPublication == null) { lastDeviceIdPublication = new Date(); getOmemoStoreBackend().setDateOfLastDeviceIdPublication(userDevice, device, lastDeviceIdPublication); } Date lastMessageReceived = getOmemoStoreBackend().getDateOfLastReceivedMessage(userDevice, device); if (lastMessageReceived == null) { lastMessageReceived = new Date(); getOmemoStoreBackend().setDateOfLastReceivedMessage(userDevice, device, lastMessageReceived); } boolean stale = isStale(userDevice, device, lastDeviceIdPublication, maxAgeHours); stale &= isStale(userDevice, device, lastMessageReceived, maxAgeHours); if (stale) { deviceList.addInactiveDevice(deviceId); } } return deviceList; }
java
private OmemoCachedDeviceList removeStaleDevicesFromDeviceList(OmemoDevice userDevice, BareJid contact, OmemoCachedDeviceList contactsDeviceList, int maxAgeHours) { OmemoCachedDeviceList deviceList = new OmemoCachedDeviceList(contactsDeviceList); // Don't work on original list. // Iterate through original list, but modify copy instead for (int deviceId : contactsDeviceList.getActiveDevices()) { OmemoDevice device = new OmemoDevice(contact, deviceId); Date lastDeviceIdPublication = getOmemoStoreBackend().getDateOfLastDeviceIdPublication(userDevice, device); if (lastDeviceIdPublication == null) { lastDeviceIdPublication = new Date(); getOmemoStoreBackend().setDateOfLastDeviceIdPublication(userDevice, device, lastDeviceIdPublication); } Date lastMessageReceived = getOmemoStoreBackend().getDateOfLastReceivedMessage(userDevice, device); if (lastMessageReceived == null) { lastMessageReceived = new Date(); getOmemoStoreBackend().setDateOfLastReceivedMessage(userDevice, device, lastMessageReceived); } boolean stale = isStale(userDevice, device, lastDeviceIdPublication, maxAgeHours); stale &= isStale(userDevice, device, lastMessageReceived, maxAgeHours); if (stale) { deviceList.addInactiveDevice(deviceId); } } return deviceList; }
[ "private", "OmemoCachedDeviceList", "removeStaleDevicesFromDeviceList", "(", "OmemoDevice", "userDevice", ",", "BareJid", "contact", ",", "OmemoCachedDeviceList", "contactsDeviceList", ",", "int", "maxAgeHours", ")", "{", "OmemoCachedDeviceList", "deviceList", "=", "new", "OmemoCachedDeviceList", "(", "contactsDeviceList", ")", ";", "// Don't work on original list.", "// Iterate through original list, but modify copy instead", "for", "(", "int", "deviceId", ":", "contactsDeviceList", ".", "getActiveDevices", "(", ")", ")", "{", "OmemoDevice", "device", "=", "new", "OmemoDevice", "(", "contact", ",", "deviceId", ")", ";", "Date", "lastDeviceIdPublication", "=", "getOmemoStoreBackend", "(", ")", ".", "getDateOfLastDeviceIdPublication", "(", "userDevice", ",", "device", ")", ";", "if", "(", "lastDeviceIdPublication", "==", "null", ")", "{", "lastDeviceIdPublication", "=", "new", "Date", "(", ")", ";", "getOmemoStoreBackend", "(", ")", ".", "setDateOfLastDeviceIdPublication", "(", "userDevice", ",", "device", ",", "lastDeviceIdPublication", ")", ";", "}", "Date", "lastMessageReceived", "=", "getOmemoStoreBackend", "(", ")", ".", "getDateOfLastReceivedMessage", "(", "userDevice", ",", "device", ")", ";", "if", "(", "lastMessageReceived", "==", "null", ")", "{", "lastMessageReceived", "=", "new", "Date", "(", ")", ";", "getOmemoStoreBackend", "(", ")", ".", "setDateOfLastReceivedMessage", "(", "userDevice", ",", "device", ",", "lastMessageReceived", ")", ";", "}", "boolean", "stale", "=", "isStale", "(", "userDevice", ",", "device", ",", "lastDeviceIdPublication", ",", "maxAgeHours", ")", ";", "stale", "&=", "isStale", "(", "userDevice", ",", "device", ",", "lastMessageReceived", ",", "maxAgeHours", ")", ";", "if", "(", "stale", ")", "{", "deviceList", ".", "addInactiveDevice", "(", "deviceId", ")", ";", "}", "}", "return", "deviceList", ";", "}" ]
Return a copy of the given deviceList of user contact, but with stale devices marked as inactive. Never mark our own device as stale. If we haven't yet received a message from a device, store the current date as last date of message receipt to allow future decisions. A stale device is a device, from which we haven't received an OMEMO message from for more than "maxAgeMillis" milliseconds. @param userDevice our OmemoDevice. @param contact subjects BareJid. @param contactsDeviceList subjects deviceList. @return copy of subjects deviceList with stale devices marked as inactive.
[ "Return", "a", "copy", "of", "the", "given", "deviceList", "of", "user", "contact", "but", "with", "stale", "devices", "marked", "as", "inactive", ".", "Never", "mark", "our", "own", "device", "as", "stale", ".", "If", "we", "haven", "t", "yet", "received", "a", "message", "from", "a", "device", "store", "the", "current", "date", "as", "last", "date", "of", "message", "receipt", "to", "allow", "future", "decisions", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L938-L968
26,914
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.removeOurDevice
static void removeOurDevice(OmemoDevice userDevice, Collection<OmemoDevice> devices) { if (devices.contains(userDevice)) { devices.remove(userDevice); } }
java
static void removeOurDevice(OmemoDevice userDevice, Collection<OmemoDevice> devices) { if (devices.contains(userDevice)) { devices.remove(userDevice); } }
[ "static", "void", "removeOurDevice", "(", "OmemoDevice", "userDevice", ",", "Collection", "<", "OmemoDevice", ">", "devices", ")", "{", "if", "(", "devices", ".", "contains", "(", "userDevice", ")", ")", "{", "devices", ".", "remove", "(", "userDevice", ")", ";", "}", "}" ]
Remove our device from the collection of devices. @param userDevice our OmemoDevice @param devices collection of OmemoDevices
[ "Remove", "our", "device", "from", "the", "collection", "of", "devices", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L977-L981
26,915
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.repairBrokenSessionWithPreKeyMessage
private void repairBrokenSessionWithPreKeyMessage(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice brokenDevice) { LOGGER.log(Level.WARNING, "Attempt to repair the session by sending a fresh preKey message to " + brokenDevice); OmemoManager manager = managerGuard.get(); try { // Create fresh session and send new preKeyMessage. buildFreshSessionWithDevice(manager.getConnection(), manager.getOwnDevice(), brokenDevice); sendRatchetUpdate(managerGuard, brokenDevice); } catch (CannotEstablishOmemoSessionException | CorruptedOmemoKeyException e) { LOGGER.log(Level.WARNING, "Unable to repair session with " + brokenDevice, e); } catch (SmackException.NotConnectedException | InterruptedException | SmackException.NoResponseException e) { LOGGER.log(Level.WARNING, "Could not fetch fresh bundle for " + brokenDevice, e); } catch (CryptoFailedException | NoSuchAlgorithmException e) { LOGGER.log(Level.WARNING, "Could not create PreKeyMessage", e); } }
java
private void repairBrokenSessionWithPreKeyMessage(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice brokenDevice) { LOGGER.log(Level.WARNING, "Attempt to repair the session by sending a fresh preKey message to " + brokenDevice); OmemoManager manager = managerGuard.get(); try { // Create fresh session and send new preKeyMessage. buildFreshSessionWithDevice(manager.getConnection(), manager.getOwnDevice(), brokenDevice); sendRatchetUpdate(managerGuard, brokenDevice); } catch (CannotEstablishOmemoSessionException | CorruptedOmemoKeyException e) { LOGGER.log(Level.WARNING, "Unable to repair session with " + brokenDevice, e); } catch (SmackException.NotConnectedException | InterruptedException | SmackException.NoResponseException e) { LOGGER.log(Level.WARNING, "Could not fetch fresh bundle for " + brokenDevice, e); } catch (CryptoFailedException | NoSuchAlgorithmException e) { LOGGER.log(Level.WARNING, "Could not create PreKeyMessage", e); } }
[ "private", "void", "repairBrokenSessionWithPreKeyMessage", "(", "OmemoManager", ".", "LoggedInOmemoManager", "managerGuard", ",", "OmemoDevice", "brokenDevice", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Attempt to repair the session by sending a fresh preKey message to \"", "+", "brokenDevice", ")", ";", "OmemoManager", "manager", "=", "managerGuard", ".", "get", "(", ")", ";", "try", "{", "// Create fresh session and send new preKeyMessage.", "buildFreshSessionWithDevice", "(", "manager", ".", "getConnection", "(", ")", ",", "manager", ".", "getOwnDevice", "(", ")", ",", "brokenDevice", ")", ";", "sendRatchetUpdate", "(", "managerGuard", ",", "brokenDevice", ")", ";", "}", "catch", "(", "CannotEstablishOmemoSessionException", "|", "CorruptedOmemoKeyException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Unable to repair session with \"", "+", "brokenDevice", ",", "e", ")", ";", "}", "catch", "(", "SmackException", ".", "NotConnectedException", "|", "InterruptedException", "|", "SmackException", ".", "NoResponseException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Could not fetch fresh bundle for \"", "+", "brokenDevice", ",", "e", ")", ";", "}", "catch", "(", "CryptoFailedException", "|", "NoSuchAlgorithmException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Could not create PreKeyMessage\"", ",", "e", ")", ";", "}", "}" ]
Fetch and process a fresh bundle and send an empty preKeyMessage in order to establish a fresh session. @param managerGuard authenticated OmemoManager. @param brokenDevice device which session broke.
[ "Fetch", "and", "process", "a", "fresh", "bundle", "and", "send", "an", "empty", "preKeyMessage", "in", "order", "to", "establish", "a", "fresh", "session", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L1285-L1303
26,916
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.sendRatchetUpdate
private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice) throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException, CannotEstablishOmemoSessionException { OmemoManager manager = managerGuard.get(); OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice); Message m = new Message(); m.setTo(contactsDevice.getJid()); m.addExtension(ratchetUpdate); manager.getConnection().sendStanza(m); }
java
private void sendRatchetUpdate(OmemoManager.LoggedInOmemoManager managerGuard, OmemoDevice contactsDevice) throws CorruptedOmemoKeyException, InterruptedException, SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException, CryptoFailedException, CannotEstablishOmemoSessionException { OmemoManager manager = managerGuard.get(); OmemoElement ratchetUpdate = createRatchetUpdateElement(managerGuard, contactsDevice); Message m = new Message(); m.setTo(contactsDevice.getJid()); m.addExtension(ratchetUpdate); manager.getConnection().sendStanza(m); }
[ "private", "void", "sendRatchetUpdate", "(", "OmemoManager", ".", "LoggedInOmemoManager", "managerGuard", ",", "OmemoDevice", "contactsDevice", ")", "throws", "CorruptedOmemoKeyException", ",", "InterruptedException", ",", "SmackException", ".", "NoResponseException", ",", "NoSuchAlgorithmException", ",", "SmackException", ".", "NotConnectedException", ",", "CryptoFailedException", ",", "CannotEstablishOmemoSessionException", "{", "OmemoManager", "manager", "=", "managerGuard", ".", "get", "(", ")", ";", "OmemoElement", "ratchetUpdate", "=", "createRatchetUpdateElement", "(", "managerGuard", ",", "contactsDevice", ")", ";", "Message", "m", "=", "new", "Message", "(", ")", ";", "m", ".", "setTo", "(", "contactsDevice", ".", "getJid", "(", ")", ")", ";", "m", ".", "addExtension", "(", "ratchetUpdate", ")", ";", "manager", ".", "getConnection", "(", ")", ".", "sendStanza", "(", "m", ")", ";", "}" ]
Send an empty OMEMO message to contactsDevice in order to forward the ratchet. @param managerGuard @param contactsDevice @throws CorruptedOmemoKeyException if our or their OMEMO key is corrupted. @throws InterruptedException @throws SmackException.NoResponseException @throws NoSuchAlgorithmException if AES encryption fails @throws SmackException.NotConnectedException @throws CryptoFailedException if encryption fails (should not happen though, but who knows...) @throws CannotEstablishOmemoSessionException if we cannot establish a session with contactsDevice.
[ "Send", "an", "empty", "OMEMO", "message", "to", "contactsDevice", "in", "order", "to", "forward", "the", "ratchet", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L1317-L1328
26,917
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java
OmemoService.purgeDeviceList
public void purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { OmemoManager omemoManager = managerGuard.get(); OmemoDevice userDevice = omemoManager.getOwnDevice(); OmemoDeviceListElement_VAxolotl newList = new OmemoDeviceListElement_VAxolotl(Collections.singleton(userDevice.getDeviceId())); // Merge list getOmemoStoreBackend().mergeCachedDeviceList(userDevice, userDevice.getJid(), newList); OmemoService.publishDeviceList(omemoManager.getConnection(), newList); }
java
public void purgeDeviceList(OmemoManager.LoggedInOmemoManager managerGuard) throws InterruptedException, XMPPException.XMPPErrorException, SmackException.NotConnectedException, SmackException.NoResponseException { OmemoManager omemoManager = managerGuard.get(); OmemoDevice userDevice = omemoManager.getOwnDevice(); OmemoDeviceListElement_VAxolotl newList = new OmemoDeviceListElement_VAxolotl(Collections.singleton(userDevice.getDeviceId())); // Merge list getOmemoStoreBackend().mergeCachedDeviceList(userDevice, userDevice.getJid(), newList); OmemoService.publishDeviceList(omemoManager.getConnection(), newList); }
[ "public", "void", "purgeDeviceList", "(", "OmemoManager", ".", "LoggedInOmemoManager", "managerGuard", ")", "throws", "InterruptedException", ",", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ".", "NotConnectedException", ",", "SmackException", ".", "NoResponseException", "{", "OmemoManager", "omemoManager", "=", "managerGuard", ".", "get", "(", ")", ";", "OmemoDevice", "userDevice", "=", "omemoManager", ".", "getOwnDevice", "(", ")", ";", "OmemoDeviceListElement_VAxolotl", "newList", "=", "new", "OmemoDeviceListElement_VAxolotl", "(", "Collections", ".", "singleton", "(", "userDevice", ".", "getDeviceId", "(", ")", ")", ")", ";", "// Merge list", "getOmemoStoreBackend", "(", ")", ".", "mergeCachedDeviceList", "(", "userDevice", ",", "userDevice", ".", "getJid", "(", ")", ",", "newList", ")", ";", "OmemoService", ".", "publishDeviceList", "(", "omemoManager", ".", "getConnection", "(", ")", ",", "newList", ")", ";", "}" ]
Publish a new DeviceList with just our device in it. @param managerGuard authenticated OmemoManager. @throws InterruptedException @throws XMPPException.XMPPErrorException @throws SmackException.NotConnectedException @throws SmackException.NoResponseException
[ "Publish", "a", "new", "DeviceList", "with", "just", "our", "device", "in", "it", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoService.java#L1360-L1374
26,918
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleNegotiator.java
JingleNegotiator.getListenersList
protected List<JingleListener> getListenersList() { ArrayList<JingleListener> result; synchronized (listeners) { result = new ArrayList<>(listeners); } return result; }
java
protected List<JingleListener> getListenersList() { ArrayList<JingleListener> result; synchronized (listeners) { result = new ArrayList<>(listeners); } return result; }
[ "protected", "List", "<", "JingleListener", ">", "getListenersList", "(", ")", "{", "ArrayList", "<", "JingleListener", ">", "result", ";", "synchronized", "(", "listeners", ")", "{", "result", "=", "new", "ArrayList", "<>", "(", "listeners", ")", ";", "}", "return", "result", ";", "}" ]
Get a copy of the listeners @return a copy of the listeners
[ "Get", "a", "copy", "of", "the", "listeners" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleNegotiator.java#L192-L200
26,919
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.sendMessage
public void sendMessage(String text) throws NotConnectedException, InterruptedException { Message message = createMessage(); message.setBody(text); connection.sendStanza(message); }
java
public void sendMessage(String text) throws NotConnectedException, InterruptedException { Message message = createMessage(); message.setBody(text); connection.sendStanza(message); }
[ "public", "void", "sendMessage", "(", "String", "text", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "Message", "message", "=", "createMessage", "(", ")", ";", "message", ".", "setBody", "(", "text", ")", ";", "connection", ".", "sendStanza", "(", "message", ")", ";", "}" ]
Sends a message to the chat room. @param text the text of the message to send. @throws NotConnectedException @throws InterruptedException
[ "Sends", "a", "message", "to", "the", "chat", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L128-L132
26,920
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.sendMessage
public void sendMessage(Message message) throws NotConnectedException, InterruptedException { message.setTo(room); message.setType(Message.Type.groupchat); connection.sendStanza(message); }
java
public void sendMessage(Message message) throws NotConnectedException, InterruptedException { message.setTo(room); message.setType(Message.Type.groupchat); connection.sendStanza(message); }
[ "public", "void", "sendMessage", "(", "Message", "message", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "message", ".", "setTo", "(", "room", ")", ";", "message", ".", "setType", "(", "Message", ".", "Type", ".", "groupchat", ")", ";", "connection", ".", "sendStanza", "(", "message", ")", ";", "}" ]
Sends a Message to the chat room. @param message the message. @throws NotConnectedException @throws InterruptedException
[ "Sends", "a", "Message", "to", "the", "chat", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L173-L177
26,921
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.removeConnectionCallbacks
private void removeConnectionCallbacks() { connection.removeSyncStanzaListener(messageListener); if (messageCollector != null) { messageCollector.cancel(); messageCollector = null; } }
java
private void removeConnectionCallbacks() { connection.removeSyncStanzaListener(messageListener); if (messageCollector != null) { messageCollector.cancel(); messageCollector = null; } }
[ "private", "void", "removeConnectionCallbacks", "(", ")", "{", "connection", ".", "removeSyncStanzaListener", "(", "messageListener", ")", ";", "if", "(", "messageCollector", "!=", "null", ")", "{", "messageCollector", ".", "cancel", "(", ")", ";", "messageCollector", "=", "null", ";", "}", "}" ]
Remove the connection callbacks used by this MUC Light from the connection.
[ "Remove", "the", "connection", "callbacks", "used", "by", "this", "MUC", "Light", "from", "the", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L243-L249
26,922
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.leave
public void leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); affiliations.put(connection.getUser(), MUCLightAffiliation.none); MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); IQ responseIq = connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow(); boolean roomLeft = responseIq.getType().equals(IQ.Type.result); if (roomLeft) { removeConnectionCallbacks(); } }
java
public void leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException { HashMap<Jid, MUCLightAffiliation> affiliations = new HashMap<>(); affiliations.put(connection.getUser(), MUCLightAffiliation.none); MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); IQ responseIq = connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow(); boolean roomLeft = responseIq.getType().equals(IQ.Type.result); if (roomLeft) { removeConnectionCallbacks(); } }
[ "public", "void", "leave", "(", ")", "throws", "NotConnectedException", ",", "InterruptedException", ",", "NoResponseException", ",", "XMPPErrorException", "{", "HashMap", "<", "Jid", ",", "MUCLightAffiliation", ">", "affiliations", "=", "new", "HashMap", "<>", "(", ")", ";", "affiliations", ".", "put", "(", "connection", ".", "getUser", "(", ")", ",", "MUCLightAffiliation", ".", "none", ")", ";", "MUCLightChangeAffiliationsIQ", "changeAffiliationsIQ", "=", "new", "MUCLightChangeAffiliationsIQ", "(", "room", ",", "affiliations", ")", ";", "IQ", "responseIq", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "changeAffiliationsIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "boolean", "roomLeft", "=", "responseIq", ".", "getType", "(", ")", ".", "equals", "(", "IQ", ".", "Type", ".", "result", ")", ";", "if", "(", "roomLeft", ")", "{", "removeConnectionCallbacks", "(", ")", ";", "}", "}" ]
Leave the MUCLight. @throws NotConnectedException @throws InterruptedException @throws NoResponseException @throws XMPPErrorException
[ "Leave", "the", "MUCLight", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L298-L309
26,923
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.getFullInfo
public MUCLightRoomInfo getFullInfo(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ(room, version); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetInfoIQ).nextResultOrThrow(); MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) responseIq; return new MUCLightRoomInfo(mucLightInfoResponseIQ.getVersion(), room, mucLightInfoResponseIQ.getConfiguration(), mucLightInfoResponseIQ.getOccupants()); }
java
public MUCLightRoomInfo getFullInfo(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightGetInfoIQ mucLightGetInfoIQ = new MUCLightGetInfoIQ(room, version); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetInfoIQ).nextResultOrThrow(); MUCLightInfoIQ mucLightInfoResponseIQ = (MUCLightInfoIQ) responseIq; return new MUCLightRoomInfo(mucLightInfoResponseIQ.getVersion(), room, mucLightInfoResponseIQ.getConfiguration(), mucLightInfoResponseIQ.getOccupants()); }
[ "public", "MUCLightRoomInfo", "getFullInfo", "(", "String", "version", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightGetInfoIQ", "mucLightGetInfoIQ", "=", "new", "MUCLightGetInfoIQ", "(", "room", ",", "version", ")", ";", "IQ", "responseIq", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "mucLightGetInfoIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "MUCLightInfoIQ", "mucLightInfoResponseIQ", "=", "(", "MUCLightInfoIQ", ")", "responseIq", ";", "return", "new", "MUCLightRoomInfo", "(", "mucLightInfoResponseIQ", ".", "getVersion", "(", ")", ",", "room", ",", "mucLightInfoResponseIQ", ".", "getConfiguration", "(", ")", ",", "mucLightInfoResponseIQ", ".", "getOccupants", "(", ")", ")", ";", "}" ]
Get the MUC Light info. @param version @return the room info @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Get", "the", "MUC", "Light", "info", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L321-L330
26,924
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.getConfiguration
public MUCLightRoomConfiguration getConfiguration(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(room, version); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetConfigsIQ).nextResultOrThrow(); MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) responseIq; return mucLightConfigurationIQ.getConfiguration(); }
java
public MUCLightRoomConfiguration getConfiguration(String version) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightGetConfigsIQ mucLightGetConfigsIQ = new MUCLightGetConfigsIQ(room, version); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightGetConfigsIQ).nextResultOrThrow(); MUCLightConfigurationIQ mucLightConfigurationIQ = (MUCLightConfigurationIQ) responseIq; return mucLightConfigurationIQ.getConfiguration(); }
[ "public", "MUCLightRoomConfiguration", "getConfiguration", "(", "String", "version", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightGetConfigsIQ", "mucLightGetConfigsIQ", "=", "new", "MUCLightGetConfigsIQ", "(", "room", ",", "version", ")", ";", "IQ", "responseIq", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "mucLightGetConfigsIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "MUCLightConfigurationIQ", "mucLightConfigurationIQ", "=", "(", "MUCLightConfigurationIQ", ")", "responseIq", ";", "return", "mucLightConfigurationIQ", ".", "getConfiguration", "(", ")", ";", "}" ]
Get the MUC Light configuration. @param version @return the room configuration @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Get", "the", "MUC", "Light", "configuration", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L356-L362
26,925
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.changeAffiliations
public void changeAffiliations(HashMap<Jid, MUCLightAffiliation> affiliations) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow(); }
java
public void changeAffiliations(HashMap<Jid, MUCLightAffiliation> affiliations) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightChangeAffiliationsIQ changeAffiliationsIQ = new MUCLightChangeAffiliationsIQ(room, affiliations); connection.createStanzaCollectorAndSend(changeAffiliationsIQ).nextResultOrThrow(); }
[ "public", "void", "changeAffiliations", "(", "HashMap", "<", "Jid", ",", "MUCLightAffiliation", ">", "affiliations", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightChangeAffiliationsIQ", "changeAffiliationsIQ", "=", "new", "MUCLightChangeAffiliationsIQ", "(", "room", ",", "affiliations", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "changeAffiliationsIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Change the MUC Light affiliations. @param affiliations @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Change", "the", "MUC", "Light", "affiliations", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L421-L425
26,926
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.destroy
public void destroy() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(room); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightDestroyIQ).nextResultOrThrow(); boolean roomDestroyed = responseIq.getType().equals(IQ.Type.result); if (roomDestroyed) { removeConnectionCallbacks(); } }
java
public void destroy() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightDestroyIQ mucLightDestroyIQ = new MUCLightDestroyIQ(room); IQ responseIq = connection.createStanzaCollectorAndSend(mucLightDestroyIQ).nextResultOrThrow(); boolean roomDestroyed = responseIq.getType().equals(IQ.Type.result); if (roomDestroyed) { removeConnectionCallbacks(); } }
[ "public", "void", "destroy", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightDestroyIQ", "mucLightDestroyIQ", "=", "new", "MUCLightDestroyIQ", "(", "room", ")", ";", "IQ", "responseIq", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "mucLightDestroyIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "boolean", "roomDestroyed", "=", "responseIq", ".", "getType", "(", ")", ".", "equals", "(", "IQ", ".", "Type", ".", "result", ")", ";", "if", "(", "roomDestroyed", ")", "{", "removeConnectionCallbacks", "(", ")", ";", "}", "}" ]
Destroy the MUC Light. Only will work if it is requested by the owner. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Destroy", "the", "MUC", "Light", ".", "Only", "will", "work", "if", "it", "is", "requested", "by", "the", "owner", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L435-L443
26,927
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.changeSubject
public void changeSubject(String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, null, subject, null); connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow(); }
java
public void changeSubject(String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, null, subject, null); connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow(); }
[ "public", "void", "changeSubject", "(", "String", "subject", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightSetConfigsIQ", "mucLightSetConfigIQ", "=", "new", "MUCLightSetConfigsIQ", "(", "room", ",", "null", ",", "subject", ",", "null", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "mucLightSetConfigIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Change the subject of the MUC Light. @param subject @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Change", "the", "subject", "of", "the", "MUC", "Light", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L454-L458
26,928
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java
MultiUserChatLight.changeRoomName
public void changeRoomName(String roomName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, null); connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow(); }
java
public void changeRoomName(String roomName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightSetConfigsIQ mucLightSetConfigIQ = new MUCLightSetConfigsIQ(room, roomName, null); connection.createStanzaCollectorAndSend(mucLightSetConfigIQ).nextResultOrThrow(); }
[ "public", "void", "changeRoomName", "(", "String", "roomName", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightSetConfigsIQ", "mucLightSetConfigIQ", "=", "new", "MUCLightSetConfigsIQ", "(", "room", ",", "roomName", ",", "null", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "mucLightSetConfigIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Change the name of the room. @param roomName @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Change", "the", "name", "of", "the", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLight.java#L469-L473
26,929
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
FileTransferNegotiator.getInstanceFor
public static synchronized FileTransferNegotiator getInstanceFor( final XMPPConnection connection) { FileTransferNegotiator fileTransferNegotiator = INSTANCES.get(connection); if (fileTransferNegotiator == null) { fileTransferNegotiator = new FileTransferNegotiator(connection); INSTANCES.put(connection, fileTransferNegotiator); } return fileTransferNegotiator; }
java
public static synchronized FileTransferNegotiator getInstanceFor( final XMPPConnection connection) { FileTransferNegotiator fileTransferNegotiator = INSTANCES.get(connection); if (fileTransferNegotiator == null) { fileTransferNegotiator = new FileTransferNegotiator(connection); INSTANCES.put(connection, fileTransferNegotiator); } return fileTransferNegotiator; }
[ "public", "static", "synchronized", "FileTransferNegotiator", "getInstanceFor", "(", "final", "XMPPConnection", "connection", ")", "{", "FileTransferNegotiator", "fileTransferNegotiator", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "fileTransferNegotiator", "==", "null", ")", "{", "fileTransferNegotiator", "=", "new", "FileTransferNegotiator", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "fileTransferNegotiator", ")", ";", "}", "return", "fileTransferNegotiator", ";", "}" ]
Returns the file transfer negotiator related to a particular connection. When this class is requested on a particular connection the file transfer service is automatically enabled. @param connection The connection for which the transfer manager is desired @return The FileTransferNegotiator
[ "Returns", "the", "file", "transfer", "negotiator", "related", "to", "a", "particular", "connection", ".", "When", "this", "class", "is", "requested", "on", "a", "particular", "connection", "the", "file", "transfer", "service", "is", "automatically", "enabled", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java#L86-L94
26,930
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
FileTransferNegotiator.setServiceEnabled
private static void setServiceEnabled(final XMPPConnection connection, final boolean isEnabled) { ServiceDiscoveryManager manager = ServiceDiscoveryManager .getInstanceFor(connection); List<String> namespaces = new ArrayList<>(); namespaces.addAll(Arrays.asList(NAMESPACE)); namespaces.add(DataPacketExtension.NAMESPACE); if (!IBB_ONLY) { namespaces.add(Bytestream.NAMESPACE); } for (String namespace : namespaces) { if (isEnabled) { manager.addFeature(namespace); } else { manager.removeFeature(namespace); } } }
java
private static void setServiceEnabled(final XMPPConnection connection, final boolean isEnabled) { ServiceDiscoveryManager manager = ServiceDiscoveryManager .getInstanceFor(connection); List<String> namespaces = new ArrayList<>(); namespaces.addAll(Arrays.asList(NAMESPACE)); namespaces.add(DataPacketExtension.NAMESPACE); if (!IBB_ONLY) { namespaces.add(Bytestream.NAMESPACE); } for (String namespace : namespaces) { if (isEnabled) { manager.addFeature(namespace); } else { manager.removeFeature(namespace); } } }
[ "private", "static", "void", "setServiceEnabled", "(", "final", "XMPPConnection", "connection", ",", "final", "boolean", "isEnabled", ")", "{", "ServiceDiscoveryManager", "manager", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ";", "List", "<", "String", ">", "namespaces", "=", "new", "ArrayList", "<>", "(", ")", ";", "namespaces", ".", "addAll", "(", "Arrays", ".", "asList", "(", "NAMESPACE", ")", ")", ";", "namespaces", ".", "add", "(", "DataPacketExtension", ".", "NAMESPACE", ")", ";", "if", "(", "!", "IBB_ONLY", ")", "{", "namespaces", ".", "add", "(", "Bytestream", ".", "NAMESPACE", ")", ";", "}", "for", "(", "String", "namespace", ":", "namespaces", ")", "{", "if", "(", "isEnabled", ")", "{", "manager", ".", "addFeature", "(", "namespace", ")", ";", "}", "else", "{", "manager", ".", "removeFeature", "(", "namespace", ")", ";", "}", "}", "}" ]
Enable the Jabber services related to file transfer on the particular connection. @param connection The connection on which to enable or disable the services. @param isEnabled True to enable, false to disable.
[ "Enable", "the", "Jabber", "services", "related", "to", "file", "transfer", "on", "the", "particular", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java#L103-L122
26,931
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
FileTransferNegotiator.isServiceEnabled
public static boolean isServiceEnabled(final XMPPConnection connection) { ServiceDiscoveryManager manager = ServiceDiscoveryManager .getInstanceFor(connection); List<String> namespaces = new ArrayList<>(); namespaces.addAll(Arrays.asList(NAMESPACE)); namespaces.add(DataPacketExtension.NAMESPACE); if (!IBB_ONLY) { namespaces.add(Bytestream.NAMESPACE); } for (String namespace : namespaces) { if (!manager.includesFeature(namespace)) { return false; } } return true; }
java
public static boolean isServiceEnabled(final XMPPConnection connection) { ServiceDiscoveryManager manager = ServiceDiscoveryManager .getInstanceFor(connection); List<String> namespaces = new ArrayList<>(); namespaces.addAll(Arrays.asList(NAMESPACE)); namespaces.add(DataPacketExtension.NAMESPACE); if (!IBB_ONLY) { namespaces.add(Bytestream.NAMESPACE); } for (String namespace : namespaces) { if (!manager.includesFeature(namespace)) { return false; } } return true; }
[ "public", "static", "boolean", "isServiceEnabled", "(", "final", "XMPPConnection", "connection", ")", "{", "ServiceDiscoveryManager", "manager", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ";", "List", "<", "String", ">", "namespaces", "=", "new", "ArrayList", "<>", "(", ")", ";", "namespaces", ".", "addAll", "(", "Arrays", ".", "asList", "(", "NAMESPACE", ")", ")", ";", "namespaces", ".", "add", "(", "DataPacketExtension", ".", "NAMESPACE", ")", ";", "if", "(", "!", "IBB_ONLY", ")", "{", "namespaces", ".", "add", "(", "Bytestream", ".", "NAMESPACE", ")", ";", "}", "for", "(", "String", "namespace", ":", "namespaces", ")", "{", "if", "(", "!", "manager", ".", "includesFeature", "(", "namespace", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Checks to see if all file transfer related services are enabled on the connection. @param connection The connection to check @return True if all related services are enabled, false if they are not.
[ "Checks", "to", "see", "if", "all", "file", "transfer", "related", "services", "are", "enabled", "on", "the", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java#L131-L148
26,932
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
FileTransferNegotiator.getSupportedProtocols
public static Collection<String> getSupportedProtocols() { List<String> protocols = new ArrayList<>(); protocols.add(DataPacketExtension.NAMESPACE); if (!IBB_ONLY) { protocols.add(Bytestream.NAMESPACE); } return Collections.unmodifiableList(protocols); }
java
public static Collection<String> getSupportedProtocols() { List<String> protocols = new ArrayList<>(); protocols.add(DataPacketExtension.NAMESPACE); if (!IBB_ONLY) { protocols.add(Bytestream.NAMESPACE); } return Collections.unmodifiableList(protocols); }
[ "public", "static", "Collection", "<", "String", ">", "getSupportedProtocols", "(", ")", "{", "List", "<", "String", ">", "protocols", "=", "new", "ArrayList", "<>", "(", ")", ";", "protocols", ".", "add", "(", "DataPacketExtension", ".", "NAMESPACE", ")", ";", "if", "(", "!", "IBB_ONLY", ")", "{", "protocols", ".", "add", "(", "Bytestream", ".", "NAMESPACE", ")", ";", "}", "return", "Collections", ".", "unmodifiableList", "(", "protocols", ")", ";", "}" ]
Returns a collection of the supported transfer protocols. @return Returns a collection of the supported transfer protocols.
[ "Returns", "a", "collection", "of", "the", "supported", "transfer", "protocols", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java#L155-L162
26,933
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
FileTransferNegotiator.selectStreamNegotiator
public StreamNegotiator selectStreamNegotiator( FileTransferRequest request) throws NotConnectedException, NoStreamMethodsOfferedException, NoAcceptableTransferMechanisms, InterruptedException { StreamInitiation si = request.getStreamInitiation(); FormField streamMethodField = getStreamMethodField(si .getFeatureNegotiationForm()); if (streamMethodField == null) { String errorMessage = "No stream methods contained in stanza."; StanzaError.Builder error = StanzaError.from(StanzaError.Condition.bad_request, errorMessage); IQ iqPacket = IQ.createErrorResponse(si, error); connection().sendStanza(iqPacket); throw new FileTransferException.NoStreamMethodsOfferedException(); } // select the appropriate protocol StreamNegotiator selectedStreamNegotiator; try { selectedStreamNegotiator = getNegotiator(streamMethodField); } catch (NoAcceptableTransferMechanisms e) { IQ iqPacket = IQ.createErrorResponse(si, StanzaError.from(StanzaError.Condition.bad_request, "No acceptable transfer mechanism")); connection().sendStanza(iqPacket); throw e; } // return the appropriate negotiator return selectedStreamNegotiator; }
java
public StreamNegotiator selectStreamNegotiator( FileTransferRequest request) throws NotConnectedException, NoStreamMethodsOfferedException, NoAcceptableTransferMechanisms, InterruptedException { StreamInitiation si = request.getStreamInitiation(); FormField streamMethodField = getStreamMethodField(si .getFeatureNegotiationForm()); if (streamMethodField == null) { String errorMessage = "No stream methods contained in stanza."; StanzaError.Builder error = StanzaError.from(StanzaError.Condition.bad_request, errorMessage); IQ iqPacket = IQ.createErrorResponse(si, error); connection().sendStanza(iqPacket); throw new FileTransferException.NoStreamMethodsOfferedException(); } // select the appropriate protocol StreamNegotiator selectedStreamNegotiator; try { selectedStreamNegotiator = getNegotiator(streamMethodField); } catch (NoAcceptableTransferMechanisms e) { IQ iqPacket = IQ.createErrorResponse(si, StanzaError.from(StanzaError.Condition.bad_request, "No acceptable transfer mechanism")); connection().sendStanza(iqPacket); throw e; } // return the appropriate negotiator return selectedStreamNegotiator; }
[ "public", "StreamNegotiator", "selectStreamNegotiator", "(", "FileTransferRequest", "request", ")", "throws", "NotConnectedException", ",", "NoStreamMethodsOfferedException", ",", "NoAcceptableTransferMechanisms", ",", "InterruptedException", "{", "StreamInitiation", "si", "=", "request", ".", "getStreamInitiation", "(", ")", ";", "FormField", "streamMethodField", "=", "getStreamMethodField", "(", "si", ".", "getFeatureNegotiationForm", "(", ")", ")", ";", "if", "(", "streamMethodField", "==", "null", ")", "{", "String", "errorMessage", "=", "\"No stream methods contained in stanza.\"", ";", "StanzaError", ".", "Builder", "error", "=", "StanzaError", ".", "from", "(", "StanzaError", ".", "Condition", ".", "bad_request", ",", "errorMessage", ")", ";", "IQ", "iqPacket", "=", "IQ", ".", "createErrorResponse", "(", "si", ",", "error", ")", ";", "connection", "(", ")", ".", "sendStanza", "(", "iqPacket", ")", ";", "throw", "new", "FileTransferException", ".", "NoStreamMethodsOfferedException", "(", ")", ";", "}", "// select the appropriate protocol", "StreamNegotiator", "selectedStreamNegotiator", ";", "try", "{", "selectedStreamNegotiator", "=", "getNegotiator", "(", "streamMethodField", ")", ";", "}", "catch", "(", "NoAcceptableTransferMechanisms", "e", ")", "{", "IQ", "iqPacket", "=", "IQ", ".", "createErrorResponse", "(", "si", ",", "StanzaError", ".", "from", "(", "StanzaError", ".", "Condition", ".", "bad_request", ",", "\"No acceptable transfer mechanism\"", ")", ")", ";", "connection", "(", ")", ".", "sendStanza", "(", "iqPacket", ")", ";", "throw", "e", ";", "}", "// return the appropriate negotiator", "return", "selectedStreamNegotiator", ";", "}" ]
Selects an appropriate stream negotiator after examining the incoming file transfer request. @param request The related file transfer request. @return The file transfer object that handles the transfer @throws NoStreamMethodsOfferedException If there are either no stream methods contained in the packet, or there is not an appropriate stream method. @throws NotConnectedException @throws NoAcceptableTransferMechanisms @throws InterruptedException
[ "Selects", "an", "appropriate", "stream", "negotiator", "after", "examining", "the", "incoming", "file", "transfer", "request", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java#L189-L217
26,934
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java
FileTransferNegotiator.getNextStreamID
public static String getNextStreamID() { StringBuilder buffer = new StringBuilder(); buffer.append(STREAM_INIT_PREFIX); buffer.append(randomGenerator.nextInt(Integer.MAX_VALUE) + randomGenerator.nextInt(Integer.MAX_VALUE)); return buffer.toString(); }
java
public static String getNextStreamID() { StringBuilder buffer = new StringBuilder(); buffer.append(STREAM_INIT_PREFIX); buffer.append(randomGenerator.nextInt(Integer.MAX_VALUE) + randomGenerator.nextInt(Integer.MAX_VALUE)); return buffer.toString(); }
[ "public", "static", "String", "getNextStreamID", "(", ")", "{", "StringBuilder", "buffer", "=", "new", "StringBuilder", "(", ")", ";", "buffer", ".", "append", "(", "STREAM_INIT_PREFIX", ")", ";", "buffer", ".", "append", "(", "randomGenerator", ".", "nextInt", "(", "Integer", ".", "MAX_VALUE", ")", "+", "randomGenerator", ".", "nextInt", "(", "Integer", ".", "MAX_VALUE", ")", ")", ";", "return", "buffer", ".", "toString", "(", ")", ";", "}" ]
Returns a new, unique, stream ID to identify a file transfer. @return Returns a new, unique, stream ID to identify a file transfer.
[ "Returns", "a", "new", "unique", "stream", "ID", "to", "identify", "a", "file", "transfer", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/filetransfer/FileTransferNegotiator.java#L260-L266
26,935
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/element/OmemoBundleElement.java
OmemoBundleElement.getPreKeys
public HashMap<Integer, byte[]> getPreKeys() { if (preKeys == null) { preKeys = new HashMap<>(); for (int id : preKeysB64.keySet()) { preKeys.put(id, Base64.decode(preKeysB64.get(id))); } } return this.preKeys; }
java
public HashMap<Integer, byte[]> getPreKeys() { if (preKeys == null) { preKeys = new HashMap<>(); for (int id : preKeysB64.keySet()) { preKeys.put(id, Base64.decode(preKeysB64.get(id))); } } return this.preKeys; }
[ "public", "HashMap", "<", "Integer", ",", "byte", "[", "]", ">", "getPreKeys", "(", ")", "{", "if", "(", "preKeys", "==", "null", ")", "{", "preKeys", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "int", "id", ":", "preKeysB64", ".", "keySet", "(", ")", ")", "{", "preKeys", ".", "put", "(", "id", ",", "Base64", ".", "decode", "(", "preKeysB64", ".", "get", "(", "id", ")", ")", ")", ";", "}", "}", "return", "this", ".", "preKeys", ";", "}" ]
Return the HashMap of preKeys in the bundle. The map uses the preKeys ids as key and the preKeys as value. @return preKeys
[ "Return", "the", "HashMap", "of", "preKeys", "in", "the", "bundle", ".", "The", "map", "uses", "the", "preKeys", "ids", "as", "key", "and", "the", "preKeys", "as", "value", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/element/OmemoBundleElement.java#L163-L171
26,936
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java
IQ.getChildElementXML
public final XmlStringBuilder getChildElementXML(XmlEnvironment enclosingXmlEnvironment) { XmlStringBuilder xml = new XmlStringBuilder(); if (type == Type.error) { // Add the error sub-packet, if there is one. appendErrorIfExists(xml, enclosingXmlEnvironment); } else if (childElementName != null) { // Add the query section if there is one. IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this)); if (iqChildElement != null) { xml.append(iqChildElement); List<ExtensionElement> extensionsXml = getExtensions(); if (iqChildElement.isEmptyElement) { if (extensionsXml.isEmpty()) { xml.closeEmptyElement(); return xml; } else { xml.rightAngleBracket(); } } xml.append(extensionsXml); xml.closeElement(iqChildElement.element); } } return xml; }
java
public final XmlStringBuilder getChildElementXML(XmlEnvironment enclosingXmlEnvironment) { XmlStringBuilder xml = new XmlStringBuilder(); if (type == Type.error) { // Add the error sub-packet, if there is one. appendErrorIfExists(xml, enclosingXmlEnvironment); } else if (childElementName != null) { // Add the query section if there is one. IQChildElementXmlStringBuilder iqChildElement = getIQChildElementBuilder(new IQChildElementXmlStringBuilder(this)); if (iqChildElement != null) { xml.append(iqChildElement); List<ExtensionElement> extensionsXml = getExtensions(); if (iqChildElement.isEmptyElement) { if (extensionsXml.isEmpty()) { xml.closeEmptyElement(); return xml; } else { xml.rightAngleBracket(); } } xml.append(extensionsXml); xml.closeElement(iqChildElement.element); } } return xml; }
[ "public", "final", "XmlStringBuilder", "getChildElementXML", "(", "XmlEnvironment", "enclosingXmlEnvironment", ")", "{", "XmlStringBuilder", "xml", "=", "new", "XmlStringBuilder", "(", ")", ";", "if", "(", "type", "==", "Type", ".", "error", ")", "{", "// Add the error sub-packet, if there is one.", "appendErrorIfExists", "(", "xml", ",", "enclosingXmlEnvironment", ")", ";", "}", "else", "if", "(", "childElementName", "!=", "null", ")", "{", "// Add the query section if there is one.", "IQChildElementXmlStringBuilder", "iqChildElement", "=", "getIQChildElementBuilder", "(", "new", "IQChildElementXmlStringBuilder", "(", "this", ")", ")", ";", "if", "(", "iqChildElement", "!=", "null", ")", "{", "xml", ".", "append", "(", "iqChildElement", ")", ";", "List", "<", "ExtensionElement", ">", "extensionsXml", "=", "getExtensions", "(", ")", ";", "if", "(", "iqChildElement", ".", "isEmptyElement", ")", "{", "if", "(", "extensionsXml", ".", "isEmpty", "(", ")", ")", "{", "xml", ".", "closeEmptyElement", "(", ")", ";", "return", "xml", ";", "}", "else", "{", "xml", ".", "rightAngleBracket", "(", ")", ";", "}", "}", "xml", ".", "append", "(", "extensionsXml", ")", ";", "xml", ".", "closeElement", "(", "iqChildElement", ".", "element", ")", ";", "}", "}", "return", "xml", ";", "}" ]
Returns the sub-element XML section of the IQ packet, or the empty String if there isn't one. @param enclosingXmlEnvironment the enclosing XML namespace. @return the child element section of the IQ XML. @since 4.3.0
[ "Returns", "the", "sub", "-", "element", "XML", "section", "of", "the", "IQ", "packet", "or", "the", "empty", "String", "if", "there", "isn", "t", "one", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/IQ.java#L173-L199
26,937
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/RosterGroup.java
RosterGroup.setName
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException { synchronized (entries) { for (RosterEntry entry : entries) { RosterPacket packet = new RosterPacket(); packet.setType(IQ.Type.set); RosterPacket.Item item = RosterEntry.toRosterItem(entry); item.removeGroupName(this.name); item.addGroupName(name); packet.addRosterItem(item); connection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); } } }
java
public void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException { synchronized (entries) { for (RosterEntry entry : entries) { RosterPacket packet = new RosterPacket(); packet.setType(IQ.Type.set); RosterPacket.Item item = RosterEntry.toRosterItem(entry); item.removeGroupName(this.name); item.addGroupName(name); packet.addRosterItem(item); connection().createStanzaCollectorAndSend(packet).nextResultOrThrow(); } } }
[ "public", "void", "setName", "(", "String", "name", ")", "throws", "NotConnectedException", ",", "NoResponseException", ",", "XMPPErrorException", ",", "InterruptedException", "{", "synchronized", "(", "entries", ")", "{", "for", "(", "RosterEntry", "entry", ":", "entries", ")", "{", "RosterPacket", "packet", "=", "new", "RosterPacket", "(", ")", ";", "packet", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "RosterPacket", ".", "Item", "item", "=", "RosterEntry", ".", "toRosterItem", "(", "entry", ")", ";", "item", ".", "removeGroupName", "(", "this", ".", "name", ")", ";", "item", ".", "addGroupName", "(", "name", ")", ";", "packet", ".", "addRosterItem", "(", "item", ")", ";", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "packet", ")", ".", "nextResultOrThrow", "(", ")", ";", "}", "}", "}" ]
Sets the name of the group. Changing the group's name is like moving all the group entries of the group to a new group specified by the new name. Since this group won't have entries it will be removed from the roster. This means that all the references to this object will be invalid and will need to be updated to the new group specified by the new name. @param name the name of the group. @throws NotConnectedException @throws XMPPErrorException @throws NoResponseException @throws InterruptedException
[ "Sets", "the", "name", "of", "the", "group", ".", "Changing", "the", "group", "s", "name", "is", "like", "moving", "all", "the", "group", "entries", "of", "the", "group", "to", "a", "new", "group", "specified", "by", "the", "new", "name", ".", "Since", "this", "group", "won", "t", "have", "entries", "it", "will", "be", "removed", "from", "the", "roster", ".", "This", "means", "that", "all", "the", "references", "to", "this", "object", "will", "be", "invalid", "and", "will", "need", "to", "be", "updated", "to", "the", "new", "group", "specified", "by", "the", "new", "name", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterGroup.java#L79-L91
26,938
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java
ChatMarkersManager.getInstanceFor
public static synchronized ChatMarkersManager getInstanceFor(XMPPConnection connection) { ChatMarkersManager chatMarkersManager = INSTANCES.get(connection); if (chatMarkersManager == null) { chatMarkersManager = new ChatMarkersManager(connection); INSTANCES.put(connection, chatMarkersManager); } return chatMarkersManager; }
java
public static synchronized ChatMarkersManager getInstanceFor(XMPPConnection connection) { ChatMarkersManager chatMarkersManager = INSTANCES.get(connection); if (chatMarkersManager == null) { chatMarkersManager = new ChatMarkersManager(connection); INSTANCES.put(connection, chatMarkersManager); } return chatMarkersManager; }
[ "public", "static", "synchronized", "ChatMarkersManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "ChatMarkersManager", "chatMarkersManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "chatMarkersManager", "==", "null", ")", "{", "chatMarkersManager", "=", "new", "ChatMarkersManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "chatMarkersManager", ")", ";", "}", "return", "chatMarkersManager", ";", "}" ]
Get the singleton instance of ChatMarkersManager. @param connection the connection used to get the ChatMarkersManager instance. @return the instance of ChatMarkersManager
[ "Get", "the", "singleton", "instance", "of", "ChatMarkersManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java#L106-L115
26,939
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java
ChatMarkersManager.addIncomingChatMarkerMessageListener
public synchronized boolean addIncomingChatMarkerMessageListener(ChatMarkersListener listener) { boolean res = incomingListeners.add(listener); if (!enabled) { serviceDiscoveryManager.addFeature(ChatMarkersElements.NAMESPACE); enabled = true; } return res; }
java
public synchronized boolean addIncomingChatMarkerMessageListener(ChatMarkersListener listener) { boolean res = incomingListeners.add(listener); if (!enabled) { serviceDiscoveryManager.addFeature(ChatMarkersElements.NAMESPACE); enabled = true; } return res; }
[ "public", "synchronized", "boolean", "addIncomingChatMarkerMessageListener", "(", "ChatMarkersListener", "listener", ")", "{", "boolean", "res", "=", "incomingListeners", ".", "add", "(", "listener", ")", ";", "if", "(", "!", "enabled", ")", "{", "serviceDiscoveryManager", ".", "addFeature", "(", "ChatMarkersElements", ".", "NAMESPACE", ")", ";", "enabled", "=", "true", ";", "}", "return", "res", ";", "}" ]
Register a ChatMarkersListener. That listener will be informed about new incoming markable messages. @param listener ChatMarkersListener @return true, if the listener was not registered before
[ "Register", "a", "ChatMarkersListener", ".", "That", "listener", "will", "be", "informed", "about", "new", "incoming", "markable", "messages", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java#L198-L205
26,940
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java
ChatMarkersManager.removeIncomingChatMarkerMessageListener
public synchronized boolean removeIncomingChatMarkerMessageListener(ChatMarkersListener listener) { boolean res = incomingListeners.remove(listener); if (incomingListeners.isEmpty() && enabled) { serviceDiscoveryManager.removeFeature(ChatMarkersElements.NAMESPACE); enabled = false; } return res; }
java
public synchronized boolean removeIncomingChatMarkerMessageListener(ChatMarkersListener listener) { boolean res = incomingListeners.remove(listener); if (incomingListeners.isEmpty() && enabled) { serviceDiscoveryManager.removeFeature(ChatMarkersElements.NAMESPACE); enabled = false; } return res; }
[ "public", "synchronized", "boolean", "removeIncomingChatMarkerMessageListener", "(", "ChatMarkersListener", "listener", ")", "{", "boolean", "res", "=", "incomingListeners", ".", "remove", "(", "listener", ")", ";", "if", "(", "incomingListeners", ".", "isEmpty", "(", ")", "&&", "enabled", ")", "{", "serviceDiscoveryManager", ".", "removeFeature", "(", "ChatMarkersElements", ".", "NAMESPACE", ")", ";", "enabled", "=", "false", ";", "}", "return", "res", ";", "}" ]
Unregister a ChatMarkersListener. @param listener ChatMarkersListener @return true, if the listener was registered before
[ "Unregister", "a", "ChatMarkersListener", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/chat_markers/ChatMarkersManager.java#L213-L220
26,941
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java
ConnectionConfiguration.isEnabledSaslMechanism
public boolean isEnabledSaslMechanism(String saslMechanism) { // If enabledSaslMechanisms is not set, then all mechanisms which are not blacklisted are enabled per default. if (enabledSaslMechanisms == null) { return !SASLAuthentication.getBlacklistedSASLMechanisms().contains(saslMechanism); } return enabledSaslMechanisms.contains(saslMechanism); }
java
public boolean isEnabledSaslMechanism(String saslMechanism) { // If enabledSaslMechanisms is not set, then all mechanisms which are not blacklisted are enabled per default. if (enabledSaslMechanisms == null) { return !SASLAuthentication.getBlacklistedSASLMechanisms().contains(saslMechanism); } return enabledSaslMechanisms.contains(saslMechanism); }
[ "public", "boolean", "isEnabledSaslMechanism", "(", "String", "saslMechanism", ")", "{", "// If enabledSaslMechanisms is not set, then all mechanisms which are not blacklisted are enabled per default.", "if", "(", "enabledSaslMechanisms", "==", "null", ")", "{", "return", "!", "SASLAuthentication", ".", "getBlacklistedSASLMechanisms", "(", ")", ".", "contains", "(", "saslMechanism", ")", ";", "}", "return", "enabledSaslMechanisms", ".", "contains", "(", "saslMechanism", ")", ";", "}" ]
Check if the given SASL mechansism is enabled in this connection configuration. @param saslMechanism @return true if the given SASL mechanism is enabled, false otherwise.
[ "Check", "if", "the", "given", "SASL", "mechansism", "is", "enabled", "in", "this", "connection", "configuration", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/ConnectionConfiguration.java#L486-L492
26,942
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/StanzaIdElement.java
StanzaIdElement.getStanzaId
public static StanzaIdElement getStanzaId(Message message) { return message.getExtension(StanzaIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE); }
java
public static StanzaIdElement getStanzaId(Message message) { return message.getExtension(StanzaIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE); }
[ "public", "static", "StanzaIdElement", "getStanzaId", "(", "Message", "message", ")", "{", "return", "message", ".", "getExtension", "(", "StanzaIdElement", ".", "ELEMENT", ",", "StableUniqueStanzaIdManager", ".", "NAMESPACE", ")", ";", "}" ]
Return the stanza-id element of a message. @param message message @return stanza-id element of a jid, or null if absent.
[ "Return", "the", "stanza", "-", "id", "element", "of", "a", "message", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/StanzaIdElement.java#L56-L58
26,943
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.setTo
@Deprecated public void setTo(String to) { Jid jid; try { jid = JidCreate.from(to); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } setTo(jid); }
java
@Deprecated public void setTo(String to) { Jid jid; try { jid = JidCreate.from(to); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } setTo(jid); }
[ "@", "Deprecated", "public", "void", "setTo", "(", "String", "to", ")", "{", "Jid", "jid", ";", "try", "{", "jid", "=", "JidCreate", ".", "from", "(", "to", ")", ";", "}", "catch", "(", "XmppStringprepException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "setTo", "(", "jid", ")", ";", "}" ]
Sets who the stanza is being sent "to". The XMPP protocol often makes the "to" attribute optional, so it does not always need to be set. @param to who the stanza is being sent to. @throws IllegalArgumentException if to is not a valid JID String. @deprecated use {@link #setTo(Jid)} instead.
[ "Sets", "who", "the", "stanza", "is", "being", "sent", "to", ".", "The", "XMPP", "protocol", "often", "makes", "the", "to", "attribute", "optional", "so", "it", "does", "not", "always", "need", "to", "be", "set", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L185-L195
26,944
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.setFrom
@Deprecated public void setFrom(String from) { Jid jid; try { jid = JidCreate.from(from); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } setFrom(jid); }
java
@Deprecated public void setFrom(String from) { Jid jid; try { jid = JidCreate.from(from); } catch (XmppStringprepException e) { throw new IllegalArgumentException(e); } setFrom(jid); }
[ "@", "Deprecated", "public", "void", "setFrom", "(", "String", "from", ")", "{", "Jid", "jid", ";", "try", "{", "jid", "=", "JidCreate", ".", "from", "(", "from", ")", ";", "}", "catch", "(", "XmppStringprepException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "e", ")", ";", "}", "setFrom", "(", "jid", ")", ";", "}" ]
Sets who the stanza is being sent "from". The XMPP protocol often makes the "from" attribute optional, so it does not always need to be set. @param from who the stanza is being sent to. @throws IllegalArgumentException if from is not a valid JID String. @deprecated use {@link #setFrom(Jid)} instead.
[ "Sets", "who", "the", "stanza", "is", "being", "sent", "from", ".", "The", "XMPP", "protocol", "often", "makes", "the", "from", "attribute", "optional", "so", "it", "does", "not", "always", "need", "to", "be", "set", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L228-L238
26,945
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.setError
public void setError(StanzaError.Builder xmppErrorBuilder) { if (xmppErrorBuilder == null) { return; } xmppErrorBuilder.setStanza(this); error = xmppErrorBuilder.build(); }
java
public void setError(StanzaError.Builder xmppErrorBuilder) { if (xmppErrorBuilder == null) { return; } xmppErrorBuilder.setStanza(this); error = xmppErrorBuilder.build(); }
[ "public", "void", "setError", "(", "StanzaError", ".", "Builder", "xmppErrorBuilder", ")", "{", "if", "(", "xmppErrorBuilder", "==", "null", ")", "{", "return", ";", "}", "xmppErrorBuilder", ".", "setStanza", "(", "this", ")", ";", "error", "=", "xmppErrorBuilder", ".", "build", "(", ")", ";", "}" ]
Sets the error for this stanza. @param xmppErrorBuilder the error to associate with this stanza.
[ "Sets", "the", "error", "for", "this", "stanza", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L277-L283
26,946
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.addExtension
public void addExtension(ExtensionElement extension) { if (extension == null) return; String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace()); synchronized (packetExtensions) { packetExtensions.put(key, extension); } }
java
public void addExtension(ExtensionElement extension) { if (extension == null) return; String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace()); synchronized (packetExtensions) { packetExtensions.put(key, extension); } }
[ "public", "void", "addExtension", "(", "ExtensionElement", "extension", ")", "{", "if", "(", "extension", "==", "null", ")", "return", ";", "String", "key", "=", "XmppStringUtils", ".", "generateKey", "(", "extension", ".", "getElementName", "(", ")", ",", "extension", ".", "getNamespace", "(", ")", ")", ";", "synchronized", "(", "packetExtensions", ")", "{", "packetExtensions", ".", "put", "(", "key", ",", "extension", ")", ";", "}", "}" ]
Adds a stanza extension to the packet. Does nothing if extension is null. @param extension a stanza extension.
[ "Adds", "a", "stanza", "extension", "to", "the", "packet", ".", "Does", "nothing", "if", "extension", "is", "null", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L378-L384
26,947
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.overrideExtension
public ExtensionElement overrideExtension(ExtensionElement extension) { if (extension == null) return null; synchronized (packetExtensions) { // Note that we need to use removeExtension(String, String) here. If would use // removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which // is not what we want in this case. ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace()); addExtension(extension); return removedExtension; } }
java
public ExtensionElement overrideExtension(ExtensionElement extension) { if (extension == null) return null; synchronized (packetExtensions) { // Note that we need to use removeExtension(String, String) here. If would use // removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which // is not what we want in this case. ExtensionElement removedExtension = removeExtension(extension.getElementName(), extension.getNamespace()); addExtension(extension); return removedExtension; } }
[ "public", "ExtensionElement", "overrideExtension", "(", "ExtensionElement", "extension", ")", "{", "if", "(", "extension", "==", "null", ")", "return", "null", ";", "synchronized", "(", "packetExtensions", ")", "{", "// Note that we need to use removeExtension(String, String) here. If would use", "// removeExtension(ExtensionElement) then we would remove based on the equality of ExtensionElement, which", "// is not what we want in this case.", "ExtensionElement", "removedExtension", "=", "removeExtension", "(", "extension", ".", "getElementName", "(", ")", ",", "extension", ".", "getNamespace", "(", ")", ")", ";", "addExtension", "(", "extension", ")", ";", "return", "removedExtension", ";", "}", "}" ]
Add the given extension and override eventually existing extensions with the same name and namespace. @param extension the extension element to add. @return one of the removed extensions or <code>null</code> if there are none. @since 4.1.2
[ "Add", "the", "given", "extension", "and", "override", "eventually", "existing", "extensions", "with", "the", "same", "name", "and", "namespace", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L394-L404
26,948
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.addExtensions
public void addExtensions(Collection<ExtensionElement> extensions) { if (extensions == null) return; for (ExtensionElement packetExtension : extensions) { addExtension(packetExtension); } }
java
public void addExtensions(Collection<ExtensionElement> extensions) { if (extensions == null) return; for (ExtensionElement packetExtension : extensions) { addExtension(packetExtension); } }
[ "public", "void", "addExtensions", "(", "Collection", "<", "ExtensionElement", ">", "extensions", ")", "{", "if", "(", "extensions", "==", "null", ")", "return", ";", "for", "(", "ExtensionElement", "packetExtension", ":", "extensions", ")", "{", "addExtension", "(", "packetExtension", ")", ";", "}", "}" ]
Adds a collection of stanza extensions to the packet. Does nothing if extensions is null. @param extensions a collection of stanza extensions
[ "Adds", "a", "collection", "of", "stanza", "extensions", "to", "the", "packet", ".", "Does", "nothing", "if", "extensions", "is", "null", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L411-L416
26,949
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.hasExtension
public boolean hasExtension(String namespace) { synchronized (packetExtensions) { for (ExtensionElement packetExtension : packetExtensions.values()) { if (packetExtension.getNamespace().equals(namespace)) { return true; } } } return false; }
java
public boolean hasExtension(String namespace) { synchronized (packetExtensions) { for (ExtensionElement packetExtension : packetExtensions.values()) { if (packetExtension.getNamespace().equals(namespace)) { return true; } } } return false; }
[ "public", "boolean", "hasExtension", "(", "String", "namespace", ")", "{", "synchronized", "(", "packetExtensions", ")", "{", "for", "(", "ExtensionElement", "packetExtension", ":", "packetExtensions", ".", "values", "(", ")", ")", "{", "if", "(", "packetExtension", ".", "getNamespace", "(", ")", ".", "equals", "(", "namespace", ")", ")", "{", "return", "true", ";", "}", "}", "}", "return", "false", ";", "}" ]
Check if a stanza extension with the given namespace exists. @param namespace @return true if a stanza extension exists, false otherwise.
[ "Check", "if", "a", "stanza", "extension", "with", "the", "given", "namespace", "exists", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L444-L453
26,950
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.removeExtension
public ExtensionElement removeExtension(String elementName, String namespace) { String key = XmppStringUtils.generateKey(elementName, namespace); synchronized (packetExtensions) { return packetExtensions.remove(key); } }
java
public ExtensionElement removeExtension(String elementName, String namespace) { String key = XmppStringUtils.generateKey(elementName, namespace); synchronized (packetExtensions) { return packetExtensions.remove(key); } }
[ "public", "ExtensionElement", "removeExtension", "(", "String", "elementName", ",", "String", "namespace", ")", "{", "String", "key", "=", "XmppStringUtils", ".", "generateKey", "(", "elementName", ",", "namespace", ")", ";", "synchronized", "(", "packetExtensions", ")", "{", "return", "packetExtensions", ".", "remove", "(", "key", ")", ";", "}", "}" ]
Remove the stanza extension with the given elementName and namespace. @param elementName @param namespace @return the removed stanza extension or null.
[ "Remove", "the", "stanza", "extension", "with", "the", "given", "elementName", "and", "namespace", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L462-L467
26,951
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.removeExtension
public ExtensionElement removeExtension(ExtensionElement extension) { String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace()); synchronized (packetExtensions) { List<ExtensionElement> list = packetExtensions.getAll(key); boolean removed = list.remove(extension); if (removed) { return extension; } } return null; }
java
public ExtensionElement removeExtension(ExtensionElement extension) { String key = XmppStringUtils.generateKey(extension.getElementName(), extension.getNamespace()); synchronized (packetExtensions) { List<ExtensionElement> list = packetExtensions.getAll(key); boolean removed = list.remove(extension); if (removed) { return extension; } } return null; }
[ "public", "ExtensionElement", "removeExtension", "(", "ExtensionElement", "extension", ")", "{", "String", "key", "=", "XmppStringUtils", ".", "generateKey", "(", "extension", ".", "getElementName", "(", ")", ",", "extension", ".", "getNamespace", "(", ")", ")", ";", "synchronized", "(", "packetExtensions", ")", "{", "List", "<", "ExtensionElement", ">", "list", "=", "packetExtensions", ".", "getAll", "(", "key", ")", ";", "boolean", "removed", "=", "list", ".", "remove", "(", "extension", ")", ";", "if", "(", "removed", ")", "{", "return", "extension", ";", "}", "}", "return", "null", ";", "}" ]
Removes a stanza extension from the packet. @param extension the stanza extension to remove. @return the removed stanza extension or null.
[ "Removes", "a", "stanza", "extension", "from", "the", "packet", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L475-L485
26,952
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java
Stanza.appendErrorIfExists
protected void appendErrorIfExists(XmlStringBuilder xml, XmlEnvironment enclosingXmlEnvironment) { StanzaError error = getError(); if (error != null) { xml.append(error.toXML(enclosingXmlEnvironment)); } }
java
protected void appendErrorIfExists(XmlStringBuilder xml, XmlEnvironment enclosingXmlEnvironment) { StanzaError error = getError(); if (error != null) { xml.append(error.toXML(enclosingXmlEnvironment)); } }
[ "protected", "void", "appendErrorIfExists", "(", "XmlStringBuilder", "xml", ",", "XmlEnvironment", "enclosingXmlEnvironment", ")", "{", "StanzaError", "error", "=", "getError", "(", ")", ";", "if", "(", "error", "!=", "null", ")", "{", "xml", ".", "append", "(", "error", ".", "toXML", "(", "enclosingXmlEnvironment", ")", ")", ";", "}", "}" ]
Append an XMPPError is this stanza has one set. @param xml the XmlStringBuilder to append the error to.
[ "Append", "an", "XMPPError", "is", "this", "stanza", "has", "one", "set", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Stanza.java#L549-L554
26,953
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Agent.java
Agent.getName
public String getName() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { AgentInfo agentInfo = new AgentInfo(); agentInfo.setType(IQ.Type.get); agentInfo.setTo(workgroupJID); agentInfo.setFrom(getUser()); AgentInfo response = connection.createStanzaCollectorAndSend(agentInfo).nextResultOrThrow(); return response.getName(); }
java
public String getName() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { AgentInfo agentInfo = new AgentInfo(); agentInfo.setType(IQ.Type.get); agentInfo.setTo(workgroupJID); agentInfo.setFrom(getUser()); AgentInfo response = connection.createStanzaCollectorAndSend(agentInfo).nextResultOrThrow(); return response.getName(); }
[ "public", "String", "getName", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "AgentInfo", "agentInfo", "=", "new", "AgentInfo", "(", ")", ";", "agentInfo", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "agentInfo", ".", "setTo", "(", "workgroupJID", ")", ";", "agentInfo", ".", "setFrom", "(", "getUser", "(", ")", ")", ";", "AgentInfo", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "agentInfo", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "response", ".", "getName", "(", ")", ";", "}" ]
Return the agents name. @return - the agents name. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Return", "the", "agents", "name", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Agent.java#L76-L83
26,954
igniterealtime/Smack
smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Agent.java
Agent.setName
public void setName(String newName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { AgentInfo agentInfo = new AgentInfo(); agentInfo.setType(IQ.Type.set); agentInfo.setTo(workgroupJID); agentInfo.setFrom(getUser()); agentInfo.setName(newName); connection.createStanzaCollectorAndSend(agentInfo).nextResultOrThrow(); }
java
public void setName(String newName) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { AgentInfo agentInfo = new AgentInfo(); agentInfo.setType(IQ.Type.set); agentInfo.setTo(workgroupJID); agentInfo.setFrom(getUser()); agentInfo.setName(newName); connection.createStanzaCollectorAndSend(agentInfo).nextResultOrThrow(); }
[ "public", "void", "setName", "(", "String", "newName", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "AgentInfo", "agentInfo", "=", "new", "AgentInfo", "(", ")", ";", "agentInfo", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "agentInfo", ".", "setTo", "(", "workgroupJID", ")", ";", "agentInfo", ".", "setFrom", "(", "getUser", "(", ")", ")", ";", "agentInfo", ".", "setName", "(", "newName", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "agentInfo", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Changes the name of the agent in the server. The server may have this functionality disabled for all the agents or for this agent in particular. If the agent is not allowed to change his name then an exception will be thrown with a service_unavailable error code. @param newName the new name of the agent. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Changes", "the", "name", "of", "the", "agent", "in", "the", "server", ".", "The", "server", "may", "have", "this", "functionality", "disabled", "for", "all", "the", "agents", "or", "for", "this", "agent", "in", "particular", ".", "If", "the", "agent", "is", "not", "allowed", "to", "change", "his", "name", "then", "an", "exception", "will", "be", "thrown", "with", "a", "service_unavailable", "error", "code", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/Agent.java#L97-L104
26,955
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java
JivePropertiesExtension.setProperty
public synchronized void setProperty(String name, Object value) { if (!(value instanceof Serializable)) { throw new IllegalArgumentException("Value must be serializable"); } properties.put(name, value); }
java
public synchronized void setProperty(String name, Object value) { if (!(value instanceof Serializable)) { throw new IllegalArgumentException("Value must be serializable"); } properties.put(name, value); }
[ "public", "synchronized", "void", "setProperty", "(", "String", "name", ",", "Object", "value", ")", "{", "if", "(", "!", "(", "value", "instanceof", "Serializable", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Value must be serializable\"", ")", ";", "}", "properties", ".", "put", "(", "name", ",", "value", ")", ";", "}" ]
Sets a property with an Object as the value. The value must be Serializable or an IllegalArgumentException will be thrown. @param name the name of the property. @param value the value of the property.
[ "Sets", "a", "property", "with", "an", "Object", "as", "the", "value", ".", "The", "value", "must", "be", "Serializable", "or", "an", "IllegalArgumentException", "will", "be", "thrown", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java#L85-L90
26,956
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java
JivePropertiesExtension.getPropertyNames
public synchronized Collection<String> getPropertyNames() { if (properties == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(new HashSet<>(properties.keySet())); }
java
public synchronized Collection<String> getPropertyNames() { if (properties == null) { return Collections.emptySet(); } return Collections.unmodifiableSet(new HashSet<>(properties.keySet())); }
[ "public", "synchronized", "Collection", "<", "String", ">", "getPropertyNames", "(", ")", "{", "if", "(", "properties", "==", "null", ")", "{", "return", "Collections", ".", "emptySet", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableSet", "(", "new", "HashSet", "<>", "(", "properties", ".", "keySet", "(", ")", ")", ")", ";", "}" ]
Returns an unmodifiable collection of all the property names that are set. @return all property names.
[ "Returns", "an", "unmodifiable", "collection", "of", "all", "the", "property", "names", "that", "are", "set", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java#L109-L114
26,957
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java
JivePropertiesExtension.getProperties
public synchronized Map<String, Object> getProperties() { if (properties == null) { return Collections.emptyMap(); } return Collections.unmodifiableMap(new HashMap<>(properties)); }
java
public synchronized Map<String, Object> getProperties() { if (properties == null) { return Collections.emptyMap(); } return Collections.unmodifiableMap(new HashMap<>(properties)); }
[ "public", "synchronized", "Map", "<", "String", ",", "Object", ">", "getProperties", "(", ")", "{", "if", "(", "properties", "==", "null", ")", "{", "return", "Collections", ".", "emptyMap", "(", ")", ";", "}", "return", "Collections", ".", "unmodifiableMap", "(", "new", "HashMap", "<>", "(", "properties", ")", ")", ";", "}" ]
Returns an unmodifiable map of all properties. @return all properties.
[ "Returns", "an", "unmodifiable", "map", "of", "all", "properties", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java#L121-L126
26,958
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/OctTreeQuantizer.java
OctTreeQuantizer.addPixels
@Override public void addPixels(int[] pixels, int offset, int count) { for (int i = 0; i < count; i++) { insertColor(pixels[i + offset]); if (colors > reduceColors) reduceTree(reduceColors); } }
java
@Override public void addPixels(int[] pixels, int offset, int count) { for (int i = 0; i < count; i++) { insertColor(pixels[i + offset]); if (colors > reduceColors) reduceTree(reduceColors); } }
[ "@", "Override", "public", "void", "addPixels", "(", "int", "[", "]", "pixels", ",", "int", "offset", ",", "int", "count", ")", "{", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "insertColor", "(", "pixels", "[", "i", "+", "offset", "]", ")", ";", "if", "(", "colors", ">", "reduceColors", ")", "reduceTree", "(", "reduceColors", ")", ";", "}", "}" ]
Add pixels to the quantizer. @param pixels the array of ARGB pixels @param offset the offset into the array @param count the count of pixels
[ "Add", "pixels", "to", "the", "quantizer", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/OctTreeQuantizer.java#L102-L109
26,959
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/OctTreeQuantizer.java
OctTreeQuantizer.buildColorTable
public void buildColorTable(int[] inPixels, int[] table) { int count = inPixels.length; maximumColors = table.length; for (int i = 0; i < count; i++) { insertColor(inPixels[i]); if (colors > reduceColors) reduceTree(reduceColors); } if (colors > maximumColors) reduceTree(maximumColors); buildColorTable(root, table, 0); }
java
public void buildColorTable(int[] inPixels, int[] table) { int count = inPixels.length; maximumColors = table.length; for (int i = 0; i < count; i++) { insertColor(inPixels[i]); if (colors > reduceColors) reduceTree(reduceColors); } if (colors > maximumColors) reduceTree(maximumColors); buildColorTable(root, table, 0); }
[ "public", "void", "buildColorTable", "(", "int", "[", "]", "inPixels", ",", "int", "[", "]", "table", ")", "{", "int", "count", "=", "inPixels", ".", "length", ";", "maximumColors", "=", "table", ".", "length", ";", "for", "(", "int", "i", "=", "0", ";", "i", "<", "count", ";", "i", "++", ")", "{", "insertColor", "(", "inPixels", "[", "i", "]", ")", ";", "if", "(", "colors", ">", "reduceColors", ")", "reduceTree", "(", "reduceColors", ")", ";", "}", "if", "(", "colors", ">", "maximumColors", ")", "reduceTree", "(", "maximumColors", ")", ";", "buildColorTable", "(", "root", ",", "table", ",", "0", ")", ";", "}" ]
A quick way to use the quantizer. Just create a table the right size and pass in the pixels. @param inPixels the input colors @param table the output color table
[ "A", "quick", "way", "to", "use", "the", "quantizer", ".", "Just", "create", "a", "table", "the", "right", "size", "and", "pass", "in", "the", "pixels", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/sshare/api/OctTreeQuantizer.java#L256-L267
26,960
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.enter
private Presence enter(MucEnterConfiguration conf) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException, NotAMucServiceException { final DomainBareJid mucService = room.asDomainBareJid(); if (!KNOWN_MUC_SERVICES.containsKey(mucService)) { if (multiUserChatManager.providesMucService(mucService)) { KNOWN_MUC_SERVICES.put(mucService, null); } else { throw new NotAMucServiceException(this); } } // We enter a room by sending a presence packet where the "to" // field is in the form "roomName@service/nickname" Presence joinPresence = conf.getJoinPresence(this); // Setup the messageListeners and presenceListeners *before* the join presence is send. connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter); StanzaFilter presenceFromRoomFilter = new AndFilter(fromRoomFilter, StanzaTypeFilter.PRESENCE, PossibleFromTypeFilter.ENTITY_FULL_JID); connection.addSyncStanzaListener(presenceListener, presenceFromRoomFilter); // @formatter:off connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter, MessageWithSubjectFilter.INSTANCE, new NotFilter(MessageTypeFilter.ERROR), // According to XEP-0045 § 8.1 "A message with a <subject/> and a <body/> or a <subject/> and a <thread/> is a // legitimate message, but it SHALL NOT be interpreted as a subject change." new NotFilter(MessageWithBodiesFilter.INSTANCE), new NotFilter(MessageWithThreadFilter.INSTANCE)) ); // @formatter:on connection.addSyncStanzaListener(declinesListener, new AndFilter(fromRoomFilter, DECLINE_FILTER)); connection.addStanzaInterceptor(presenceInterceptor, new AndFilter(ToMatchesFilter.create(room), StanzaTypeFilter.PRESENCE)); messageCollector = connection.createStanzaCollector(fromRoomGroupchatFilter); // Wait for a presence packet back from the server. // @formatter:off StanzaFilter responseFilter = new AndFilter(StanzaTypeFilter.PRESENCE, new OrFilter( // We use a bare JID filter for positive responses, since the MUC service/room may rewrite the nickname. new AndFilter(FromMatchesFilter.createBare(getRoom()), MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF), // In case there is an error reply, we match on an error presence with the same stanza id and from the full // JID we send the join presence to. new AndFilter(FromMatchesFilter.createFull(joinPresence.getTo()), new StanzaIdFilter(joinPresence), PresenceTypeFilter.ERROR) ) ); // @formatter:on StanzaCollector presenceStanzaCollector = null; Presence presence; try { // This stanza collector will collect the final self presence from the MUC, which also signals that we have successful entered the MUC. StanzaCollector selfPresenceCollector = connection.createStanzaCollectorAndSend(responseFilter, joinPresence); StanzaCollector.Configuration presenceStanzaCollectorConfguration = StanzaCollector.newConfiguration().setCollectorToReset( selfPresenceCollector).setStanzaFilter(presenceFromRoomFilter); // This stanza collector is used to reset the timeout of the selfPresenceCollector. presenceStanzaCollector = connection.createStanzaCollector(presenceStanzaCollectorConfguration); presence = selfPresenceCollector.nextResultOrThrow(conf.getTimeout()); } catch (NotConnectedException | InterruptedException | NoResponseException | XMPPErrorException e) { // Ensure that all callbacks are removed if there is an exception removeConnectionCallbacks(); throw e; } finally { if (presenceStanzaCollector != null) { presenceStanzaCollector.cancel(); } } // This presence must be send from a full JID. We use the resourcepart of this JID as nick, since the room may // performed roomnick rewriting Resourcepart receivedNickname = presence.getFrom().getResourceOrThrow(); setNickname(receivedNickname); joined = true; // Update the list of joined rooms multiUserChatManager.addJoinedRoom(room); return presence; }
java
private Presence enter(MucEnterConfiguration conf) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException, NotAMucServiceException { final DomainBareJid mucService = room.asDomainBareJid(); if (!KNOWN_MUC_SERVICES.containsKey(mucService)) { if (multiUserChatManager.providesMucService(mucService)) { KNOWN_MUC_SERVICES.put(mucService, null); } else { throw new NotAMucServiceException(this); } } // We enter a room by sending a presence packet where the "to" // field is in the form "roomName@service/nickname" Presence joinPresence = conf.getJoinPresence(this); // Setup the messageListeners and presenceListeners *before* the join presence is send. connection.addSyncStanzaListener(messageListener, fromRoomGroupchatFilter); StanzaFilter presenceFromRoomFilter = new AndFilter(fromRoomFilter, StanzaTypeFilter.PRESENCE, PossibleFromTypeFilter.ENTITY_FULL_JID); connection.addSyncStanzaListener(presenceListener, presenceFromRoomFilter); // @formatter:off connection.addSyncStanzaListener(subjectListener, new AndFilter(fromRoomFilter, MessageWithSubjectFilter.INSTANCE, new NotFilter(MessageTypeFilter.ERROR), // According to XEP-0045 § 8.1 "A message with a <subject/> and a <body/> or a <subject/> and a <thread/> is a // legitimate message, but it SHALL NOT be interpreted as a subject change." new NotFilter(MessageWithBodiesFilter.INSTANCE), new NotFilter(MessageWithThreadFilter.INSTANCE)) ); // @formatter:on connection.addSyncStanzaListener(declinesListener, new AndFilter(fromRoomFilter, DECLINE_FILTER)); connection.addStanzaInterceptor(presenceInterceptor, new AndFilter(ToMatchesFilter.create(room), StanzaTypeFilter.PRESENCE)); messageCollector = connection.createStanzaCollector(fromRoomGroupchatFilter); // Wait for a presence packet back from the server. // @formatter:off StanzaFilter responseFilter = new AndFilter(StanzaTypeFilter.PRESENCE, new OrFilter( // We use a bare JID filter for positive responses, since the MUC service/room may rewrite the nickname. new AndFilter(FromMatchesFilter.createBare(getRoom()), MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF), // In case there is an error reply, we match on an error presence with the same stanza id and from the full // JID we send the join presence to. new AndFilter(FromMatchesFilter.createFull(joinPresence.getTo()), new StanzaIdFilter(joinPresence), PresenceTypeFilter.ERROR) ) ); // @formatter:on StanzaCollector presenceStanzaCollector = null; Presence presence; try { // This stanza collector will collect the final self presence from the MUC, which also signals that we have successful entered the MUC. StanzaCollector selfPresenceCollector = connection.createStanzaCollectorAndSend(responseFilter, joinPresence); StanzaCollector.Configuration presenceStanzaCollectorConfguration = StanzaCollector.newConfiguration().setCollectorToReset( selfPresenceCollector).setStanzaFilter(presenceFromRoomFilter); // This stanza collector is used to reset the timeout of the selfPresenceCollector. presenceStanzaCollector = connection.createStanzaCollector(presenceStanzaCollectorConfguration); presence = selfPresenceCollector.nextResultOrThrow(conf.getTimeout()); } catch (NotConnectedException | InterruptedException | NoResponseException | XMPPErrorException e) { // Ensure that all callbacks are removed if there is an exception removeConnectionCallbacks(); throw e; } finally { if (presenceStanzaCollector != null) { presenceStanzaCollector.cancel(); } } // This presence must be send from a full JID. We use the resourcepart of this JID as nick, since the room may // performed roomnick rewriting Resourcepart receivedNickname = presence.getFrom().getResourceOrThrow(); setNickname(receivedNickname); joined = true; // Update the list of joined rooms multiUserChatManager.addJoinedRoom(room); return presence; }
[ "private", "Presence", "enter", "(", "MucEnterConfiguration", "conf", ")", "throws", "NotConnectedException", ",", "NoResponseException", ",", "XMPPErrorException", ",", "InterruptedException", ",", "NotAMucServiceException", "{", "final", "DomainBareJid", "mucService", "=", "room", ".", "asDomainBareJid", "(", ")", ";", "if", "(", "!", "KNOWN_MUC_SERVICES", ".", "containsKey", "(", "mucService", ")", ")", "{", "if", "(", "multiUserChatManager", ".", "providesMucService", "(", "mucService", ")", ")", "{", "KNOWN_MUC_SERVICES", ".", "put", "(", "mucService", ",", "null", ")", ";", "}", "else", "{", "throw", "new", "NotAMucServiceException", "(", "this", ")", ";", "}", "}", "// We enter a room by sending a presence packet where the \"to\"", "// field is in the form \"roomName@service/nickname\"", "Presence", "joinPresence", "=", "conf", ".", "getJoinPresence", "(", "this", ")", ";", "// Setup the messageListeners and presenceListeners *before* the join presence is send.", "connection", ".", "addSyncStanzaListener", "(", "messageListener", ",", "fromRoomGroupchatFilter", ")", ";", "StanzaFilter", "presenceFromRoomFilter", "=", "new", "AndFilter", "(", "fromRoomFilter", ",", "StanzaTypeFilter", ".", "PRESENCE", ",", "PossibleFromTypeFilter", ".", "ENTITY_FULL_JID", ")", ";", "connection", ".", "addSyncStanzaListener", "(", "presenceListener", ",", "presenceFromRoomFilter", ")", ";", "// @formatter:off", "connection", ".", "addSyncStanzaListener", "(", "subjectListener", ",", "new", "AndFilter", "(", "fromRoomFilter", ",", "MessageWithSubjectFilter", ".", "INSTANCE", ",", "new", "NotFilter", "(", "MessageTypeFilter", ".", "ERROR", ")", ",", "// According to XEP-0045 § 8.1 \"A message with a <subject/> and a <body/> or a <subject/> and a <thread/> is a", "// legitimate message, but it SHALL NOT be interpreted as a subject change.\"", "new", "NotFilter", "(", "MessageWithBodiesFilter", ".", "INSTANCE", ")", ",", "new", "NotFilter", "(", "MessageWithThreadFilter", ".", "INSTANCE", ")", ")", ")", ";", "// @formatter:on", "connection", ".", "addSyncStanzaListener", "(", "declinesListener", ",", "new", "AndFilter", "(", "fromRoomFilter", ",", "DECLINE_FILTER", ")", ")", ";", "connection", ".", "addStanzaInterceptor", "(", "presenceInterceptor", ",", "new", "AndFilter", "(", "ToMatchesFilter", ".", "create", "(", "room", ")", ",", "StanzaTypeFilter", ".", "PRESENCE", ")", ")", ";", "messageCollector", "=", "connection", ".", "createStanzaCollector", "(", "fromRoomGroupchatFilter", ")", ";", "// Wait for a presence packet back from the server.", "// @formatter:off", "StanzaFilter", "responseFilter", "=", "new", "AndFilter", "(", "StanzaTypeFilter", ".", "PRESENCE", ",", "new", "OrFilter", "(", "// We use a bare JID filter for positive responses, since the MUC service/room may rewrite the nickname.", "new", "AndFilter", "(", "FromMatchesFilter", ".", "createBare", "(", "getRoom", "(", ")", ")", ",", "MUCUserStatusCodeFilter", ".", "STATUS_110_PRESENCE_TO_SELF", ")", ",", "// In case there is an error reply, we match on an error presence with the same stanza id and from the full", "// JID we send the join presence to.", "new", "AndFilter", "(", "FromMatchesFilter", ".", "createFull", "(", "joinPresence", ".", "getTo", "(", ")", ")", ",", "new", "StanzaIdFilter", "(", "joinPresence", ")", ",", "PresenceTypeFilter", ".", "ERROR", ")", ")", ")", ";", "// @formatter:on", "StanzaCollector", "presenceStanzaCollector", "=", "null", ";", "Presence", "presence", ";", "try", "{", "// This stanza collector will collect the final self presence from the MUC, which also signals that we have successful entered the MUC.", "StanzaCollector", "selfPresenceCollector", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "responseFilter", ",", "joinPresence", ")", ";", "StanzaCollector", ".", "Configuration", "presenceStanzaCollectorConfguration", "=", "StanzaCollector", ".", "newConfiguration", "(", ")", ".", "setCollectorToReset", "(", "selfPresenceCollector", ")", ".", "setStanzaFilter", "(", "presenceFromRoomFilter", ")", ";", "// This stanza collector is used to reset the timeout of the selfPresenceCollector.", "presenceStanzaCollector", "=", "connection", ".", "createStanzaCollector", "(", "presenceStanzaCollectorConfguration", ")", ";", "presence", "=", "selfPresenceCollector", ".", "nextResultOrThrow", "(", "conf", ".", "getTimeout", "(", ")", ")", ";", "}", "catch", "(", "NotConnectedException", "|", "InterruptedException", "|", "NoResponseException", "|", "XMPPErrorException", "e", ")", "{", "// Ensure that all callbacks are removed if there is an exception", "removeConnectionCallbacks", "(", ")", ";", "throw", "e", ";", "}", "finally", "{", "if", "(", "presenceStanzaCollector", "!=", "null", ")", "{", "presenceStanzaCollector", ".", "cancel", "(", ")", ";", "}", "}", "// This presence must be send from a full JID. We use the resourcepart of this JID as nick, since the room may", "// performed roomnick rewriting", "Resourcepart", "receivedNickname", "=", "presence", ".", "getFrom", "(", ")", ".", "getResourceOrThrow", "(", ")", ";", "setNickname", "(", "receivedNickname", ")", ";", "joined", "=", "true", ";", "// Update the list of joined rooms", "multiUserChatManager", ".", "addJoinedRoom", "(", "room", ")", ";", "return", "presence", ";", "}" ]
Enter a room, as described in XEP-45 7.2. @param conf the configuration used to enter the room. @return the returned presence by the service after the client send the initial presence in order to enter the room. @throws NotConnectedException @throws NoResponseException @throws XMPPErrorException @throws InterruptedException @throws NotAMucServiceException @see <a href="http://xmpp.org/extensions/xep-0045.html#enter">XEP-45 7.2 Entering a Room</a>
[ "Enter", "a", "room", "as", "described", "in", "XEP", "-", "45", "7", ".", "2", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L328-L408
26,961
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.getEnterConfigurationBuilder
public MucEnterConfiguration.Builder getEnterConfigurationBuilder(Resourcepart nickname) { return new MucEnterConfiguration.Builder(nickname, connection.getReplyTimeout()); }
java
public MucEnterConfiguration.Builder getEnterConfigurationBuilder(Resourcepart nickname) { return new MucEnterConfiguration.Builder(nickname, connection.getReplyTimeout()); }
[ "public", "MucEnterConfiguration", ".", "Builder", "getEnterConfigurationBuilder", "(", "Resourcepart", "nickname", ")", "{", "return", "new", "MucEnterConfiguration", ".", "Builder", "(", "nickname", ",", "connection", ".", "getReplyTimeout", "(", ")", ")", ";", "}" ]
Get a new MUC enter configuration builder. @param nickname the nickname used when entering the MUC room. @return a new MUC enter configuration builder. @since 4.2
[ "Get", "a", "new", "MUC", "enter", "configuration", "builder", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L421-L423
26,962
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.createOrJoin
public synchronized MucCreateConfigFormHandle createOrJoin(Resourcepart nickname) throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException { MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder(nickname).build(); return createOrJoin(mucEnterConfiguration); }
java
public synchronized MucCreateConfigFormHandle createOrJoin(Resourcepart nickname) throws NoResponseException, XMPPErrorException, InterruptedException, MucAlreadyJoinedException, NotConnectedException, NotAMucServiceException { MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder(nickname).build(); return createOrJoin(mucEnterConfiguration); }
[ "public", "synchronized", "MucCreateConfigFormHandle", "createOrJoin", "(", "Resourcepart", "nickname", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "InterruptedException", ",", "MucAlreadyJoinedException", ",", "NotConnectedException", ",", "NotAMucServiceException", "{", "MucEnterConfiguration", "mucEnterConfiguration", "=", "getEnterConfigurationBuilder", "(", "nickname", ")", ".", "build", "(", ")", ";", "return", "createOrJoin", "(", "mucEnterConfiguration", ")", ";", "}" ]
Create or join the MUC room with the given nickname. @param nickname the nickname to use in the MUC room. @return A {@link MucCreateConfigFormHandle} if the room was created while joining, or {@code null} if the room was just joined. @throws NoResponseException @throws XMPPErrorException @throws InterruptedException @throws NotConnectedException @throws MucAlreadyJoinedException @throws NotAMucServiceException
[ "Create", "or", "join", "the", "MUC", "room", "with", "the", "given", "nickname", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L487-L491
26,963
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.createOrJoinIfNecessary
public MucCreateConfigFormHandle createOrJoinIfNecessary(Resourcepart nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException { if (isJoined()) { return null; } MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder(nickname).withPassword( password).build(); try { return createOrJoin(mucEnterConfiguration); } catch (MucAlreadyJoinedException e) { return null; } }
java
public MucCreateConfigFormHandle createOrJoinIfNecessary(Resourcepart nickname, String password) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException { if (isJoined()) { return null; } MucEnterConfiguration mucEnterConfiguration = getEnterConfigurationBuilder(nickname).withPassword( password).build(); try { return createOrJoin(mucEnterConfiguration); } catch (MucAlreadyJoinedException e) { return null; } }
[ "public", "MucCreateConfigFormHandle", "createOrJoinIfNecessary", "(", "Resourcepart", "nickname", ",", "String", "password", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", ",", "NotAMucServiceException", "{", "if", "(", "isJoined", "(", ")", ")", "{", "return", "null", ";", "}", "MucEnterConfiguration", "mucEnterConfiguration", "=", "getEnterConfigurationBuilder", "(", "nickname", ")", ".", "withPassword", "(", "password", ")", ".", "build", "(", ")", ";", "try", "{", "return", "createOrJoin", "(", "mucEnterConfiguration", ")", ";", "}", "catch", "(", "MucAlreadyJoinedException", "e", ")", "{", "return", "null", ";", "}", "}" ]
Create or join a MUC if it is necessary, i.e. if not the MUC is not already joined. @param nickname the required nickname to use. @param password the optional password required to join @return A {@link MucCreateConfigFormHandle} if the room was created while joining, or {@code null} if the room was just joined. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @throws NotAMucServiceException
[ "Create", "or", "join", "a", "MUC", "if", "it", "is", "necessary", "i", ".", "e", ".", "if", "not", "the", "MUC", "is", "not", "already", "joined", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L582-L595
26,964
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.join
public void join(Resourcepart nickname) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException { MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname); join(builder.build()); }
java
public void join(Resourcepart nickname) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotAMucServiceException { MucEnterConfiguration.Builder builder = getEnterConfigurationBuilder(nickname); join(builder.build()); }
[ "public", "void", "join", "(", "Resourcepart", "nickname", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", ",", "NotAMucServiceException", "{", "MucEnterConfiguration", ".", "Builder", "builder", "=", "getEnterConfigurationBuilder", "(", "nickname", ")", ";", "join", "(", "builder", ".", "build", "(", ")", ")", ";", "}" ]
Joins the chat room using the specified nickname. If already joined using another nickname, this method will first leave the room and then re-join using the new nickname. The default connection timeout for a reply from the group chat server that the join succeeded will be used. After joining the room, the room will decide the amount of history to send. @param nickname the nickname to use. @throws NoResponseException @throws XMPPErrorException if an error occurs joining the room. In particular, a 401 error can occur if no password was provided and one is required; or a 403 error can occur if the user is banned; or a 404 error can occur if the room does not exist or is locked; or a 407 error can occur if user is not on the member list; or a 409 error can occur if someone is already in the group chat with the same nickname. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException @throws NotAMucServiceException
[ "Joins", "the", "chat", "room", "using", "the", "specified", "nickname", ".", "If", "already", "joined", "using", "another", "nickname", "this", "method", "will", "first", "leave", "the", "room", "and", "then", "re", "-", "join", "using", "the", "new", "nickname", ".", "The", "default", "connection", "timeout", "for", "a", "reply", "from", "the", "group", "chat", "server", "that", "the", "join", "succeeded", "will", "be", "used", ".", "After", "joining", "the", "room", "the", "room", "will", "decide", "the", "amount", "of", "history", "to", "send", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L617-L621
26,965
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.leave
public synchronized Presence leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException, MucNotJoinedException { // Note that this method is intentionally not guarded by // "if (!joined) return" because it should be always be possible to leave the room in case the instance's // state does not reflect the actual state. // Reset occupant information first so that we are assume that we left the room even if sendStanza() would // throw. userHasLeft(); final EntityFullJid myRoomJid = this.myRoomJid; if (myRoomJid == null) { throw new MucNotJoinedException(this); } // We leave a room by sending a presence packet where the "to" // field is in the form "roomName@service/nickname" Presence leavePresence = new Presence(Presence.Type.unavailable); leavePresence.setTo(myRoomJid); StanzaFilter reflectedLeavePresenceFilter = new AndFilter( StanzaTypeFilter.PRESENCE, new StanzaIdFilter(leavePresence), new OrFilter( new AndFilter(FromMatchesFilter.createFull(myRoomJid), PresenceTypeFilter.UNAVAILABLE, MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF), new AndFilter(fromRoomFilter, PresenceTypeFilter.ERROR) ) ); Presence reflectedLeavePresence = connection.createStanzaCollectorAndSend(reflectedLeavePresenceFilter, leavePresence).nextResultOrThrow(); return reflectedLeavePresence; }
java
public synchronized Presence leave() throws NotConnectedException, InterruptedException, NoResponseException, XMPPErrorException, MucNotJoinedException { // Note that this method is intentionally not guarded by // "if (!joined) return" because it should be always be possible to leave the room in case the instance's // state does not reflect the actual state. // Reset occupant information first so that we are assume that we left the room even if sendStanza() would // throw. userHasLeft(); final EntityFullJid myRoomJid = this.myRoomJid; if (myRoomJid == null) { throw new MucNotJoinedException(this); } // We leave a room by sending a presence packet where the "to" // field is in the form "roomName@service/nickname" Presence leavePresence = new Presence(Presence.Type.unavailable); leavePresence.setTo(myRoomJid); StanzaFilter reflectedLeavePresenceFilter = new AndFilter( StanzaTypeFilter.PRESENCE, new StanzaIdFilter(leavePresence), new OrFilter( new AndFilter(FromMatchesFilter.createFull(myRoomJid), PresenceTypeFilter.UNAVAILABLE, MUCUserStatusCodeFilter.STATUS_110_PRESENCE_TO_SELF), new AndFilter(fromRoomFilter, PresenceTypeFilter.ERROR) ) ); Presence reflectedLeavePresence = connection.createStanzaCollectorAndSend(reflectedLeavePresenceFilter, leavePresence).nextResultOrThrow(); return reflectedLeavePresence; }
[ "public", "synchronized", "Presence", "leave", "(", ")", "throws", "NotConnectedException", ",", "InterruptedException", ",", "NoResponseException", ",", "XMPPErrorException", ",", "MucNotJoinedException", "{", "// Note that this method is intentionally not guarded by", "// \"if (!joined) return\" because it should be always be possible to leave the room in case the instance's", "// state does not reflect the actual state.", "// Reset occupant information first so that we are assume that we left the room even if sendStanza() would", "// throw.", "userHasLeft", "(", ")", ";", "final", "EntityFullJid", "myRoomJid", "=", "this", ".", "myRoomJid", ";", "if", "(", "myRoomJid", "==", "null", ")", "{", "throw", "new", "MucNotJoinedException", "(", "this", ")", ";", "}", "// We leave a room by sending a presence packet where the \"to\"", "// field is in the form \"roomName@service/nickname\"", "Presence", "leavePresence", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "leavePresence", ".", "setTo", "(", "myRoomJid", ")", ";", "StanzaFilter", "reflectedLeavePresenceFilter", "=", "new", "AndFilter", "(", "StanzaTypeFilter", ".", "PRESENCE", ",", "new", "StanzaIdFilter", "(", "leavePresence", ")", ",", "new", "OrFilter", "(", "new", "AndFilter", "(", "FromMatchesFilter", ".", "createFull", "(", "myRoomJid", ")", ",", "PresenceTypeFilter", ".", "UNAVAILABLE", ",", "MUCUserStatusCodeFilter", ".", "STATUS_110_PRESENCE_TO_SELF", ")", ",", "new", "AndFilter", "(", "fromRoomFilter", ",", "PresenceTypeFilter", ".", "ERROR", ")", ")", ")", ";", "Presence", "reflectedLeavePresence", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "reflectedLeavePresenceFilter", ",", "leavePresence", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "reflectedLeavePresence", ";", "}" ]
Leave the chat room. @return the leave presence as reflected by the MUC. @throws NotConnectedException @throws InterruptedException @throws XMPPErrorException @throws NoResponseException @throws MucNotJoinedException
[ "Leave", "the", "chat", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L730-L762
26,966
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.sendConfigurationForm
public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCOwner iq = new MUCOwner(); iq.setTo(room); iq.setType(IQ.Type.set); iq.addExtension(form.getDataFormToSend()); connection.createStanzaCollectorAndSend(iq).nextResultOrThrow(); }
java
public void sendConfigurationForm(Form form) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCOwner iq = new MUCOwner(); iq.setTo(room); iq.setType(IQ.Type.set); iq.addExtension(form.getDataFormToSend()); connection.createStanzaCollectorAndSend(iq).nextResultOrThrow(); }
[ "public", "void", "sendConfigurationForm", "(", "Form", "form", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCOwner", "iq", "=", "new", "MUCOwner", "(", ")", ";", "iq", ".", "setTo", "(", "room", ")", ";", "iq", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "iq", ".", "addExtension", "(", "form", ".", "getDataFormToSend", "(", ")", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "iq", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Sends the completed configuration form to the server. The room will be configured with the new settings defined in the form. @param form the form with the new settings. @throws XMPPErrorException if an error occurs setting the new rooms' configuration. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Sends", "the", "completed", "configuration", "form", "to", "the", "server", ".", "The", "room", "will", "be", "configured", "with", "the", "new", "settings", "defined", "in", "the", "form", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L814-L821
26,967
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.fireInvitationRejectionListeners
private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) { EntityBareJid invitee = rejection.getFrom(); String reason = rejection.getReason(); InvitationRejectionListener[] listeners; synchronized (invitationRejectionListeners) { listeners = new InvitationRejectionListener[invitationRejectionListeners.size()]; invitationRejectionListeners.toArray(listeners); } for (InvitationRejectionListener listener : listeners) { listener.invitationDeclined(invitee, reason, message, rejection); } }
java
private void fireInvitationRejectionListeners(Message message, MUCUser.Decline rejection) { EntityBareJid invitee = rejection.getFrom(); String reason = rejection.getReason(); InvitationRejectionListener[] listeners; synchronized (invitationRejectionListeners) { listeners = new InvitationRejectionListener[invitationRejectionListeners.size()]; invitationRejectionListeners.toArray(listeners); } for (InvitationRejectionListener listener : listeners) { listener.invitationDeclined(invitee, reason, message, rejection); } }
[ "private", "void", "fireInvitationRejectionListeners", "(", "Message", "message", ",", "MUCUser", ".", "Decline", "rejection", ")", "{", "EntityBareJid", "invitee", "=", "rejection", ".", "getFrom", "(", ")", ";", "String", "reason", "=", "rejection", ".", "getReason", "(", ")", ";", "InvitationRejectionListener", "[", "]", "listeners", ";", "synchronized", "(", "invitationRejectionListeners", ")", "{", "listeners", "=", "new", "InvitationRejectionListener", "[", "invitationRejectionListeners", ".", "size", "(", ")", "]", ";", "invitationRejectionListeners", ".", "toArray", "(", "listeners", ")", ";", "}", "for", "(", "InvitationRejectionListener", "listener", ":", "listeners", ")", "{", "listener", ".", "invitationDeclined", "(", "invitee", ",", "reason", ",", "message", ",", "rejection", ")", ";", "}", "}" ]
Fires invitation rejection listeners. @param invitee the user being invited. @param reason the reason for the rejection
[ "Fires", "invitation", "rejection", "listeners", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L988-L999
26,968
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.getReservedNickname
public String getReservedNickname() throws SmackException, InterruptedException { try { DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo( room, "x-roomuser-item"); // Look for an Identity that holds the reserved nickname and return its name for (DiscoverInfo.Identity identity : result.getIdentities()) { return identity.getName(); } } catch (XMPPException e) { LOGGER.log(Level.SEVERE, "Error retrieving room nickname", e); } // If no Identity was found then the user does not have a reserved room nickname return null; }
java
public String getReservedNickname() throws SmackException, InterruptedException { try { DiscoverInfo result = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo( room, "x-roomuser-item"); // Look for an Identity that holds the reserved nickname and return its name for (DiscoverInfo.Identity identity : result.getIdentities()) { return identity.getName(); } } catch (XMPPException e) { LOGGER.log(Level.SEVERE, "Error retrieving room nickname", e); } // If no Identity was found then the user does not have a reserved room nickname return null; }
[ "public", "String", "getReservedNickname", "(", ")", "throws", "SmackException", ",", "InterruptedException", "{", "try", "{", "DiscoverInfo", "result", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ".", "discoverInfo", "(", "room", ",", "\"x-roomuser-item\"", ")", ";", "// Look for an Identity that holds the reserved nickname and return its name", "for", "(", "DiscoverInfo", ".", "Identity", "identity", ":", "result", ".", "getIdentities", "(", ")", ")", "{", "return", "identity", ".", "getName", "(", ")", ";", "}", "}", "catch", "(", "XMPPException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Error retrieving room nickname\"", ",", "e", ")", ";", "}", "// If no Identity was found then the user does not have a reserved room nickname", "return", "null", ";", "}" ]
Returns the reserved room nickname for the user in the room. A user may have a reserved nickname, for example through explicit room registration or database integration. In such cases it may be desirable for the user to discover the reserved nickname before attempting to enter the room. @return the reserved room nickname or <tt>null</tt> if none. @throws SmackException if there was no response from the server. @throws InterruptedException
[ "Returns", "the", "reserved", "room", "nickname", "for", "the", "user", "in", "the", "room", ".", "A", "user", "may", "have", "a", "reserved", "nickname", "for", "example", "through", "explicit", "room", "registration", "or", "database", "integration", ".", "In", "such", "cases", "it", "may", "be", "desirable", "for", "the", "user", "to", "discover", "the", "reserved", "nickname", "before", "attempting", "to", "enter", "the", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1072-L1088
26,969
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.requestVoice
public void requestVoice() throws NotConnectedException, InterruptedException { DataForm form = new DataForm(DataForm.Type.submit); FormField formTypeField = new FormField(FormField.FORM_TYPE); formTypeField.addValue(MUCInitialPresence.NAMESPACE + "#request"); form.addField(formTypeField); FormField requestVoiceField = new FormField("muc#role"); requestVoiceField.setType(FormField.Type.text_single); requestVoiceField.setLabel("Requested role"); requestVoiceField.addValue("participant"); form.addField(requestVoiceField); Message message = new Message(room); message.addExtension(form); connection.sendStanza(message); }
java
public void requestVoice() throws NotConnectedException, InterruptedException { DataForm form = new DataForm(DataForm.Type.submit); FormField formTypeField = new FormField(FormField.FORM_TYPE); formTypeField.addValue(MUCInitialPresence.NAMESPACE + "#request"); form.addField(formTypeField); FormField requestVoiceField = new FormField("muc#role"); requestVoiceField.setType(FormField.Type.text_single); requestVoiceField.setLabel("Requested role"); requestVoiceField.addValue("participant"); form.addField(requestVoiceField); Message message = new Message(room); message.addExtension(form); connection.sendStanza(message); }
[ "public", "void", "requestVoice", "(", ")", "throws", "NotConnectedException", ",", "InterruptedException", "{", "DataForm", "form", "=", "new", "DataForm", "(", "DataForm", ".", "Type", ".", "submit", ")", ";", "FormField", "formTypeField", "=", "new", "FormField", "(", "FormField", ".", "FORM_TYPE", ")", ";", "formTypeField", ".", "addValue", "(", "MUCInitialPresence", ".", "NAMESPACE", "+", "\"#request\"", ")", ";", "form", ".", "addField", "(", "formTypeField", ")", ";", "FormField", "requestVoiceField", "=", "new", "FormField", "(", "\"muc#role\"", ")", ";", "requestVoiceField", ".", "setType", "(", "FormField", ".", "Type", ".", "text_single", ")", ";", "requestVoiceField", ".", "setLabel", "(", "\"Requested role\"", ")", ";", "requestVoiceField", ".", "addValue", "(", "\"participant\"", ")", ";", "form", ".", "addField", "(", "requestVoiceField", ")", ";", "Message", "message", "=", "new", "Message", "(", "room", ")", ";", "message", ".", "addExtension", "(", "form", ")", ";", "connection", ".", "sendStanza", "(", "message", ")", ";", "}" ]
Sends a voice request to the MUC. The room moderators usually need to approve this request. @throws NotConnectedException @throws InterruptedException @see <a href="http://xmpp.org/extensions/xep-0045.html#requestvoice">XEP-45 § 7.13 Requesting Voice</a> @since 4.1
[ "Sends", "a", "voice", "request", "to", "the", "MUC", ".", "The", "room", "moderators", "usually", "need", "to", "approve", "this", "request", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1213-L1226
26,970
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantVoice
public void grantVoice(Collection<Resourcepart> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nicknames, MUCRole.participant); }
java
public void grantVoice(Collection<Resourcepart> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nicknames, MUCRole.participant); }
[ "public", "void", "grantVoice", "(", "Collection", "<", "Resourcepart", ">", "nicknames", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeRole", "(", "nicknames", ",", "MUCRole", ".", "participant", ")", ";", "}" ]
Grants voice to visitors in the room. In a moderated room, a moderator may want to manage who does and does not have "voice" in the room. To have voice means that a room occupant is able to send messages to the room occupants. @param nicknames the nicknames of the visitors to grant voice in the room (e.g. "john"). @throws XMPPErrorException if an error occurs granting voice to a visitor. In particular, a 403 error can occur if the occupant that intended to grant voice is not a moderator in this room (i.e. Forbidden error); or a 400 error can occur if the provided nickname is not present in the room. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "voice", "to", "visitors", "in", "the", "room", ".", "In", "a", "moderated", "room", "a", "moderator", "may", "want", "to", "manage", "who", "does", "and", "does", "not", "have", "voice", "in", "the", "room", ".", "To", "have", "voice", "means", "that", "a", "room", "occupant", "is", "able", "to", "send", "messages", "to", "the", "room", "occupants", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1242-L1244
26,971
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantVoice
public void grantVoice(Resourcepart nickname) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nickname, MUCRole.participant, null); }
java
public void grantVoice(Resourcepart nickname) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nickname, MUCRole.participant, null); }
[ "public", "void", "grantVoice", "(", "Resourcepart", "nickname", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeRole", "(", "nickname", ",", "MUCRole", ".", "participant", ",", "null", ")", ";", "}" ]
Grants voice to a visitor in the room. In a moderated room, a moderator may want to manage who does and does not have "voice" in the room. To have voice means that a room occupant is able to send messages to the room occupants. @param nickname the nickname of the visitor to grant voice in the room (e.g. "john"). @throws XMPPErrorException if an error occurs granting voice to a visitor. In particular, a 403 error can occur if the occupant that intended to grant voice is not a moderator in this room (i.e. Forbidden error); or a 400 error can occur if the provided nickname is not present in the room. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "voice", "to", "a", "visitor", "in", "the", "room", ".", "In", "a", "moderated", "room", "a", "moderator", "may", "want", "to", "manage", "who", "does", "and", "does", "not", "have", "voice", "in", "the", "room", ".", "To", "have", "voice", "means", "that", "a", "room", "occupant", "is", "able", "to", "send", "messages", "to", "the", "room", "occupants", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1260-L1262
26,972
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.revokeVoice
public void revokeVoice(Collection<Resourcepart> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nicknames, MUCRole.visitor); }
java
public void revokeVoice(Collection<Resourcepart> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nicknames, MUCRole.visitor); }
[ "public", "void", "revokeVoice", "(", "Collection", "<", "Resourcepart", ">", "nicknames", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeRole", "(", "nicknames", ",", "MUCRole", ".", "visitor", ")", ";", "}" ]
Revokes voice from participants in the room. In a moderated room, a moderator may want to revoke an occupant's privileges to speak. To have voice means that a room occupant is able to send messages to the room occupants. @param nicknames the nicknames of the participants to revoke voice (e.g. "john"). @throws XMPPErrorException if an error occurs revoking voice from a participant. In particular, a 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin" was tried to revoke his voice (i.e. Not Allowed error); or a 400 error can occur if the provided nickname is not present in the room. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Revokes", "voice", "from", "participants", "in", "the", "room", ".", "In", "a", "moderated", "room", "a", "moderator", "may", "want", "to", "revoke", "an", "occupant", "s", "privileges", "to", "speak", ".", "To", "have", "voice", "means", "that", "a", "room", "occupant", "is", "able", "to", "send", "messages", "to", "the", "room", "occupants", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1278-L1280
26,973
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.revokeVoice
public void revokeVoice(Resourcepart nickname) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nickname, MUCRole.visitor, null); }
java
public void revokeVoice(Resourcepart nickname) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nickname, MUCRole.visitor, null); }
[ "public", "void", "revokeVoice", "(", "Resourcepart", "nickname", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeRole", "(", "nickname", ",", "MUCRole", ".", "visitor", ",", "null", ")", ";", "}" ]
Revokes voice from a participant in the room. In a moderated room, a moderator may want to revoke an occupant's privileges to speak. To have voice means that a room occupant is able to send messages to the room occupants. @param nickname the nickname of the participant to revoke voice (e.g. "john"). @throws XMPPErrorException if an error occurs revoking voice from a participant. In particular, a 405 error can occur if a moderator or a user with an affiliation of "owner" or "admin" was tried to revoke his voice (i.e. Not Allowed error); or a 400 error can occur if the provided nickname is not present in the room. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Revokes", "voice", "from", "a", "participant", "in", "the", "room", ".", "In", "a", "moderated", "room", "a", "moderator", "may", "want", "to", "revoke", "an", "occupant", "s", "privileges", "to", "speak", ".", "To", "have", "voice", "means", "that", "a", "room", "occupant", "is", "able", "to", "send", "messages", "to", "the", "room", "occupants", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1296-L1298
26,974
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantModerator
public void grantModerator(Collection<Resourcepart> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nicknames, MUCRole.moderator); }
java
public void grantModerator(Collection<Resourcepart> nicknames) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nicknames, MUCRole.moderator); }
[ "public", "void", "grantModerator", "(", "Collection", "<", "Resourcepart", ">", "nicknames", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeRole", "(", "nicknames", ",", "MUCRole", ".", "moderator", ")", ";", "}" ]
Grants moderator privileges to participants or visitors. Room administrators may grant moderator privileges. A moderator is allowed to kick users, grant and revoke voice, invite other users, modify room's subject plus all the partcipants privileges. @param nicknames the nicknames of the occupants to grant moderator privileges. @throws XMPPErrorException if an error occurs granting moderator privileges to a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "moderator", "privileges", "to", "participants", "or", "visitors", ".", "Room", "administrators", "may", "grant", "moderator", "privileges", ".", "A", "moderator", "is", "allowed", "to", "kick", "users", "grant", "and", "revoke", "voice", "invite", "other", "users", "modify", "room", "s", "subject", "plus", "all", "the", "partcipants", "privileges", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1412-L1414
26,975
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantModerator
public void grantModerator(Resourcepart nickname) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nickname, MUCRole.moderator, null); }
java
public void grantModerator(Resourcepart nickname) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeRole(nickname, MUCRole.moderator, null); }
[ "public", "void", "grantModerator", "(", "Resourcepart", "nickname", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeRole", "(", "nickname", ",", "MUCRole", ".", "moderator", ",", "null", ")", ";", "}" ]
Grants moderator privileges to a participant or visitor. Room administrators may grant moderator privileges. A moderator is allowed to kick users, grant and revoke voice, invite other users, modify room's subject plus all the partcipants privileges. @param nickname the nickname of the occupant to grant moderator privileges. @throws XMPPErrorException if an error occurs granting moderator privileges to a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "moderator", "privileges", "to", "a", "participant", "or", "visitor", ".", "Room", "administrators", "may", "grant", "moderator", "privileges", ".", "A", "moderator", "is", "allowed", "to", "kick", "users", "grant", "and", "revoke", "voice", "invite", "other", "users", "modify", "room", "s", "subject", "plus", "all", "the", "partcipants", "privileges", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1427-L1429
26,976
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantOwnership
public void grantOwnership(Collection<? extends Jid> jids) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jids, MUCAffiliation.owner); }
java
public void grantOwnership(Collection<? extends Jid> jids) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jids, MUCAffiliation.owner); }
[ "public", "void", "grantOwnership", "(", "Collection", "<", "?", "extends", "Jid", ">", "jids", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeAffiliationByAdmin", "(", "jids", ",", "MUCAffiliation", ".", "owner", ")", ";", "}" ]
Grants ownership privileges to other users. Room owners may grant ownership privileges. Some room implementations will not allow to grant ownership privileges to other users. An owner is allowed to change defining room features as well as perform all administrative functions. @param jids the collection of bare XMPP user IDs of the users to grant ownership. @throws XMPPErrorException if an error occurs granting ownership privileges to a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "ownership", "privileges", "to", "other", "users", ".", "Room", "owners", "may", "grant", "ownership", "privileges", ".", "Some", "room", "implementations", "will", "not", "allow", "to", "grant", "ownership", "privileges", "to", "other", "users", ".", "An", "owner", "is", "allowed", "to", "change", "defining", "room", "features", "as", "well", "as", "perform", "all", "administrative", "functions", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1475-L1477
26,977
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantOwnership
public void grantOwnership(Jid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.owner, null); }
java
public void grantOwnership(Jid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.owner, null); }
[ "public", "void", "grantOwnership", "(", "Jid", "jid", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeAffiliationByAdmin", "(", "jid", ",", "MUCAffiliation", ".", "owner", ",", "null", ")", ";", "}" ]
Grants ownership privileges to another user. Room owners may grant ownership privileges. Some room implementations will not allow to grant ownership privileges to other users. An owner is allowed to change defining room features as well as perform all administrative functions. @param jid the bare XMPP user ID of the user to grant ownership (e.g. "user@host.org"). @throws XMPPErrorException if an error occurs granting ownership privileges to a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "ownership", "privileges", "to", "another", "user", ".", "Room", "owners", "may", "grant", "ownership", "privileges", ".", "Some", "room", "implementations", "will", "not", "allow", "to", "grant", "ownership", "privileges", "to", "other", "users", ".", "An", "owner", "is", "allowed", "to", "change", "defining", "room", "features", "as", "well", "as", "perform", "all", "administrative", "functions", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1491-L1493
26,978
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.revokeOwnership
public void revokeOwnership(Collection<? extends Jid> jids) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jids, MUCAffiliation.admin); }
java
public void revokeOwnership(Collection<? extends Jid> jids) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jids, MUCAffiliation.admin); }
[ "public", "void", "revokeOwnership", "(", "Collection", "<", "?", "extends", "Jid", ">", "jids", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeAffiliationByAdmin", "(", "jids", ",", "MUCAffiliation", ".", "admin", ")", ";", "}" ]
Revokes ownership privileges from other users. The occupant that loses ownership privileges will become an administrator. Room owners may revoke ownership privileges. Some room implementations will not allow to grant ownership privileges to other users. @param jids the bare XMPP user IDs of the users to revoke ownership. @throws XMPPErrorException if an error occurs revoking ownership privileges from a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Revokes", "ownership", "privileges", "from", "other", "users", ".", "The", "occupant", "that", "loses", "ownership", "privileges", "will", "become", "an", "administrator", ".", "Room", "owners", "may", "revoke", "ownership", "privileges", ".", "Some", "room", "implementations", "will", "not", "allow", "to", "grant", "ownership", "privileges", "to", "other", "users", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1506-L1508
26,979
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.revokeOwnership
public void revokeOwnership(Jid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.admin, null); }
java
public void revokeOwnership(Jid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.admin, null); }
[ "public", "void", "revokeOwnership", "(", "Jid", "jid", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeAffiliationByAdmin", "(", "jid", ",", "MUCAffiliation", ".", "admin", ",", "null", ")", ";", "}" ]
Revokes ownership privileges from another user. The occupant that loses ownership privileges will become an administrator. Room owners may revoke ownership privileges. Some room implementations will not allow to grant ownership privileges to other users. @param jid the bare XMPP user ID of the user to revoke ownership (e.g. "user@host.org"). @throws XMPPErrorException if an error occurs revoking ownership privileges from a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Revokes", "ownership", "privileges", "from", "another", "user", ".", "The", "occupant", "that", "loses", "ownership", "privileges", "will", "become", "an", "administrator", ".", "Room", "owners", "may", "revoke", "ownership", "privileges", ".", "Some", "room", "implementations", "will", "not", "allow", "to", "grant", "ownership", "privileges", "to", "other", "users", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1521-L1523
26,980
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.grantAdmin
public void grantAdmin(Jid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.admin); }
java
public void grantAdmin(Jid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.admin); }
[ "public", "void", "grantAdmin", "(", "Jid", "jid", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeAffiliationByAdmin", "(", "jid", ",", "MUCAffiliation", ".", "admin", ")", ";", "}" ]
Grants administrator privileges to another user. Room owners may grant administrator privileges to a member or unaffiliated user. An administrator is allowed to perform administrative functions such as banning users and edit moderator list. @param jid the bare XMPP user ID of the user to grant administrator privileges (e.g. "user@host.org"). @throws XMPPErrorException if an error occurs granting administrator privileges to a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Grants", "administrator", "privileges", "to", "another", "user", ".", "Room", "owners", "may", "grant", "administrator", "privileges", "to", "a", "member", "or", "unaffiliated", "user", ".", "An", "administrator", "is", "allowed", "to", "perform", "administrative", "functions", "such", "as", "banning", "users", "and", "edit", "moderator", "list", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1552-L1554
26,981
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.revokeAdmin
public void revokeAdmin(EntityJid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.member); }
java
public void revokeAdmin(EntityJid jid) throws XMPPErrorException, NoResponseException, NotConnectedException, InterruptedException { changeAffiliationByAdmin(jid, MUCAffiliation.member); }
[ "public", "void", "revokeAdmin", "(", "EntityJid", "jid", ")", "throws", "XMPPErrorException", ",", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", "{", "changeAffiliationByAdmin", "(", "jid", ",", "MUCAffiliation", ".", "member", ")", ";", "}" ]
Revokes administrator privileges from a user. The occupant that loses administrator privileges will become a member. Room owners may revoke administrator privileges from a member or unaffiliated user. @param jid the bare XMPP user ID of the user to revoke administrator privileges (e.g. "user@host.org"). @throws XMPPErrorException if an error occurs revoking administrator privileges from a user. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Revokes", "administrator", "privileges", "from", "a", "user", ".", "The", "occupant", "that", "loses", "administrator", "privileges", "will", "become", "a", "member", ".", "Room", "owners", "may", "revoke", "administrator", "privileges", "from", "a", "member", "or", "unaffiliated", "user", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L1583-L1585
26,982
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.changeSubject
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Message message = createMessage(); message.setSubject(subject); // Wait for an error or confirmation message back from the server. StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() { @Override public boolean accept(Stanza packet) { Message msg = (Message) packet; return subject.equals(msg.getSubject()); } }); StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message); // Wait up to a certain number of seconds for a reply. response.nextResultOrThrow(); }
java
public void changeSubject(final String subject) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Message message = createMessage(); message.setSubject(subject); // Wait for an error or confirmation message back from the server. StanzaFilter responseFilter = new AndFilter(fromRoomGroupchatFilter, new StanzaFilter() { @Override public boolean accept(Stanza packet) { Message msg = (Message) packet; return subject.equals(msg.getSubject()); } }); StanzaCollector response = connection.createStanzaCollectorAndSend(responseFilter, message); // Wait up to a certain number of seconds for a reply. response.nextResultOrThrow(); }
[ "public", "void", "changeSubject", "(", "final", "String", "subject", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "Message", "message", "=", "createMessage", "(", ")", ";", "message", ".", "setSubject", "(", "subject", ")", ";", "// Wait for an error or confirmation message back from the server.", "StanzaFilter", "responseFilter", "=", "new", "AndFilter", "(", "fromRoomGroupchatFilter", ",", "new", "StanzaFilter", "(", ")", "{", "@", "Override", "public", "boolean", "accept", "(", "Stanza", "packet", ")", "{", "Message", "msg", "=", "(", "Message", ")", "packet", ";", "return", "subject", ".", "equals", "(", "msg", ".", "getSubject", "(", ")", ")", ";", "}", "}", ")", ";", "StanzaCollector", "response", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "responseFilter", ",", "message", ")", ";", "// Wait up to a certain number of seconds for a reply.", "response", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Changes the subject within the room. As a default, only users with a role of "moderator" are allowed to change the subject in a room. Although some rooms may be configured to allow a mere participant or even a visitor to change the subject. @param subject the new room's subject to set. @throws XMPPErrorException if someone without appropriate privileges attempts to change the room subject will throw an error with code 403 (i.e. Forbidden) @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Changes", "the", "subject", "within", "the", "room", ".", "As", "a", "default", "only", "users", "with", "a", "role", "of", "moderator", "are", "allowed", "to", "change", "the", "subject", "in", "a", "room", ".", "Although", "some", "rooms", "may", "be", "configured", "to", "allow", "a", "mere", "participant", "or", "even", "a", "visitor", "to", "change", "the", "subject", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L2026-L2040
26,983
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java
MultiUserChat.checkPresenceCode
private void checkPresenceCode( Set<Status> statusCodes, boolean isUserModification, MUCUser mucUser, EntityFullJid from) { // Check if an occupant was kicked from the room if (statusCodes.contains(Status.KICKED_307)) { // Check if this occupant was kicked if (isUserModification) { // Reset occupant information. userHasLeft(); for (UserStatusListener listener : userStatusListeners) { listener.kicked(mucUser.getItem().getActor(), mucUser.getItem().getReason()); } } else { for (ParticipantStatusListener listener : participantStatusListeners) { listener.kicked(from, mucUser.getItem().getActor(), mucUser.getItem().getReason()); } } } // A user was banned from the room if (statusCodes.contains(Status.BANNED_301)) { // Check if this occupant was banned if (isUserModification) { joined = false; for (UserStatusListener listener : userStatusListeners) { listener.banned(mucUser.getItem().getActor(), mucUser.getItem().getReason()); } // Reset occupant information. occupantsMap.clear(); myRoomJid = null; userHasLeft(); } else { for (ParticipantStatusListener listener : participantStatusListeners) { listener.banned(from, mucUser.getItem().getActor(), mucUser.getItem().getReason()); } } } // A user's membership was revoked from the room if (statusCodes.contains(Status.REMOVED_AFFIL_CHANGE_321)) { // Check if this occupant's membership was revoked if (isUserModification) { joined = false; for (UserStatusListener listener : userStatusListeners) { listener.membershipRevoked(); } // Reset occupant information. occupantsMap.clear(); myRoomJid = null; userHasLeft(); } } // A occupant has changed his nickname in the room if (statusCodes.contains(Status.NEW_NICKNAME_303)) { for (ParticipantStatusListener listener : participantStatusListeners) { listener.nicknameChanged(from, mucUser.getItem().getNick()); } } // The room has been destroyed. if (mucUser.getDestroy() != null) { MultiUserChat alternateMUC = multiUserChatManager.getMultiUserChat(mucUser.getDestroy().getJid()); for (UserStatusListener listener : userStatusListeners) { listener.roomDestroyed(alternateMUC, mucUser.getDestroy().getReason()); } // Reset occupant information. occupantsMap.clear(); myRoomJid = null; userHasLeft(); } }
java
private void checkPresenceCode( Set<Status> statusCodes, boolean isUserModification, MUCUser mucUser, EntityFullJid from) { // Check if an occupant was kicked from the room if (statusCodes.contains(Status.KICKED_307)) { // Check if this occupant was kicked if (isUserModification) { // Reset occupant information. userHasLeft(); for (UserStatusListener listener : userStatusListeners) { listener.kicked(mucUser.getItem().getActor(), mucUser.getItem().getReason()); } } else { for (ParticipantStatusListener listener : participantStatusListeners) { listener.kicked(from, mucUser.getItem().getActor(), mucUser.getItem().getReason()); } } } // A user was banned from the room if (statusCodes.contains(Status.BANNED_301)) { // Check if this occupant was banned if (isUserModification) { joined = false; for (UserStatusListener listener : userStatusListeners) { listener.banned(mucUser.getItem().getActor(), mucUser.getItem().getReason()); } // Reset occupant information. occupantsMap.clear(); myRoomJid = null; userHasLeft(); } else { for (ParticipantStatusListener listener : participantStatusListeners) { listener.banned(from, mucUser.getItem().getActor(), mucUser.getItem().getReason()); } } } // A user's membership was revoked from the room if (statusCodes.contains(Status.REMOVED_AFFIL_CHANGE_321)) { // Check if this occupant's membership was revoked if (isUserModification) { joined = false; for (UserStatusListener listener : userStatusListeners) { listener.membershipRevoked(); } // Reset occupant information. occupantsMap.clear(); myRoomJid = null; userHasLeft(); } } // A occupant has changed his nickname in the room if (statusCodes.contains(Status.NEW_NICKNAME_303)) { for (ParticipantStatusListener listener : participantStatusListeners) { listener.nicknameChanged(from, mucUser.getItem().getNick()); } } // The room has been destroyed. if (mucUser.getDestroy() != null) { MultiUserChat alternateMUC = multiUserChatManager.getMultiUserChat(mucUser.getDestroy().getJid()); for (UserStatusListener listener : userStatusListeners) { listener.roomDestroyed(alternateMUC, mucUser.getDestroy().getReason()); } // Reset occupant information. occupantsMap.clear(); myRoomJid = null; userHasLeft(); } }
[ "private", "void", "checkPresenceCode", "(", "Set", "<", "Status", ">", "statusCodes", ",", "boolean", "isUserModification", ",", "MUCUser", "mucUser", ",", "EntityFullJid", "from", ")", "{", "// Check if an occupant was kicked from the room", "if", "(", "statusCodes", ".", "contains", "(", "Status", ".", "KICKED_307", ")", ")", "{", "// Check if this occupant was kicked", "if", "(", "isUserModification", ")", "{", "// Reset occupant information.", "userHasLeft", "(", ")", ";", "for", "(", "UserStatusListener", "listener", ":", "userStatusListeners", ")", "{", "listener", ".", "kicked", "(", "mucUser", ".", "getItem", "(", ")", ".", "getActor", "(", ")", ",", "mucUser", ".", "getItem", "(", ")", ".", "getReason", "(", ")", ")", ";", "}", "}", "else", "{", "for", "(", "ParticipantStatusListener", "listener", ":", "participantStatusListeners", ")", "{", "listener", ".", "kicked", "(", "from", ",", "mucUser", ".", "getItem", "(", ")", ".", "getActor", "(", ")", ",", "mucUser", ".", "getItem", "(", ")", ".", "getReason", "(", ")", ")", ";", "}", "}", "}", "// A user was banned from the room", "if", "(", "statusCodes", ".", "contains", "(", "Status", ".", "BANNED_301", ")", ")", "{", "// Check if this occupant was banned", "if", "(", "isUserModification", ")", "{", "joined", "=", "false", ";", "for", "(", "UserStatusListener", "listener", ":", "userStatusListeners", ")", "{", "listener", ".", "banned", "(", "mucUser", ".", "getItem", "(", ")", ".", "getActor", "(", ")", ",", "mucUser", ".", "getItem", "(", ")", ".", "getReason", "(", ")", ")", ";", "}", "// Reset occupant information.", "occupantsMap", ".", "clear", "(", ")", ";", "myRoomJid", "=", "null", ";", "userHasLeft", "(", ")", ";", "}", "else", "{", "for", "(", "ParticipantStatusListener", "listener", ":", "participantStatusListeners", ")", "{", "listener", ".", "banned", "(", "from", ",", "mucUser", ".", "getItem", "(", ")", ".", "getActor", "(", ")", ",", "mucUser", ".", "getItem", "(", ")", ".", "getReason", "(", ")", ")", ";", "}", "}", "}", "// A user's membership was revoked from the room", "if", "(", "statusCodes", ".", "contains", "(", "Status", ".", "REMOVED_AFFIL_CHANGE_321", ")", ")", "{", "// Check if this occupant's membership was revoked", "if", "(", "isUserModification", ")", "{", "joined", "=", "false", ";", "for", "(", "UserStatusListener", "listener", ":", "userStatusListeners", ")", "{", "listener", ".", "membershipRevoked", "(", ")", ";", "}", "// Reset occupant information.", "occupantsMap", ".", "clear", "(", ")", ";", "myRoomJid", "=", "null", ";", "userHasLeft", "(", ")", ";", "}", "}", "// A occupant has changed his nickname in the room", "if", "(", "statusCodes", ".", "contains", "(", "Status", ".", "NEW_NICKNAME_303", ")", ")", "{", "for", "(", "ParticipantStatusListener", "listener", ":", "participantStatusListeners", ")", "{", "listener", ".", "nicknameChanged", "(", "from", ",", "mucUser", ".", "getItem", "(", ")", ".", "getNick", "(", ")", ")", ";", "}", "}", "// The room has been destroyed.", "if", "(", "mucUser", ".", "getDestroy", "(", ")", "!=", "null", ")", "{", "MultiUserChat", "alternateMUC", "=", "multiUserChatManager", ".", "getMultiUserChat", "(", "mucUser", ".", "getDestroy", "(", ")", ".", "getJid", "(", ")", ")", ";", "for", "(", "UserStatusListener", "listener", ":", "userStatusListeners", ")", "{", "listener", ".", "roomDestroyed", "(", "alternateMUC", ",", "mucUser", ".", "getDestroy", "(", ")", ".", "getReason", "(", ")", ")", ";", "}", "// Reset occupant information.", "occupantsMap", ".", "clear", "(", ")", ";", "myRoomJid", "=", "null", ";", "userHasLeft", "(", ")", ";", "}", "}" ]
Fires events according to the received presence code. @param statusCodes @param isUserModification @param mucUser @param from
[ "Fires", "events", "according", "to", "the", "received", "presence", "code", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MultiUserChat.java#L2375-L2450
26,984
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/reference/element/ReferenceElement.java
ReferenceElement.addMention
public static void addMention(Stanza stanza, int begin, int end, BareJid jid) { URI uri; try { uri = new URI("xmpp:" + jid.toString()); } catch (URISyntaxException e) { throw new AssertionError("Cannot create URI from bareJid."); } ReferenceElement reference = new ReferenceElement(begin, end, ReferenceElement.Type.mention, null, uri); stanza.addExtension(reference); }
java
public static void addMention(Stanza stanza, int begin, int end, BareJid jid) { URI uri; try { uri = new URI("xmpp:" + jid.toString()); } catch (URISyntaxException e) { throw new AssertionError("Cannot create URI from bareJid."); } ReferenceElement reference = new ReferenceElement(begin, end, ReferenceElement.Type.mention, null, uri); stanza.addExtension(reference); }
[ "public", "static", "void", "addMention", "(", "Stanza", "stanza", ",", "int", "begin", ",", "int", "end", ",", "BareJid", "jid", ")", "{", "URI", "uri", ";", "try", "{", "uri", "=", "new", "URI", "(", "\"xmpp:\"", "+", "jid", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "URISyntaxException", "e", ")", "{", "throw", "new", "AssertionError", "(", "\"Cannot create URI from bareJid.\"", ")", ";", "}", "ReferenceElement", "reference", "=", "new", "ReferenceElement", "(", "begin", ",", "end", ",", "ReferenceElement", ".", "Type", ".", "mention", ",", "null", ",", "uri", ")", ";", "stanza", ".", "addExtension", "(", "reference", ")", ";", "}" ]
Add a reference to another users bare jid to a stanza. @param stanza stanza. @param begin start index of the mention in the messages body. @param end end index of the mention in the messages body. @param jid referenced jid.
[ "Add", "a", "reference", "to", "another", "users", "bare", "jid", "to", "a", "stanza", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/element/ReferenceElement.java#L129-L138
26,985
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/reference/element/ReferenceElement.java
ReferenceElement.getReferencesFromStanza
public static List<ReferenceElement> getReferencesFromStanza(Stanza stanza) { List<ReferenceElement> references = new ArrayList<>(); List<ExtensionElement> extensions = stanza.getExtensions(ReferenceElement.ELEMENT, ReferenceManager.NAMESPACE); for (ExtensionElement e : extensions) { references.add((ReferenceElement) e); } return references; }
java
public static List<ReferenceElement> getReferencesFromStanza(Stanza stanza) { List<ReferenceElement> references = new ArrayList<>(); List<ExtensionElement> extensions = stanza.getExtensions(ReferenceElement.ELEMENT, ReferenceManager.NAMESPACE); for (ExtensionElement e : extensions) { references.add((ReferenceElement) e); } return references; }
[ "public", "static", "List", "<", "ReferenceElement", ">", "getReferencesFromStanza", "(", "Stanza", "stanza", ")", "{", "List", "<", "ReferenceElement", ">", "references", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "ExtensionElement", ">", "extensions", "=", "stanza", ".", "getExtensions", "(", "ReferenceElement", ".", "ELEMENT", ",", "ReferenceManager", ".", "NAMESPACE", ")", ";", "for", "(", "ExtensionElement", "e", ":", "extensions", ")", "{", "references", ".", "add", "(", "(", "ReferenceElement", ")", "e", ")", ";", "}", "return", "references", ";", "}" ]
Return a list of all reference extensions contained in a stanza. If there are no reference elements, return an empty list. @param stanza stanza @return list of all references contained in the stanza
[ "Return", "a", "list", "of", "all", "reference", "extensions", "contained", "in", "a", "stanza", ".", "If", "there", "are", "no", "reference", "elements", "return", "an", "empty", "list", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/reference/element/ReferenceElement.java#L147-L154
26,986
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/amp/AMPExpireAtCondition.java
AMPExpireAtCondition.isSupported
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return AMPManager.isConditionSupported(connection, NAME); }
java
public static boolean isSupported(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return AMPManager.isConditionSupported(connection, NAME); }
[ "public", "static", "boolean", "isSupported", "(", "XMPPConnection", "connection", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "AMPManager", ".", "isConditionSupported", "(", "connection", ",", "NAME", ")", ";", "}" ]
Check if server supports expire-at condition. @param connection Smack connection instance @return true if expire-at condition is supported. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Check", "if", "server", "supports", "expire", "-", "at", "condition", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/amp/AMPExpireAtCondition.java#L44-L46
26,987
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java
OriginIdElement.addOriginId
public static OriginIdElement addOriginId(Message message) { OriginIdElement originId = new OriginIdElement(); message.addExtension(originId); // TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID. // message.setStanzaId(originId.getId()); return originId; }
java
public static OriginIdElement addOriginId(Message message) { OriginIdElement originId = new OriginIdElement(); message.addExtension(originId); // TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID. // message.setStanzaId(originId.getId()); return originId; }
[ "public", "static", "OriginIdElement", "addOriginId", "(", "Message", "message", ")", "{", "OriginIdElement", "originId", "=", "new", "OriginIdElement", "(", ")", ";", "message", ".", "addExtension", "(", "originId", ")", ";", "// TODO: Find solution to have both the originIds stanzaId and a nice to look at incremental stanzaID.", "// message.setStanzaId(originId.getId());", "return", "originId", ";", "}" ]
Add an origin-id element to a message and set the stanzas id to the same id as in the origin-id element. @param message message.
[ "Add", "an", "origin", "-", "id", "element", "to", "a", "message", "and", "set", "the", "stanzas", "id", "to", "the", "same", "id", "as", "in", "the", "origin", "-", "id", "element", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java#L40-L46
26,988
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java
OriginIdElement.getOriginId
public static OriginIdElement getOriginId(Message message) { return message.getExtension(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE); }
java
public static OriginIdElement getOriginId(Message message) { return message.getExtension(OriginIdElement.ELEMENT, StableUniqueStanzaIdManager.NAMESPACE); }
[ "public", "static", "OriginIdElement", "getOriginId", "(", "Message", "message", ")", "{", "return", "message", ".", "getExtension", "(", "OriginIdElement", ".", "ELEMENT", ",", "StableUniqueStanzaIdManager", ".", "NAMESPACE", ")", ";", "}" ]
Return the origin-id element of a message or null, if absent. @param message message @return origin-id element
[ "Return", "the", "origin", "-", "id", "element", "of", "a", "message", "or", "null", "if", "absent", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/sid/element/OriginIdElement.java#L64-L66
26,989
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/SharedGroupManager.java
SharedGroupManager.getSharedGroups
public static List<String> getSharedGroups(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Discover the shared groups of the logged user SharedGroupsInfo info = new SharedGroupsInfo(); info.setType(IQ.Type.get); SharedGroupsInfo result = connection.createStanzaCollectorAndSend(info).nextResultOrThrow(); return result.getGroups(); }
java
public static List<String> getSharedGroups(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Discover the shared groups of the logged user SharedGroupsInfo info = new SharedGroupsInfo(); info.setType(IQ.Type.get); SharedGroupsInfo result = connection.createStanzaCollectorAndSend(info).nextResultOrThrow(); return result.getGroups(); }
[ "public", "static", "List", "<", "String", ">", "getSharedGroups", "(", "XMPPConnection", "connection", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "// Discover the shared groups of the logged user", "SharedGroupsInfo", "info", "=", "new", "SharedGroupsInfo", "(", ")", ";", "info", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "SharedGroupsInfo", "result", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "info", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "result", ".", "getGroups", "(", ")", ";", "}" ]
Returns the collection that will contain the name of the shared groups where the user logged in with the specified session belongs. @param connection connection to use to get the user's shared groups. @return collection with the shared groups' name of the logged user. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "collection", "that", "will", "contain", "the", "name", "of", "the", "shared", "groups", "where", "the", "user", "logged", "in", "with", "the", "specified", "session", "belongs", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/sharedgroups/SharedGroupManager.java#L50-L57
26,990
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
ProviderManager.getIQProviders
public static List<IQProvider<IQ>> getIQProviders() { List<IQProvider<IQ>> providers = new ArrayList<>(iqProviders.size()); providers.addAll(iqProviders.values()); return providers; }
java
public static List<IQProvider<IQ>> getIQProviders() { List<IQProvider<IQ>> providers = new ArrayList<>(iqProviders.size()); providers.addAll(iqProviders.values()); return providers; }
[ "public", "static", "List", "<", "IQProvider", "<", "IQ", ">", ">", "getIQProviders", "(", ")", "{", "List", "<", "IQProvider", "<", "IQ", ">>", "providers", "=", "new", "ArrayList", "<>", "(", "iqProviders", ".", "size", "(", ")", ")", ";", "providers", ".", "addAll", "(", "iqProviders", ".", "values", "(", ")", ")", ";", "return", "providers", ";", "}" ]
Returns an unmodifiable collection of all IQProvider instances. Each object in the collection will either be an IQProvider instance, or a Class object that implements the IQProvider interface. @return all IQProvider instances.
[ "Returns", "an", "unmodifiable", "collection", "of", "all", "IQProvider", "instances", ".", "Each", "object", "in", "the", "collection", "will", "either", "be", "an", "IQProvider", "instance", "or", "a", "Class", "object", "that", "implements", "the", "IQProvider", "interface", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java#L182-L186
26,991
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
ProviderManager.addExtensionProvider
@SuppressWarnings("unchecked") public static void addExtensionProvider(String elementName, String namespace, Object provider) { validate(elementName, namespace); // First remove existing providers String key = removeExtensionProvider(elementName, namespace); if (provider instanceof ExtensionElementProvider) { extensionProviders.put(key, (ExtensionElementProvider<ExtensionElement>) provider); } else { throw new IllegalArgumentException("Provider must be a PacketExtensionProvider"); } }
java
@SuppressWarnings("unchecked") public static void addExtensionProvider(String elementName, String namespace, Object provider) { validate(elementName, namespace); // First remove existing providers String key = removeExtensionProvider(elementName, namespace); if (provider instanceof ExtensionElementProvider) { extensionProviders.put(key, (ExtensionElementProvider<ExtensionElement>) provider); } else { throw new IllegalArgumentException("Provider must be a PacketExtensionProvider"); } }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "static", "void", "addExtensionProvider", "(", "String", "elementName", ",", "String", "namespace", ",", "Object", "provider", ")", "{", "validate", "(", "elementName", ",", "namespace", ")", ";", "// First remove existing providers", "String", "key", "=", "removeExtensionProvider", "(", "elementName", ",", "namespace", ")", ";", "if", "(", "provider", "instanceof", "ExtensionElementProvider", ")", "{", "extensionProviders", ".", "put", "(", "key", ",", "(", "ExtensionElementProvider", "<", "ExtensionElement", ">", ")", "provider", ")", ";", "}", "else", "{", "throw", "new", "IllegalArgumentException", "(", "\"Provider must be a PacketExtensionProvider\"", ")", ";", "}", "}" ]
Adds an extension provider with the specified element name and name space. The provider will override any providers loaded through the classpath. The provider must be either a PacketExtensionProvider instance, or a Class object of a Javabean. @param elementName the XML element name. @param namespace the XML namespace. @param provider the extension provider.
[ "Adds", "an", "extension", "provider", "with", "the", "specified", "element", "name", "and", "name", "space", ".", "The", "provider", "will", "override", "any", "providers", "loaded", "through", "the", "classpath", ".", "The", "provider", "must", "be", "either", "a", "PacketExtensionProvider", "instance", "or", "a", "Class", "object", "of", "a", "Javabean", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java#L258-L269
26,992
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
ProviderManager.getExtensionProviders
public static List<ExtensionElementProvider<ExtensionElement>> getExtensionProviders() { List<ExtensionElementProvider<ExtensionElement>> providers = new ArrayList<>(extensionProviders.size()); providers.addAll(extensionProviders.values()); return providers; }
java
public static List<ExtensionElementProvider<ExtensionElement>> getExtensionProviders() { List<ExtensionElementProvider<ExtensionElement>> providers = new ArrayList<>(extensionProviders.size()); providers.addAll(extensionProviders.values()); return providers; }
[ "public", "static", "List", "<", "ExtensionElementProvider", "<", "ExtensionElement", ">", ">", "getExtensionProviders", "(", ")", "{", "List", "<", "ExtensionElementProvider", "<", "ExtensionElement", ">>", "providers", "=", "new", "ArrayList", "<>", "(", "extensionProviders", ".", "size", "(", ")", ")", ";", "providers", ".", "addAll", "(", "extensionProviders", ".", "values", "(", ")", ")", ";", "return", "providers", ";", "}" ]
Returns an unmodifiable collection of all PacketExtensionProvider instances. Each object in the collection will either be a PacketExtensionProvider instance, or a Class object that implements the PacketExtensionProvider interface. @return all PacketExtensionProvider instances.
[ "Returns", "an", "unmodifiable", "collection", "of", "all", "PacketExtensionProvider", "instances", ".", "Each", "object", "in", "the", "collection", "will", "either", "be", "a", "PacketExtensionProvider", "instance", "or", "a", "Class", "object", "that", "implements", "the", "PacketExtensionProvider", "interface", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java#L293-L297
26,993
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java
Bookmarks.toXML
@Override public XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket(); for (BookmarkedURL urlStorage : getBookmarkedURLS()) { if (urlStorage.isShared()) { continue; } buf.halfOpenElement("url").attribute("name", urlStorage.getName()).attribute("url", urlStorage.getURL()); buf.condAttribute(urlStorage.isRss(), "rss", "true"); buf.closeEmptyElement(); } // Add Conference additions for (BookmarkedConference conference : getBookmarkedConferences()) { if (conference.isShared()) { continue; } buf.halfOpenElement("conference"); buf.attribute("name", conference.getName()); buf.attribute("autojoin", Boolean.toString(conference.isAutoJoin())); buf.attribute("jid", conference.getJid()); buf.rightAngleBracket(); buf.optElement("nick", conference.getNickname()); buf.optElement("password", conference.getPassword()); buf.closeElement("conference"); } buf.closeElement(ELEMENT); return buf; }
java
@Override public XmlStringBuilder toXML() { XmlStringBuilder buf = new XmlStringBuilder(); buf.halfOpenElement(ELEMENT).xmlnsAttribute(NAMESPACE).rightAngleBracket(); for (BookmarkedURL urlStorage : getBookmarkedURLS()) { if (urlStorage.isShared()) { continue; } buf.halfOpenElement("url").attribute("name", urlStorage.getName()).attribute("url", urlStorage.getURL()); buf.condAttribute(urlStorage.isRss(), "rss", "true"); buf.closeEmptyElement(); } // Add Conference additions for (BookmarkedConference conference : getBookmarkedConferences()) { if (conference.isShared()) { continue; } buf.halfOpenElement("conference"); buf.attribute("name", conference.getName()); buf.attribute("autojoin", Boolean.toString(conference.isAutoJoin())); buf.attribute("jid", conference.getJid()); buf.rightAngleBracket(); buf.optElement("nick", conference.getNickname()); buf.optElement("password", conference.getPassword()); buf.closeElement("conference"); } buf.closeElement(ELEMENT); return buf; }
[ "@", "Override", "public", "XmlStringBuilder", "toXML", "(", ")", "{", "XmlStringBuilder", "buf", "=", "new", "XmlStringBuilder", "(", ")", ";", "buf", ".", "halfOpenElement", "(", "ELEMENT", ")", ".", "xmlnsAttribute", "(", "NAMESPACE", ")", ".", "rightAngleBracket", "(", ")", ";", "for", "(", "BookmarkedURL", "urlStorage", ":", "getBookmarkedURLS", "(", ")", ")", "{", "if", "(", "urlStorage", ".", "isShared", "(", ")", ")", "{", "continue", ";", "}", "buf", ".", "halfOpenElement", "(", "\"url\"", ")", ".", "attribute", "(", "\"name\"", ",", "urlStorage", ".", "getName", "(", ")", ")", ".", "attribute", "(", "\"url\"", ",", "urlStorage", ".", "getURL", "(", ")", ")", ";", "buf", ".", "condAttribute", "(", "urlStorage", ".", "isRss", "(", ")", ",", "\"rss\"", ",", "\"true\"", ")", ";", "buf", ".", "closeEmptyElement", "(", ")", ";", "}", "// Add Conference additions", "for", "(", "BookmarkedConference", "conference", ":", "getBookmarkedConferences", "(", ")", ")", "{", "if", "(", "conference", ".", "isShared", "(", ")", ")", "{", "continue", ";", "}", "buf", ".", "halfOpenElement", "(", "\"conference\"", ")", ";", "buf", ".", "attribute", "(", "\"name\"", ",", "conference", ".", "getName", "(", ")", ")", ";", "buf", ".", "attribute", "(", "\"autojoin\"", ",", "Boolean", ".", "toString", "(", "conference", ".", "isAutoJoin", "(", ")", ")", ")", ";", "buf", ".", "attribute", "(", "\"jid\"", ",", "conference", ".", "getJid", "(", ")", ")", ";", "buf", ".", "rightAngleBracket", "(", ")", ";", "buf", ".", "optElement", "(", "\"nick\"", ",", "conference", ".", "getNickname", "(", ")", ")", ";", "buf", ".", "optElement", "(", "\"password\"", ",", "conference", ".", "getPassword", "(", ")", ")", ";", "buf", ".", "closeElement", "(", "\"conference\"", ")", ";", "}", "buf", ".", "closeElement", "(", "ELEMENT", ")", ";", "return", "buf", ";", "}" ]
Returns the XML representation of the PrivateData. @return the private data as XML.
[ "Returns", "the", "XML", "representation", "of", "the", "PrivateData", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/bookmarks/Bookmarks.java#L172-L205
26,994
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/Jingle.java
Jingle.addContents
public void addContents(final List<JingleContent> contentList) { if (contentList != null) { synchronized (contents) { contents.addAll(contentList); } } }
java
public void addContents(final List<JingleContent> contentList) { if (contentList != null) { synchronized (contents) { contents.addAll(contentList); } } }
[ "public", "void", "addContents", "(", "final", "List", "<", "JingleContent", ">", "contentList", ")", "{", "if", "(", "contentList", "!=", "null", ")", "{", "synchronized", "(", "contents", ")", "{", "contents", ".", "addAll", "(", "contentList", ")", ";", "}", "}", "}" ]
Add a list of JingleContent elements. @param contentList the list of contents to add
[ "Add", "a", "list", "of", "JingleContent", "elements", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/Jingle.java#L258-L264
26,995
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/Jingle.java
Jingle.getSessionHash
public static int getSessionHash(final String sid, final Jid initiator) { final int PRIME = 31; int result = 1; result = PRIME * result + (initiator == null ? 0 : initiator.hashCode()); result = PRIME * result + (sid == null ? 0 : sid.hashCode()); return result; }
java
public static int getSessionHash(final String sid, final Jid initiator) { final int PRIME = 31; int result = 1; result = PRIME * result + (initiator == null ? 0 : initiator.hashCode()); result = PRIME * result + (sid == null ? 0 : sid.hashCode()); return result; }
[ "public", "static", "int", "getSessionHash", "(", "final", "String", "sid", ",", "final", "Jid", "initiator", ")", "{", "final", "int", "PRIME", "=", "31", ";", "int", "result", "=", "1", ";", "result", "=", "PRIME", "*", "result", "+", "(", "initiator", "==", "null", "?", "0", ":", "initiator", ".", "hashCode", "(", ")", ")", ";", "result", "=", "PRIME", "*", "result", "+", "(", "sid", "==", "null", "?", "0", ":", "sid", ".", "hashCode", "(", ")", ")", ";", "return", "result", ";", "}" ]
Get a hash key for the session this stanza belongs to. @param sid The session id @param initiator The initiator @return A hash key
[ "Get", "a", "hash", "key", "for", "the", "session", "this", "stanza", "belongs", "to", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/Jingle.java#L335-L341
26,996
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/Jingle.java
Jingle.getIQChildElementBuilder
@Override protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) { if (getInitiator() != null) { buf.append(" initiator=\"").append(getInitiator()).append('"'); } if (getResponder() != null) { buf.append(" responder=\"").append(getResponder()).append('"'); } if (getAction() != null) { buf.append(" action=\"").append(getAction().toString()).append('"'); } if (getSid() != null) { buf.append(" sid=\"").append(getSid()).append('"'); } buf.append('>'); synchronized (contents) { for (JingleContent content : contents) { buf.append(content.toXML()); } } // and the same for audio jmf info if (contentInfo != null) { buf.append(contentInfo.toXML()); } return buf; }
java
@Override protected IQChildElementXmlStringBuilder getIQChildElementBuilder(IQChildElementXmlStringBuilder buf) { if (getInitiator() != null) { buf.append(" initiator=\"").append(getInitiator()).append('"'); } if (getResponder() != null) { buf.append(" responder=\"").append(getResponder()).append('"'); } if (getAction() != null) { buf.append(" action=\"").append(getAction().toString()).append('"'); } if (getSid() != null) { buf.append(" sid=\"").append(getSid()).append('"'); } buf.append('>'); synchronized (contents) { for (JingleContent content : contents) { buf.append(content.toXML()); } } // and the same for audio jmf info if (contentInfo != null) { buf.append(contentInfo.toXML()); } return buf; }
[ "@", "Override", "protected", "IQChildElementXmlStringBuilder", "getIQChildElementBuilder", "(", "IQChildElementXmlStringBuilder", "buf", ")", "{", "if", "(", "getInitiator", "(", ")", "!=", "null", ")", "{", "buf", ".", "append", "(", "\" initiator=\\\"\"", ")", ".", "append", "(", "getInitiator", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "getResponder", "(", ")", "!=", "null", ")", "{", "buf", ".", "append", "(", "\" responder=\\\"\"", ")", ".", "append", "(", "getResponder", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "getAction", "(", ")", "!=", "null", ")", "{", "buf", ".", "append", "(", "\" action=\\\"\"", ")", ".", "append", "(", "getAction", "(", ")", ".", "toString", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "if", "(", "getSid", "(", ")", "!=", "null", ")", "{", "buf", ".", "append", "(", "\" sid=\\\"\"", ")", ".", "append", "(", "getSid", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "buf", ".", "append", "(", "'", "'", ")", ";", "synchronized", "(", "contents", ")", "{", "for", "(", "JingleContent", "content", ":", "contents", ")", "{", "buf", ".", "append", "(", "content", ".", "toXML", "(", ")", ")", ";", "}", "}", "// and the same for audio jmf info", "if", "(", "contentInfo", "!=", "null", ")", "{", "buf", ".", "append", "(", "contentInfo", ".", "toXML", "(", ")", ")", ";", "}", "return", "buf", ";", "}" ]
Return the XML representation of the packet. @return the XML string
[ "Return", "the", "XML", "representation", "of", "the", "packet", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/Jingle.java#L348-L376
26,997
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
MamManager.isSupported
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Note that this may return 'null' but SDM's supportsFeature() does the right thing™ then. Jid archiveAddress = getArchiveAddress(); return serviceDiscoveryManager.supportsFeature(archiveAddress, MamElements.NAMESPACE); }
java
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Note that this may return 'null' but SDM's supportsFeature() does the right thing™ then. Jid archiveAddress = getArchiveAddress(); return serviceDiscoveryManager.supportsFeature(archiveAddress, MamElements.NAMESPACE); }
[ "public", "boolean", "isSupported", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "// Note that this may return 'null' but SDM's supportsFeature() does the right thing™ then.", "Jid", "archiveAddress", "=", "getArchiveAddress", "(", ")", ";", "return", "serviceDiscoveryManager", ".", "supportsFeature", "(", "archiveAddress", ",", "MamElements", ".", "NAMESPACE", ")", ";", "}" ]
Check if this MamManager's archive address supports MAM. @return true if MAM is supported, <code>false</code>otherwise. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @since 4.2.1 @see <a href="https://xmpp.org/extensions/xep-0313.html#support">XEP-0313 § 7. Determining support</a>
[ "Check", "if", "this", "MamManager", "s", "archive", "address", "supports", "MAM", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java#L739-L743
26,998
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java
MamManager.retrieveArchivingPreferences
public MamPrefsResult retrieveArchivingPreferences() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { MamPrefsIQ mamPrefIQ = new MamPrefsIQ(); return queryMamPrefs(mamPrefIQ); }
java
public MamPrefsResult retrieveArchivingPreferences() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { MamPrefsIQ mamPrefIQ = new MamPrefsIQ(); return queryMamPrefs(mamPrefIQ); }
[ "public", "MamPrefsResult", "retrieveArchivingPreferences", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", ",", "NotLoggedInException", "{", "MamPrefsIQ", "mamPrefIQ", "=", "new", "MamPrefsIQ", "(", ")", ";", "return", "queryMamPrefs", "(", "mamPrefIQ", ")", ";", "}" ]
Get the preferences stored in the server. @return the MAM preferences result @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @throws NotLoggedInException
[ "Get", "the", "preferences", "stored", "in", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/mam/MamManager.java#L790-L794
26,999
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java
Affiliation.isAffiliationModification
public boolean isAffiliationModification() { if (jid != null && affiliation != null) { assert (node == null && namespace == AffiliationNamespace.owner); return true; } return false; }
java
public boolean isAffiliationModification() { if (jid != null && affiliation != null) { assert (node == null && namespace == AffiliationNamespace.owner); return true; } return false; }
[ "public", "boolean", "isAffiliationModification", "(", ")", "{", "if", "(", "jid", "!=", "null", "&&", "affiliation", "!=", "null", ")", "{", "assert", "(", "node", "==", "null", "&&", "namespace", "==", "AffiliationNamespace", ".", "owner", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check if this is an affiliation element to modify affiliations on a node. @return <code>true</code> if this is an affiliation element to modify affiliations on a node, <code>false</code> otherwise. @since 4.2
[ "Check", "if", "this", "is", "an", "affiliation", "element", "to", "modify", "affiliations", "on", "a", "node", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java#L168-L174