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,500
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java
IoTDiscoveryManager.isRegistry
public boolean isRegistry(BareJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Objects.requireNonNull(jid, "JID argument must not be null"); // At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is // not the case from the beginning, we perform findRegistry().equals(jid) too. Jid registry = findRegistry(); if (jid.equals(registry)) { return true; } if (usedRegistries.contains(jid)) { return true; } return false; }
java
public boolean isRegistry(BareJid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Objects.requireNonNull(jid, "JID argument must not be null"); // At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is // not the case from the beginning, we perform findRegistry().equals(jid) too. Jid registry = findRegistry(); if (jid.equals(registry)) { return true; } if (usedRegistries.contains(jid)) { return true; } return false; }
[ "public", "boolean", "isRegistry", "(", "BareJid", "jid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "Objects", ".", "requireNonNull", "(", "jid", ",", "\"JID argument must not be null\"", ")", ";", "// At some point 'usedRegistries' will also contain the registry returned by findRegistry(), but since this is", "// not the case from the beginning, we perform findRegistry().equals(jid) too.", "Jid", "registry", "=", "findRegistry", "(", ")", ";", "if", "(", "jid", ".", "equals", "(", "registry", ")", ")", "{", "return", "true", ";", "}", "if", "(", "usedRegistries", ".", "contains", "(", "jid", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Registry utility methods
[ "Registry", "utility", "methods" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/discovery/IoTDiscoveryManager.java#L383-L395
26,501
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUNResolver.java
STUNResolver.loadSTUNServers
public ArrayList<STUNService> loadSTUNServers(java.io.InputStream stunConfigStream) { ArrayList<STUNService> serversList = new ArrayList<>(); String serverName; int serverPort; try { XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); parser.setInput(stunConfigStream, "UTF-8"); int eventType = parser.getEventType(); do { if (eventType == XmlPullParser.START_TAG) { // Parse a STUN server definition if (parser.getName().equals("stunServer")) { serverName = null; serverPort = -1; // Parse the hostname parser.next(); parser.next(); serverName = parser.nextText(); // Parse the port parser.next(); parser.next(); try { serverPort = Integer.parseInt(parser.nextText()); } catch (Exception e) { } // If we have a valid hostname and port, add // it to the list. if (serverName != null && serverPort != -1) { STUNService service = new STUNService(serverName, serverPort); serversList.add(service); } } } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); } catch (XmlPullParserException e) { LOGGER.log(Level.SEVERE, "Exception", e); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Exception", e); } currentServer = bestSTUNServer(serversList); return serversList; }
java
public ArrayList<STUNService> loadSTUNServers(java.io.InputStream stunConfigStream) { ArrayList<STUNService> serversList = new ArrayList<>(); String serverName; int serverPort; try { XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); parser.setInput(stunConfigStream, "UTF-8"); int eventType = parser.getEventType(); do { if (eventType == XmlPullParser.START_TAG) { // Parse a STUN server definition if (parser.getName().equals("stunServer")) { serverName = null; serverPort = -1; // Parse the hostname parser.next(); parser.next(); serverName = parser.nextText(); // Parse the port parser.next(); parser.next(); try { serverPort = Integer.parseInt(parser.nextText()); } catch (Exception e) { } // If we have a valid hostname and port, add // it to the list. if (serverName != null && serverPort != -1) { STUNService service = new STUNService(serverName, serverPort); serversList.add(service); } } } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); } catch (XmlPullParserException e) { LOGGER.log(Level.SEVERE, "Exception", e); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Exception", e); } currentServer = bestSTUNServer(serversList); return serversList; }
[ "public", "ArrayList", "<", "STUNService", ">", "loadSTUNServers", "(", "java", ".", "io", ".", "InputStream", "stunConfigStream", ")", "{", "ArrayList", "<", "STUNService", ">", "serversList", "=", "new", "ArrayList", "<>", "(", ")", ";", "String", "serverName", ";", "int", "serverPort", ";", "try", "{", "XmlPullParser", "parser", "=", "XmlPullParserFactory", ".", "newInstance", "(", ")", ".", "newPullParser", "(", ")", ";", "parser", ".", "setFeature", "(", "XmlPullParser", ".", "FEATURE_PROCESS_NAMESPACES", ",", "true", ")", ";", "parser", ".", "setInput", "(", "stunConfigStream", ",", "\"UTF-8\"", ")", ";", "int", "eventType", "=", "parser", ".", "getEventType", "(", ")", ";", "do", "{", "if", "(", "eventType", "==", "XmlPullParser", ".", "START_TAG", ")", "{", "// Parse a STUN server definition", "if", "(", "parser", ".", "getName", "(", ")", ".", "equals", "(", "\"stunServer\"", ")", ")", "{", "serverName", "=", "null", ";", "serverPort", "=", "-", "1", ";", "// Parse the hostname", "parser", ".", "next", "(", ")", ";", "parser", ".", "next", "(", ")", ";", "serverName", "=", "parser", ".", "nextText", "(", ")", ";", "// Parse the port", "parser", ".", "next", "(", ")", ";", "parser", ".", "next", "(", ")", ";", "try", "{", "serverPort", "=", "Integer", ".", "parseInt", "(", "parser", ".", "nextText", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "}", "// If we have a valid hostname and port, add", "// it to the list.", "if", "(", "serverName", "!=", "null", "&&", "serverPort", "!=", "-", "1", ")", "{", "STUNService", "service", "=", "new", "STUNService", "(", "serverName", ",", "serverPort", ")", ";", "serversList", ".", "add", "(", "service", ")", ";", "}", "}", "}", "eventType", "=", "parser", ".", "next", "(", ")", ";", "}", "while", "(", "eventType", "!=", "XmlPullParser", ".", "END_DOCUMENT", ")", ";", "}", "catch", "(", "XmlPullParserException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Exception\"", ",", "e", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Exception\"", ",", "e", ")", ";", "}", "currentServer", "=", "bestSTUNServer", "(", "serversList", ")", ";", "return", "serversList", ";", "}" ]
Load the STUN configuration from a stream. @param stunConfigStream An InputStream with the configuration file. @return A list of loaded servers
[ "Load", "the", "STUN", "configuration", "from", "a", "stream", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUNResolver.java#L138-L197
26,502
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUNResolver.java
STUNResolver.bestSTUNServer
private STUNService bestSTUNServer(ArrayList<STUNService> listServers) { if (listServers.isEmpty()) { return null; } else { // TODO: this should use some more advanced criteria... return listServers.get(0); } }
java
private STUNService bestSTUNServer(ArrayList<STUNService> listServers) { if (listServers.isEmpty()) { return null; } else { // TODO: this should use some more advanced criteria... return listServers.get(0); } }
[ "private", "STUNService", "bestSTUNServer", "(", "ArrayList", "<", "STUNService", ">", "listServers", ")", "{", "if", "(", "listServers", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "else", "{", "// TODO: this should use some more advanced criteria...", "return", "listServers", ".", "get", "(", "0", ")", ";", "}", "}" ]
Get the best usable STUN server from a list. @return the best STUN server that can be used.
[ "Get", "the", "best", "usable", "STUN", "server", "from", "a", "list", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUNResolver.java#L257-L264
26,503
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUNResolver.java
STUNResolver.initialize
@Override public void initialize() throws XMPPException { LOGGER.fine("Initialized"); if (!isResolving() && !isResolved()) { // Get the best STUN server available if (currentServer.isNull()) { loadSTUNServers(); } // We should have a valid STUN server by now... if (!currentServer.isNull()) { clearCandidates(); resolverThread = new Thread(new Runnable() { @Override public void run() { // Iterate through the list of interfaces, and ask // to the STUN server for our address. try { Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); String candAddress; int candPort; while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses(); while (iaddresses.hasMoreElements()) { InetAddress iaddress = iaddresses.nextElement(); if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) { // Reset the candidate candAddress = null; candPort = -1; DiscoveryTest test = new DiscoveryTest(iaddress, currentServer.getHostname(), currentServer.getPort()); try { // Run the tests and get the // discovery // information, where all the // info is stored... DiscoveryInfo di = test.test(); candAddress = di.getPublicIP() != null ? di.getPublicIP().getHostAddress() : null; // Get a valid port if (defaultPort == 0) { candPort = getFreePort(); } else { candPort = defaultPort; } // If we have a valid candidate, // add it to the list. if (candAddress != null && candPort >= 0) { TransportCandidate candidate = new TransportCandidate.Fixed( candAddress, candPort); candidate.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName()); addCandidate(candidate); resolvedPublicIP = candidate.getIp(); resolvedLocalIP = candidate.getLocalIp(); return; } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Exception", e); } } } } } catch (SocketException e) { LOGGER.log(Level.SEVERE, "Exception", e); } finally { setInitialized(); } } }, "Waiting for all the transport candidates checks..."); resolverThread.setName("STUN resolver"); resolverThread.start(); } else { throw new IllegalStateException("No valid STUN server found."); } } }
java
@Override public void initialize() throws XMPPException { LOGGER.fine("Initialized"); if (!isResolving() && !isResolved()) { // Get the best STUN server available if (currentServer.isNull()) { loadSTUNServers(); } // We should have a valid STUN server by now... if (!currentServer.isNull()) { clearCandidates(); resolverThread = new Thread(new Runnable() { @Override public void run() { // Iterate through the list of interfaces, and ask // to the STUN server for our address. try { Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); String candAddress; int candPort; while (ifaces.hasMoreElements()) { NetworkInterface iface = ifaces.nextElement(); Enumeration<InetAddress> iaddresses = iface.getInetAddresses(); while (iaddresses.hasMoreElements()) { InetAddress iaddress = iaddresses.nextElement(); if (!iaddress.isLoopbackAddress() && !iaddress.isLinkLocalAddress()) { // Reset the candidate candAddress = null; candPort = -1; DiscoveryTest test = new DiscoveryTest(iaddress, currentServer.getHostname(), currentServer.getPort()); try { // Run the tests and get the // discovery // information, where all the // info is stored... DiscoveryInfo di = test.test(); candAddress = di.getPublicIP() != null ? di.getPublicIP().getHostAddress() : null; // Get a valid port if (defaultPort == 0) { candPort = getFreePort(); } else { candPort = defaultPort; } // If we have a valid candidate, // add it to the list. if (candAddress != null && candPort >= 0) { TransportCandidate candidate = new TransportCandidate.Fixed( candAddress, candPort); candidate.setLocalIp(iaddress.getHostAddress() != null ? iaddress.getHostAddress() : iaddress.getHostName()); addCandidate(candidate); resolvedPublicIP = candidate.getIp(); resolvedLocalIP = candidate.getLocalIp(); return; } } catch (Exception e) { LOGGER.log(Level.SEVERE, "Exception", e); } } } } } catch (SocketException e) { LOGGER.log(Level.SEVERE, "Exception", e); } finally { setInitialized(); } } }, "Waiting for all the transport candidates checks..."); resolverThread.setName("STUN resolver"); resolverThread.start(); } else { throw new IllegalStateException("No valid STUN server found."); } } }
[ "@", "Override", "public", "void", "initialize", "(", ")", "throws", "XMPPException", "{", "LOGGER", ".", "fine", "(", "\"Initialized\"", ")", ";", "if", "(", "!", "isResolving", "(", ")", "&&", "!", "isResolved", "(", ")", ")", "{", "// Get the best STUN server available", "if", "(", "currentServer", ".", "isNull", "(", ")", ")", "{", "loadSTUNServers", "(", ")", ";", "}", "// We should have a valid STUN server by now...", "if", "(", "!", "currentServer", ".", "isNull", "(", ")", ")", "{", "clearCandidates", "(", ")", ";", "resolverThread", "=", "new", "Thread", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "// Iterate through the list of interfaces, and ask", "// to the STUN server for our address.", "try", "{", "Enumeration", "<", "NetworkInterface", ">", "ifaces", "=", "NetworkInterface", ".", "getNetworkInterfaces", "(", ")", ";", "String", "candAddress", ";", "int", "candPort", ";", "while", "(", "ifaces", ".", "hasMoreElements", "(", ")", ")", "{", "NetworkInterface", "iface", "=", "ifaces", ".", "nextElement", "(", ")", ";", "Enumeration", "<", "InetAddress", ">", "iaddresses", "=", "iface", ".", "getInetAddresses", "(", ")", ";", "while", "(", "iaddresses", ".", "hasMoreElements", "(", ")", ")", "{", "InetAddress", "iaddress", "=", "iaddresses", ".", "nextElement", "(", ")", ";", "if", "(", "!", "iaddress", ".", "isLoopbackAddress", "(", ")", "&&", "!", "iaddress", ".", "isLinkLocalAddress", "(", ")", ")", "{", "// Reset the candidate", "candAddress", "=", "null", ";", "candPort", "=", "-", "1", ";", "DiscoveryTest", "test", "=", "new", "DiscoveryTest", "(", "iaddress", ",", "currentServer", ".", "getHostname", "(", ")", ",", "currentServer", ".", "getPort", "(", ")", ")", ";", "try", "{", "// Run the tests and get the", "// discovery", "// information, where all the", "// info is stored...", "DiscoveryInfo", "di", "=", "test", ".", "test", "(", ")", ";", "candAddress", "=", "di", ".", "getPublicIP", "(", ")", "!=", "null", "?", "di", ".", "getPublicIP", "(", ")", ".", "getHostAddress", "(", ")", ":", "null", ";", "// Get a valid port", "if", "(", "defaultPort", "==", "0", ")", "{", "candPort", "=", "getFreePort", "(", ")", ";", "}", "else", "{", "candPort", "=", "defaultPort", ";", "}", "// If we have a valid candidate,", "// add it to the list.", "if", "(", "candAddress", "!=", "null", "&&", "candPort", ">=", "0", ")", "{", "TransportCandidate", "candidate", "=", "new", "TransportCandidate", ".", "Fixed", "(", "candAddress", ",", "candPort", ")", ";", "candidate", ".", "setLocalIp", "(", "iaddress", ".", "getHostAddress", "(", ")", "!=", "null", "?", "iaddress", ".", "getHostAddress", "(", ")", ":", "iaddress", ".", "getHostName", "(", ")", ")", ";", "addCandidate", "(", "candidate", ")", ";", "resolvedPublicIP", "=", "candidate", ".", "getIp", "(", ")", ";", "resolvedLocalIP", "=", "candidate", ".", "getLocalIp", "(", ")", ";", "return", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Exception\"", ",", "e", ")", ";", "}", "}", "}", "}", "}", "catch", "(", "SocketException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Exception\"", ",", "e", ")", ";", "}", "finally", "{", "setInitialized", "(", ")", ";", "}", "}", "}", ",", "\"Waiting for all the transport candidates checks...\"", ")", ";", "resolverThread", ".", "setName", "(", "\"STUN resolver\"", ")", ";", "resolverThread", ".", "start", "(", ")", ";", "}", "else", "{", "throw", "new", "IllegalStateException", "(", "\"No valid STUN server found.\"", ")", ";", "}", "}", "}" ]
Initialize the resolver. @throws XMPPException
[ "Initialize", "the", "resolver", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUNResolver.java#L295-L387
26,504
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java
OmemoRatchet.retrieveMessageKeyAndAuthTag
CipherAndAuthTag retrieveMessageKeyAndAuthTag(OmemoDevice sender, OmemoElement element) throws CryptoFailedException, NoRawSessionException { int keyId = omemoManager.getDeviceId(); byte[] unpackedKey = null; List<CryptoFailedException> decryptExceptions = new ArrayList<>(); List<OmemoKeyElement> keys = element.getHeader().getKeys(); boolean preKey = false; // Find key with our ID. for (OmemoKeyElement k : keys) { if (k.getId() == keyId) { try { unpackedKey = doubleRatchetDecrypt(sender, k.getData()); preKey = k.isPreKey(); break; } catch (CryptoFailedException e) { // There might be multiple keys with our id, but we can only decrypt one. // So we can't throw the exception, when decrypting the first duplicate which is not for us. decryptExceptions.add(e); } catch (CorruptedOmemoKeyException e) { decryptExceptions.add(new CryptoFailedException(e)); } catch (UntrustedOmemoIdentityException e) { LOGGER.log(Level.WARNING, "Received message from " + sender + " contained unknown identityKey. Ignore message.", e); } } } if (unpackedKey == null) { if (!decryptExceptions.isEmpty()) { throw MultipleCryptoFailedException.from(decryptExceptions); } throw new CryptoFailedException("Transported key could not be decrypted, since no suitable message key " + "was provided. Provides keys: " + keys); } // Split in AES auth-tag and key byte[] messageKey = new byte[16]; byte[] authTag = null; if (unpackedKey.length == 32) { authTag = new byte[16]; // copy key part into messageKey System.arraycopy(unpackedKey, 0, messageKey, 0, 16); // copy tag part into authTag System.arraycopy(unpackedKey, 16, authTag, 0,16); } else if (element.isKeyTransportElement() && unpackedKey.length == 16) { messageKey = unpackedKey; } else { throw new CryptoFailedException("MessageKey has wrong length: " + unpackedKey.length + ". Probably legacy auth tag format."); } return new CipherAndAuthTag(messageKey, element.getHeader().getIv(), authTag, preKey); }
java
CipherAndAuthTag retrieveMessageKeyAndAuthTag(OmemoDevice sender, OmemoElement element) throws CryptoFailedException, NoRawSessionException { int keyId = omemoManager.getDeviceId(); byte[] unpackedKey = null; List<CryptoFailedException> decryptExceptions = new ArrayList<>(); List<OmemoKeyElement> keys = element.getHeader().getKeys(); boolean preKey = false; // Find key with our ID. for (OmemoKeyElement k : keys) { if (k.getId() == keyId) { try { unpackedKey = doubleRatchetDecrypt(sender, k.getData()); preKey = k.isPreKey(); break; } catch (CryptoFailedException e) { // There might be multiple keys with our id, but we can only decrypt one. // So we can't throw the exception, when decrypting the first duplicate which is not for us. decryptExceptions.add(e); } catch (CorruptedOmemoKeyException e) { decryptExceptions.add(new CryptoFailedException(e)); } catch (UntrustedOmemoIdentityException e) { LOGGER.log(Level.WARNING, "Received message from " + sender + " contained unknown identityKey. Ignore message.", e); } } } if (unpackedKey == null) { if (!decryptExceptions.isEmpty()) { throw MultipleCryptoFailedException.from(decryptExceptions); } throw new CryptoFailedException("Transported key could not be decrypted, since no suitable message key " + "was provided. Provides keys: " + keys); } // Split in AES auth-tag and key byte[] messageKey = new byte[16]; byte[] authTag = null; if (unpackedKey.length == 32) { authTag = new byte[16]; // copy key part into messageKey System.arraycopy(unpackedKey, 0, messageKey, 0, 16); // copy tag part into authTag System.arraycopy(unpackedKey, 16, authTag, 0,16); } else if (element.isKeyTransportElement() && unpackedKey.length == 16) { messageKey = unpackedKey; } else { throw new CryptoFailedException("MessageKey has wrong length: " + unpackedKey.length + ". Probably legacy auth tag format."); } return new CipherAndAuthTag(messageKey, element.getHeader().getIv(), authTag, preKey); }
[ "CipherAndAuthTag", "retrieveMessageKeyAndAuthTag", "(", "OmemoDevice", "sender", ",", "OmemoElement", "element", ")", "throws", "CryptoFailedException", ",", "NoRawSessionException", "{", "int", "keyId", "=", "omemoManager", ".", "getDeviceId", "(", ")", ";", "byte", "[", "]", "unpackedKey", "=", "null", ";", "List", "<", "CryptoFailedException", ">", "decryptExceptions", "=", "new", "ArrayList", "<>", "(", ")", ";", "List", "<", "OmemoKeyElement", ">", "keys", "=", "element", ".", "getHeader", "(", ")", ".", "getKeys", "(", ")", ";", "boolean", "preKey", "=", "false", ";", "// Find key with our ID.", "for", "(", "OmemoKeyElement", "k", ":", "keys", ")", "{", "if", "(", "k", ".", "getId", "(", ")", "==", "keyId", ")", "{", "try", "{", "unpackedKey", "=", "doubleRatchetDecrypt", "(", "sender", ",", "k", ".", "getData", "(", ")", ")", ";", "preKey", "=", "k", ".", "isPreKey", "(", ")", ";", "break", ";", "}", "catch", "(", "CryptoFailedException", "e", ")", "{", "// There might be multiple keys with our id, but we can only decrypt one.", "// So we can't throw the exception, when decrypting the first duplicate which is not for us.", "decryptExceptions", ".", "add", "(", "e", ")", ";", "}", "catch", "(", "CorruptedOmemoKeyException", "e", ")", "{", "decryptExceptions", ".", "add", "(", "new", "CryptoFailedException", "(", "e", ")", ")", ";", "}", "catch", "(", "UntrustedOmemoIdentityException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "WARNING", ",", "\"Received message from \"", "+", "sender", "+", "\" contained unknown identityKey. Ignore message.\"", ",", "e", ")", ";", "}", "}", "}", "if", "(", "unpackedKey", "==", "null", ")", "{", "if", "(", "!", "decryptExceptions", ".", "isEmpty", "(", ")", ")", "{", "throw", "MultipleCryptoFailedException", ".", "from", "(", "decryptExceptions", ")", ";", "}", "throw", "new", "CryptoFailedException", "(", "\"Transported key could not be decrypted, since no suitable message key \"", "+", "\"was provided. Provides keys: \"", "+", "keys", ")", ";", "}", "// Split in AES auth-tag and key", "byte", "[", "]", "messageKey", "=", "new", "byte", "[", "16", "]", ";", "byte", "[", "]", "authTag", "=", "null", ";", "if", "(", "unpackedKey", ".", "length", "==", "32", ")", "{", "authTag", "=", "new", "byte", "[", "16", "]", ";", "// copy key part into messageKey", "System", ".", "arraycopy", "(", "unpackedKey", ",", "0", ",", "messageKey", ",", "0", ",", "16", ")", ";", "// copy tag part into authTag", "System", ".", "arraycopy", "(", "unpackedKey", ",", "16", ",", "authTag", ",", "0", ",", "16", ")", ";", "}", "else", "if", "(", "element", ".", "isKeyTransportElement", "(", ")", "&&", "unpackedKey", ".", "length", "==", "16", ")", "{", "messageKey", "=", "unpackedKey", ";", "}", "else", "{", "throw", "new", "CryptoFailedException", "(", "\"MessageKey has wrong length: \"", "+", "unpackedKey", ".", "length", "+", "\". Probably legacy auth tag format.\"", ")", ";", "}", "return", "new", "CipherAndAuthTag", "(", "messageKey", ",", "element", ".", "getHeader", "(", ")", ".", "getIv", "(", ")", ",", "authTag", ",", "preKey", ")", ";", "}" ]
Try to decrypt the transported message key using the double ratchet session. @param element omemoElement @return tuple of cipher generated from the unpacked message key and the auth-tag @throws CryptoFailedException if decryption using the double ratchet fails @throws NoRawSessionException if we have no session, but the element was NOT a PreKeyMessage
[ "Try", "to", "decrypt", "the", "transported", "message", "key", "using", "the", "double", "ratchet", "session", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java#L90-L145
26,505
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java
OmemoRatchet.decryptMessageElement
static String decryptMessageElement(OmemoElement element, CipherAndAuthTag cipherAndAuthTag) throws CryptoFailedException { if (!element.isMessageElement()) { throw new IllegalArgumentException("decryptMessageElement cannot decrypt OmemoElement which is no MessageElement!"); } if (cipherAndAuthTag.getAuthTag() == null || cipherAndAuthTag.getAuthTag().length != 16) { throw new CryptoFailedException("AuthenticationTag is null or has wrong length: " + (cipherAndAuthTag.getAuthTag() == null ? "null" : cipherAndAuthTag.getAuthTag().length)); } byte[] encryptedBody = payloadAndAuthTag(element, cipherAndAuthTag.getAuthTag()); try { String plaintext = new String(cipherAndAuthTag.getCipher().doFinal(encryptedBody), StringUtils.UTF8); return plaintext; } catch (UnsupportedEncodingException | IllegalBlockSizeException | BadPaddingException e) { throw new CryptoFailedException("decryptMessageElement could not decipher message body: " + e.getMessage()); } }
java
static String decryptMessageElement(OmemoElement element, CipherAndAuthTag cipherAndAuthTag) throws CryptoFailedException { if (!element.isMessageElement()) { throw new IllegalArgumentException("decryptMessageElement cannot decrypt OmemoElement which is no MessageElement!"); } if (cipherAndAuthTag.getAuthTag() == null || cipherAndAuthTag.getAuthTag().length != 16) { throw new CryptoFailedException("AuthenticationTag is null or has wrong length: " + (cipherAndAuthTag.getAuthTag() == null ? "null" : cipherAndAuthTag.getAuthTag().length)); } byte[] encryptedBody = payloadAndAuthTag(element, cipherAndAuthTag.getAuthTag()); try { String plaintext = new String(cipherAndAuthTag.getCipher().doFinal(encryptedBody), StringUtils.UTF8); return plaintext; } catch (UnsupportedEncodingException | IllegalBlockSizeException | BadPaddingException e) { throw new CryptoFailedException("decryptMessageElement could not decipher message body: " + e.getMessage()); } }
[ "static", "String", "decryptMessageElement", "(", "OmemoElement", "element", ",", "CipherAndAuthTag", "cipherAndAuthTag", ")", "throws", "CryptoFailedException", "{", "if", "(", "!", "element", ".", "isMessageElement", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"decryptMessageElement cannot decrypt OmemoElement which is no MessageElement!\"", ")", ";", "}", "if", "(", "cipherAndAuthTag", ".", "getAuthTag", "(", ")", "==", "null", "||", "cipherAndAuthTag", ".", "getAuthTag", "(", ")", ".", "length", "!=", "16", ")", "{", "throw", "new", "CryptoFailedException", "(", "\"AuthenticationTag is null or has wrong length: \"", "+", "(", "cipherAndAuthTag", ".", "getAuthTag", "(", ")", "==", "null", "?", "\"null\"", ":", "cipherAndAuthTag", ".", "getAuthTag", "(", ")", ".", "length", ")", ")", ";", "}", "byte", "[", "]", "encryptedBody", "=", "payloadAndAuthTag", "(", "element", ",", "cipherAndAuthTag", ".", "getAuthTag", "(", ")", ")", ";", "try", "{", "String", "plaintext", "=", "new", "String", "(", "cipherAndAuthTag", ".", "getCipher", "(", ")", ".", "doFinal", "(", "encryptedBody", ")", ",", "StringUtils", ".", "UTF8", ")", ";", "return", "plaintext", ";", "}", "catch", "(", "UnsupportedEncodingException", "|", "IllegalBlockSizeException", "|", "BadPaddingException", "e", ")", "{", "throw", "new", "CryptoFailedException", "(", "\"decryptMessageElement could not decipher message body: \"", "+", "e", ".", "getMessage", "(", ")", ")", ";", "}", "}" ]
Use the symmetric key in cipherAndAuthTag to decrypt the payload of the omemoMessage. The decrypted payload will be the body of the returned Message. @param element omemoElement containing a payload. @param cipherAndAuthTag cipher and authentication tag. @return decrypted plain text. @throws CryptoFailedException if decryption using AES key fails.
[ "Use", "the", "symmetric", "key", "in", "cipherAndAuthTag", "to", "decrypt", "the", "payload", "of", "the", "omemoMessage", ".", "The", "decrypted", "payload", "will", "be", "the", "body", "of", "the", "returned", "Message", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java#L156-L177
26,506
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java
OmemoRatchet.payloadAndAuthTag
static byte[] payloadAndAuthTag(OmemoElement element, byte[] authTag) { if (!element.isMessageElement()) { throw new IllegalArgumentException("OmemoElement has no payload."); } byte[] payload = new byte[element.getPayload().length + authTag.length]; System.arraycopy(element.getPayload(), 0, payload, 0, element.getPayload().length); System.arraycopy(authTag, 0, payload, element.getPayload().length, authTag.length); return payload; }
java
static byte[] payloadAndAuthTag(OmemoElement element, byte[] authTag) { if (!element.isMessageElement()) { throw new IllegalArgumentException("OmemoElement has no payload."); } byte[] payload = new byte[element.getPayload().length + authTag.length]; System.arraycopy(element.getPayload(), 0, payload, 0, element.getPayload().length); System.arraycopy(authTag, 0, payload, element.getPayload().length, authTag.length); return payload; }
[ "static", "byte", "[", "]", "payloadAndAuthTag", "(", "OmemoElement", "element", ",", "byte", "[", "]", "authTag", ")", "{", "if", "(", "!", "element", ".", "isMessageElement", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"OmemoElement has no payload.\"", ")", ";", "}", "byte", "[", "]", "payload", "=", "new", "byte", "[", "element", ".", "getPayload", "(", ")", ".", "length", "+", "authTag", ".", "length", "]", ";", "System", ".", "arraycopy", "(", "element", ".", "getPayload", "(", ")", ",", "0", ",", "payload", ",", "0", ",", "element", ".", "getPayload", "(", ")", ".", "length", ")", ";", "System", ".", "arraycopy", "(", "authTag", ",", "0", ",", "payload", ",", "element", ".", "getPayload", "(", ")", ".", "length", ",", "authTag", ".", "length", ")", ";", "return", "payload", ";", "}" ]
Return the concatenation of the payload of the OmemoElement and the given auth tag. @param element omemoElement (message element) @param authTag authTag @return payload + authTag
[ "Return", "the", "concatenation", "of", "the", "payload", "of", "the", "OmemoElement", "and", "the", "given", "auth", "tag", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoRatchet.java#L186-L195
26,507
igniterealtime/Smack
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
EnhancedDebugger.updateStatistics
private void updateStatistics() { statisticsTable.setValueAt(Integer.valueOf(receivedIQPackets), 0, 1); statisticsTable.setValueAt(Integer.valueOf(sentIQPackets), 0, 2); statisticsTable.setValueAt(Integer.valueOf(receivedMessagePackets), 1, 1); statisticsTable.setValueAt(Integer.valueOf(sentMessagePackets), 1, 2); statisticsTable.setValueAt(Integer.valueOf(receivedPresencePackets), 2, 1); statisticsTable.setValueAt(Integer.valueOf(sentPresencePackets), 2, 2); statisticsTable.setValueAt(Integer.valueOf(receivedOtherPackets), 3, 1); statisticsTable.setValueAt(Integer.valueOf(sentOtherPackets), 3, 2); statisticsTable.setValueAt(Integer.valueOf(receivedPackets), 4, 1); statisticsTable.setValueAt(Integer.valueOf(sentPackets), 4, 2); }
java
private void updateStatistics() { statisticsTable.setValueAt(Integer.valueOf(receivedIQPackets), 0, 1); statisticsTable.setValueAt(Integer.valueOf(sentIQPackets), 0, 2); statisticsTable.setValueAt(Integer.valueOf(receivedMessagePackets), 1, 1); statisticsTable.setValueAt(Integer.valueOf(sentMessagePackets), 1, 2); statisticsTable.setValueAt(Integer.valueOf(receivedPresencePackets), 2, 1); statisticsTable.setValueAt(Integer.valueOf(sentPresencePackets), 2, 2); statisticsTable.setValueAt(Integer.valueOf(receivedOtherPackets), 3, 1); statisticsTable.setValueAt(Integer.valueOf(sentOtherPackets), 3, 2); statisticsTable.setValueAt(Integer.valueOf(receivedPackets), 4, 1); statisticsTable.setValueAt(Integer.valueOf(sentPackets), 4, 2); }
[ "private", "void", "updateStatistics", "(", ")", "{", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "receivedIQPackets", ")", ",", "0", ",", "1", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "sentIQPackets", ")", ",", "0", ",", "2", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "receivedMessagePackets", ")", ",", "1", ",", "1", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "sentMessagePackets", ")", ",", "1", ",", "2", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "receivedPresencePackets", ")", ",", "2", ",", "1", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "sentPresencePackets", ")", ",", "2", ",", "2", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "receivedOtherPackets", ")", ",", "3", ",", "1", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "sentOtherPackets", ")", ",", "3", ",", "2", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "receivedPackets", ")", ",", "4", ",", "1", ")", ";", "statisticsTable", ".", "setValueAt", "(", "Integer", ".", "valueOf", "(", "sentPackets", ")", ",", "4", ",", "2", ")", ";", "}" ]
Updates the statistics table
[ "Updates", "the", "statistics", "table" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java#L741-L756
26,508
igniterealtime/Smack
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
EnhancedDebugger.addReadPacketToTable
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final TopLevelStreamElement packet) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String messageType; Jid from; String stanzaId; if (packet instanceof Stanza) { Stanza stanza = (Stanza) packet; from = stanza.getFrom(); stanzaId = stanza.getStanzaId(); } else { from = null; stanzaId = "(Nonza)"; } String type = ""; Icon packetTypeIcon; receivedPackets++; if (packet instanceof IQ) { packetTypeIcon = iqPacketIcon; messageType = "IQ Received (class=" + packet.getClass().getName() + ")"; type = ((IQ) packet).getType().toString(); receivedIQPackets++; } else if (packet instanceof Message) { packetTypeIcon = messagePacketIcon; messageType = "Message Received"; type = ((Message) packet).getType().toString(); receivedMessagePackets++; } else if (packet instanceof Presence) { packetTypeIcon = presencePacketIcon; messageType = "Presence Received"; type = ((Presence) packet).getType().toString(); receivedPresencePackets++; } else { packetTypeIcon = unknownPacketTypeIcon; messageType = packet.getClass().getName() + " Received"; receivedOtherPackets++; } // Check if we need to remove old rows from the table to keep memory consumption low if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 && messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) { messagesTable.removeRow(0); } messagesTable.addRow( new Object[] { XmlUtil.prettyFormatXml(packet.toXML().toString()), dateFormatter.format(new Date()), packetReceivedIcon, packetTypeIcon, messageType, stanzaId, type, "", from}); // Update the statistics table updateStatistics(); } }); }
java
private void addReadPacketToTable(final SimpleDateFormat dateFormatter, final TopLevelStreamElement packet) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String messageType; Jid from; String stanzaId; if (packet instanceof Stanza) { Stanza stanza = (Stanza) packet; from = stanza.getFrom(); stanzaId = stanza.getStanzaId(); } else { from = null; stanzaId = "(Nonza)"; } String type = ""; Icon packetTypeIcon; receivedPackets++; if (packet instanceof IQ) { packetTypeIcon = iqPacketIcon; messageType = "IQ Received (class=" + packet.getClass().getName() + ")"; type = ((IQ) packet).getType().toString(); receivedIQPackets++; } else if (packet instanceof Message) { packetTypeIcon = messagePacketIcon; messageType = "Message Received"; type = ((Message) packet).getType().toString(); receivedMessagePackets++; } else if (packet instanceof Presence) { packetTypeIcon = presencePacketIcon; messageType = "Presence Received"; type = ((Presence) packet).getType().toString(); receivedPresencePackets++; } else { packetTypeIcon = unknownPacketTypeIcon; messageType = packet.getClass().getName() + " Received"; receivedOtherPackets++; } // Check if we need to remove old rows from the table to keep memory consumption low if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 && messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) { messagesTable.removeRow(0); } messagesTable.addRow( new Object[] { XmlUtil.prettyFormatXml(packet.toXML().toString()), dateFormatter.format(new Date()), packetReceivedIcon, packetTypeIcon, messageType, stanzaId, type, "", from}); // Update the statistics table updateStatistics(); } }); }
[ "private", "void", "addReadPacketToTable", "(", "final", "SimpleDateFormat", "dateFormatter", ",", "final", "TopLevelStreamElement", "packet", ")", "{", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "String", "messageType", ";", "Jid", "from", ";", "String", "stanzaId", ";", "if", "(", "packet", "instanceof", "Stanza", ")", "{", "Stanza", "stanza", "=", "(", "Stanza", ")", "packet", ";", "from", "=", "stanza", ".", "getFrom", "(", ")", ";", "stanzaId", "=", "stanza", ".", "getStanzaId", "(", ")", ";", "}", "else", "{", "from", "=", "null", ";", "stanzaId", "=", "\"(Nonza)\"", ";", "}", "String", "type", "=", "\"\"", ";", "Icon", "packetTypeIcon", ";", "receivedPackets", "++", ";", "if", "(", "packet", "instanceof", "IQ", ")", "{", "packetTypeIcon", "=", "iqPacketIcon", ";", "messageType", "=", "\"IQ Received (class=\"", "+", "packet", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\")\"", ";", "type", "=", "(", "(", "IQ", ")", "packet", ")", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "receivedIQPackets", "++", ";", "}", "else", "if", "(", "packet", "instanceof", "Message", ")", "{", "packetTypeIcon", "=", "messagePacketIcon", ";", "messageType", "=", "\"Message Received\"", ";", "type", "=", "(", "(", "Message", ")", "packet", ")", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "receivedMessagePackets", "++", ";", "}", "else", "if", "(", "packet", "instanceof", "Presence", ")", "{", "packetTypeIcon", "=", "presencePacketIcon", ";", "messageType", "=", "\"Presence Received\"", ";", "type", "=", "(", "(", "Presence", ")", "packet", ")", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "receivedPresencePackets", "++", ";", "}", "else", "{", "packetTypeIcon", "=", "unknownPacketTypeIcon", ";", "messageType", "=", "packet", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\" Received\"", ";", "receivedOtherPackets", "++", ";", "}", "// Check if we need to remove old rows from the table to keep memory consumption low", "if", "(", "EnhancedDebuggerWindow", ".", "MAX_TABLE_ROWS", ">", "0", "&&", "messagesTable", ".", "getRowCount", "(", ")", ">=", "EnhancedDebuggerWindow", ".", "MAX_TABLE_ROWS", ")", "{", "messagesTable", ".", "removeRow", "(", "0", ")", ";", "}", "messagesTable", ".", "addRow", "(", "new", "Object", "[", "]", "{", "XmlUtil", ".", "prettyFormatXml", "(", "packet", ".", "toXML", "(", ")", ".", "toString", "(", ")", ")", ",", "dateFormatter", ".", "format", "(", "new", "Date", "(", ")", ")", ",", "packetReceivedIcon", ",", "packetTypeIcon", ",", "messageType", ",", "stanzaId", ",", "type", ",", "\"\"", ",", "from", "}", ")", ";", "// Update the statistics table", "updateStatistics", "(", ")", ";", "}", "}", ")", ";", "}" ]
Adds the received stanza detail to the messages table. @param dateFormatter the SimpleDateFormat to use to format Dates @param packet the read stanza to add to the table
[ "Adds", "the", "received", "stanza", "detail", "to", "the", "messages", "table", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java#L764-L827
26,509
igniterealtime/Smack
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
EnhancedDebugger.addSentPacketToTable
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final TopLevelStreamElement packet) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String messageType; Jid to; String stanzaId; if (packet instanceof Stanza) { Stanza stanza = (Stanza) packet; to = stanza.getTo(); stanzaId = stanza.getStanzaId(); } else { to = null; stanzaId = "(Nonza)"; } String type = ""; Icon packetTypeIcon; sentPackets++; if (packet instanceof IQ) { packetTypeIcon = iqPacketIcon; messageType = "IQ Sent (class=" + packet.getClass().getName() + ")"; type = ((IQ) packet).getType().toString(); sentIQPackets++; } else if (packet instanceof Message) { packetTypeIcon = messagePacketIcon; messageType = "Message Sent"; type = ((Message) packet).getType().toString(); sentMessagePackets++; } else if (packet instanceof Presence) { packetTypeIcon = presencePacketIcon; messageType = "Presence Sent"; type = ((Presence) packet).getType().toString(); sentPresencePackets++; } else { packetTypeIcon = unknownPacketTypeIcon; messageType = packet.getClass().getName() + " Sent"; sentOtherPackets++; } // Check if we need to remove old rows from the table to keep memory consumption low if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 && messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) { messagesTable.removeRow(0); } messagesTable.addRow( new Object[] { XmlUtil.prettyFormatXml(packet.toXML().toString()), dateFormatter.format(new Date()), packetSentIcon, packetTypeIcon, messageType, stanzaId, type, to, ""}); // Update the statistics table updateStatistics(); } }); }
java
private void addSentPacketToTable(final SimpleDateFormat dateFormatter, final TopLevelStreamElement packet) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { String messageType; Jid to; String stanzaId; if (packet instanceof Stanza) { Stanza stanza = (Stanza) packet; to = stanza.getTo(); stanzaId = stanza.getStanzaId(); } else { to = null; stanzaId = "(Nonza)"; } String type = ""; Icon packetTypeIcon; sentPackets++; if (packet instanceof IQ) { packetTypeIcon = iqPacketIcon; messageType = "IQ Sent (class=" + packet.getClass().getName() + ")"; type = ((IQ) packet).getType().toString(); sentIQPackets++; } else if (packet instanceof Message) { packetTypeIcon = messagePacketIcon; messageType = "Message Sent"; type = ((Message) packet).getType().toString(); sentMessagePackets++; } else if (packet instanceof Presence) { packetTypeIcon = presencePacketIcon; messageType = "Presence Sent"; type = ((Presence) packet).getType().toString(); sentPresencePackets++; } else { packetTypeIcon = unknownPacketTypeIcon; messageType = packet.getClass().getName() + " Sent"; sentOtherPackets++; } // Check if we need to remove old rows from the table to keep memory consumption low if (EnhancedDebuggerWindow.MAX_TABLE_ROWS > 0 && messagesTable.getRowCount() >= EnhancedDebuggerWindow.MAX_TABLE_ROWS) { messagesTable.removeRow(0); } messagesTable.addRow( new Object[] { XmlUtil.prettyFormatXml(packet.toXML().toString()), dateFormatter.format(new Date()), packetSentIcon, packetTypeIcon, messageType, stanzaId, type, to, ""}); // Update the statistics table updateStatistics(); } }); }
[ "private", "void", "addSentPacketToTable", "(", "final", "SimpleDateFormat", "dateFormatter", ",", "final", "TopLevelStreamElement", "packet", ")", "{", "SwingUtilities", ".", "invokeLater", "(", "new", "Runnable", "(", ")", "{", "@", "Override", "public", "void", "run", "(", ")", "{", "String", "messageType", ";", "Jid", "to", ";", "String", "stanzaId", ";", "if", "(", "packet", "instanceof", "Stanza", ")", "{", "Stanza", "stanza", "=", "(", "Stanza", ")", "packet", ";", "to", "=", "stanza", ".", "getTo", "(", ")", ";", "stanzaId", "=", "stanza", ".", "getStanzaId", "(", ")", ";", "}", "else", "{", "to", "=", "null", ";", "stanzaId", "=", "\"(Nonza)\"", ";", "}", "String", "type", "=", "\"\"", ";", "Icon", "packetTypeIcon", ";", "sentPackets", "++", ";", "if", "(", "packet", "instanceof", "IQ", ")", "{", "packetTypeIcon", "=", "iqPacketIcon", ";", "messageType", "=", "\"IQ Sent (class=\"", "+", "packet", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\")\"", ";", "type", "=", "(", "(", "IQ", ")", "packet", ")", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "sentIQPackets", "++", ";", "}", "else", "if", "(", "packet", "instanceof", "Message", ")", "{", "packetTypeIcon", "=", "messagePacketIcon", ";", "messageType", "=", "\"Message Sent\"", ";", "type", "=", "(", "(", "Message", ")", "packet", ")", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "sentMessagePackets", "++", ";", "}", "else", "if", "(", "packet", "instanceof", "Presence", ")", "{", "packetTypeIcon", "=", "presencePacketIcon", ";", "messageType", "=", "\"Presence Sent\"", ";", "type", "=", "(", "(", "Presence", ")", "packet", ")", ".", "getType", "(", ")", ".", "toString", "(", ")", ";", "sentPresencePackets", "++", ";", "}", "else", "{", "packetTypeIcon", "=", "unknownPacketTypeIcon", ";", "messageType", "=", "packet", ".", "getClass", "(", ")", ".", "getName", "(", ")", "+", "\" Sent\"", ";", "sentOtherPackets", "++", ";", "}", "// Check if we need to remove old rows from the table to keep memory consumption low", "if", "(", "EnhancedDebuggerWindow", ".", "MAX_TABLE_ROWS", ">", "0", "&&", "messagesTable", ".", "getRowCount", "(", ")", ">=", "EnhancedDebuggerWindow", ".", "MAX_TABLE_ROWS", ")", "{", "messagesTable", ".", "removeRow", "(", "0", ")", ";", "}", "messagesTable", ".", "addRow", "(", "new", "Object", "[", "]", "{", "XmlUtil", ".", "prettyFormatXml", "(", "packet", ".", "toXML", "(", ")", ".", "toString", "(", ")", ")", ",", "dateFormatter", ".", "format", "(", "new", "Date", "(", ")", ")", ",", "packetSentIcon", ",", "packetTypeIcon", ",", "messageType", ",", "stanzaId", ",", "type", ",", "to", ",", "\"\"", "}", ")", ";", "// Update the statistics table", "updateStatistics", "(", ")", ";", "}", "}", ")", ";", "}" ]
Adds the sent stanza detail to the messages table. @param dateFormatter the SimpleDateFormat to use to format Dates @param packet the sent stanza to add to the table
[ "Adds", "the", "sent", "stanza", "detail", "to", "the", "messages", "table", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java#L835-L899
26,510
igniterealtime/Smack
smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
EnhancedDebugger.cancel
void cancel() { connection.removeConnectionListener(connListener); ((ObservableReader) reader).removeReaderListener(readerListener); ((ObservableWriter) writer).removeWriterListener(writerListener); messagesTable = null; }
java
void cancel() { connection.removeConnectionListener(connListener); ((ObservableReader) reader).removeReaderListener(readerListener); ((ObservableWriter) writer).removeWriterListener(writerListener); messagesTable = null; }
[ "void", "cancel", "(", ")", "{", "connection", ".", "removeConnectionListener", "(", "connListener", ")", ";", "(", "(", "ObservableReader", ")", "reader", ")", ".", "removeReaderListener", "(", "readerListener", ")", ";", "(", "(", "ObservableWriter", ")", "writer", ")", ".", "removeWriterListener", "(", "writerListener", ")", ";", "messagesTable", "=", "null", ";", "}" ]
Stops debugging the connection. Removes any listener on the connection.
[ "Stops", "debugging", "the", "connection", ".", "Removes", "any", "listener", "on", "the", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java#L913-L918
26,511
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/ObservableWriter.java
ObservableWriter.notifyListeners
private void notifyListeners() { WriterListener[] writerListeners; synchronized (listeners) { writerListeners = new WriterListener[listeners.size()]; listeners.toArray(writerListeners); } String str = stringBuilder.toString(); stringBuilder.setLength(0); for (WriterListener writerListener : writerListeners) { writerListener.write(str); } }
java
private void notifyListeners() { WriterListener[] writerListeners; synchronized (listeners) { writerListeners = new WriterListener[listeners.size()]; listeners.toArray(writerListeners); } String str = stringBuilder.toString(); stringBuilder.setLength(0); for (WriterListener writerListener : writerListeners) { writerListener.write(str); } }
[ "private", "void", "notifyListeners", "(", ")", "{", "WriterListener", "[", "]", "writerListeners", ";", "synchronized", "(", "listeners", ")", "{", "writerListeners", "=", "new", "WriterListener", "[", "listeners", ".", "size", "(", ")", "]", ";", "listeners", ".", "toArray", "(", "writerListeners", ")", ";", "}", "String", "str", "=", "stringBuilder", ".", "toString", "(", ")", ";", "stringBuilder", ".", "setLength", "(", "0", ")", ";", "for", "(", "WriterListener", "writerListener", ":", "writerListeners", ")", "{", "writerListener", ".", "write", "(", "str", ")", ";", "}", "}" ]
Notify that a new string has been written.
[ "Notify", "that", "a", "new", "string", "has", "been", "written", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/ObservableWriter.java#L94-L105
26,512
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/ObservableWriter.java
ObservableWriter.addWriterListener
public void addWriterListener(WriterListener writerListener) { if (writerListener == null) { return; } synchronized (listeners) { if (!listeners.contains(writerListener)) { listeners.add(writerListener); } } }
java
public void addWriterListener(WriterListener writerListener) { if (writerListener == null) { return; } synchronized (listeners) { if (!listeners.contains(writerListener)) { listeners.add(writerListener); } } }
[ "public", "void", "addWriterListener", "(", "WriterListener", "writerListener", ")", "{", "if", "(", "writerListener", "==", "null", ")", "{", "return", ";", "}", "synchronized", "(", "listeners", ")", "{", "if", "(", "!", "listeners", ".", "contains", "(", "writerListener", ")", ")", "{", "listeners", ".", "add", "(", "writerListener", ")", ";", "}", "}", "}" ]
Adds a writer listener to this writer that will be notified when new strings are sent. @param writerListener a writer listener.
[ "Adds", "a", "writer", "listener", "to", "this", "writer", "that", "will", "be", "notified", "when", "new", "strings", "are", "sent", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/ObservableWriter.java#L113-L122
26,513
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java
OfflineMessageManager.supportsFlexibleRetrieval
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection).serverSupportsFeature(namespace); }
java
public boolean supportsFlexibleRetrieval() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection).serverSupportsFeature(namespace); }
[ "public", "boolean", "supportsFlexibleRetrieval", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ".", "serverSupportsFeature", "(", "namespace", ")", ";", "}" ]
Returns true if the server supports Flexible Offline Message Retrieval. When the server supports Flexible Offline Message Retrieval it is possible to get the header of the offline messages, get specific messages, delete specific messages, etc. @return a boolean indicating if the server supports Flexible Offline Message Retrieval. @throws XMPPErrorException If the user is not allowed to make this request. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Returns", "true", "if", "the", "server", "supports", "Flexible", "Offline", "Message", "Retrieval", ".", "When", "the", "server", "supports", "Flexible", "Offline", "Message", "Retrieval", "it", "is", "possible", "to", "get", "the", "header", "of", "the", "offline", "messages", "get", "specific", "messages", "delete", "specific", "messages", "etc", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java#L87-L89
26,514
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java
OfflineMessageManager.getMessageCount
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getFirstValue(); return Integer.parseInt(value); } return 0; }
java
public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getFirstValue(); return Integer.parseInt(value); } return 0; }
[ "public", "int", "getMessageCount", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "DiscoverInfo", "info", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ".", "discoverInfo", "(", "null", ",", "namespace", ")", ";", "Form", "extendedInfo", "=", "Form", ".", "getFormFrom", "(", "info", ")", ";", "if", "(", "extendedInfo", "!=", "null", ")", "{", "String", "value", "=", "extendedInfo", ".", "getField", "(", "\"number_of_messages\"", ")", ".", "getFirstValue", "(", ")", ";", "return", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "return", "0", ";", "}" ]
Returns the number of offline messages for the user of the connection. @return the number of offline messages for the user of the connection. @throws XMPPErrorException If the user is not allowed to make this request or the server does not support offline message retrieval. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "number", "of", "offline", "messages", "for", "the", "user", "of", "the", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java#L101-L110
26,515
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java
OfflineMessageManager.deleteMessages
public void deleteMessages(List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { OfflineMessageRequest request = new OfflineMessageRequest(); request.setType(IQ.Type.set); for (String node : nodes) { OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node); item.setAction("remove"); request.addItem(item); } connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
java
public void deleteMessages(List<String> nodes) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { OfflineMessageRequest request = new OfflineMessageRequest(); request.setType(IQ.Type.set); for (String node : nodes) { OfflineMessageRequest.Item item = new OfflineMessageRequest.Item(node); item.setAction("remove"); request.addItem(item); } connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
[ "public", "void", "deleteMessages", "(", "List", "<", "String", ">", "nodes", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "OfflineMessageRequest", "request", "=", "new", "OfflineMessageRequest", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "for", "(", "String", "node", ":", "nodes", ")", "{", "OfflineMessageRequest", ".", "Item", "item", "=", "new", "OfflineMessageRequest", ".", "Item", "(", "node", ")", ";", "item", ".", "setAction", "(", "\"remove\"", ")", ";", "request", ".", "addItem", "(", "item", ")", ";", "}", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Deletes the specified list of offline messages. The request will include the list of stamps that uniquely identifies the offline messages to delete. @param nodes the list of stamps that uniquely identifies offline message. @throws XMPPErrorException If the user is not allowed to make this request or the server does not support offline message retrieval. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Deletes", "the", "specified", "list", "of", "offline", "messages", ".", "The", "request", "will", "include", "the", "list", "of", "stamps", "that", "uniquely", "identifies", "the", "offline", "messages", "to", "delete", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java#L232-L241
26,516
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java
OfflineMessageManager.deleteMessages
public void deleteMessages() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { OfflineMessageRequest request = new OfflineMessageRequest(); request.setType(IQ.Type.set); request.setPurge(true); connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
java
public void deleteMessages() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { OfflineMessageRequest request = new OfflineMessageRequest(); request.setType(IQ.Type.set); request.setPurge(true); connection.createStanzaCollectorAndSend(request).nextResultOrThrow(); }
[ "public", "void", "deleteMessages", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "OfflineMessageRequest", "request", "=", "new", "OfflineMessageRequest", "(", ")", ";", "request", ".", "setType", "(", "IQ", ".", "Type", ".", "set", ")", ";", "request", ".", "setPurge", "(", "true", ")", ";", "connection", ".", "createStanzaCollectorAndSend", "(", "request", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Deletes all offline messages of the user. @throws XMPPErrorException If the user is not allowed to make this request or the server does not support offline message retrieval. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Deletes", "all", "offline", "messages", "of", "the", "user", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/offline/OfflineMessageManager.java#L252-L257
26,517
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearchManager.java
UserSearchManager.getSearchForm
public Form getSearchForm(DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return userSearch.getSearchForm(con, searchService); }
java
public Form getSearchForm(DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return userSearch.getSearchForm(con, searchService); }
[ "public", "Form", "getSearchForm", "(", "DomainBareJid", "searchService", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "userSearch", ".", "getSearchForm", "(", "con", ",", "searchService", ")", ";", "}" ]
Returns the form to fill out to perform a search. @param searchService the search service to query. @return the form to fill out to perform a search. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "form", "to", "fill", "out", "to", "perform", "a", "search", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearchManager.java#L74-L76
26,518
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearchManager.java
UserSearchManager.getSearchServices
public List<DomainBareJid> getSearchServices() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); return discoManager.findServices(UserSearch.NAMESPACE, false, false); }
java
public List<DomainBareJid> getSearchServices() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(con); return discoManager.findServices(UserSearch.NAMESPACE, false, false); }
[ "public", "List", "<", "DomainBareJid", ">", "getSearchServices", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ServiceDiscoveryManager", "discoManager", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "con", ")", ";", "return", "discoManager", ".", "findServices", "(", "UserSearch", ".", "NAMESPACE", ",", "false", ",", "false", ")", ";", "}" ]
Returns a collection of search services found on the server. @return a Collection of search services found on the server. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "a", "collection", "of", "search", "services", "found", "on", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/search/UserSearchManager.java#L104-L107
26,519
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java
BoBManager.getInstanceFor
public static synchronized BoBManager getInstanceFor(XMPPConnection connection) { BoBManager bobManager = INSTANCES.get(connection); if (bobManager == null) { bobManager = new BoBManager(connection); INSTANCES.put(connection, bobManager); } return bobManager; }
java
public static synchronized BoBManager getInstanceFor(XMPPConnection connection) { BoBManager bobManager = INSTANCES.get(connection); if (bobManager == null) { bobManager = new BoBManager(connection); INSTANCES.put(connection, bobManager); } return bobManager; }
[ "public", "static", "synchronized", "BoBManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "BoBManager", "bobManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "bobManager", "==", "null", ")", "{", "bobManager", "=", "new", "BoBManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "bobManager", ")", ";", "}", "return", "bobManager", ";", "}" ]
Get the singleton instance of BoBManager. @param connection @return the instance of BoBManager
[ "Get", "the", "singleton", "instance", "of", "BoBManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java#L74-L82
26,520
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java
BoBManager.isSupportedByServer
public boolean isSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(NAMESPACE); }
java
public boolean isSupportedByServer() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).serverSupportsFeature(NAMESPACE); }
[ "public", "boolean", "isSupportedByServer", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ".", "serverSupportsFeature", "(", "NAMESPACE", ")", ";", "}" ]
Returns true if Bits of Binary is supported by the server. @return true if Bits of Binary is supported by the server. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Returns", "true", "if", "Bits", "of", "Binary", "is", "supported", "by", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java#L123-L126
26,521
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java
BoBManager.requestBoB
public BoBData requestBoB(Jid to, BoBHash bobHash) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { BoBData bobData = BOB_CACHE.lookup(bobHash); if (bobData != null) { return bobData; } BoBIQ requestBoBIQ = new BoBIQ(bobHash); requestBoBIQ.setType(Type.get); requestBoBIQ.setTo(to); XMPPConnection connection = getAuthenticatedConnectionOrThrow(); BoBIQ responseBoBIQ = connection.createStanzaCollectorAndSend(requestBoBIQ).nextResultOrThrow(); bobData = responseBoBIQ.getBoBData(); BOB_CACHE.put(bobHash, bobData); return bobData; }
java
public BoBData requestBoB(Jid to, BoBHash bobHash) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { BoBData bobData = BOB_CACHE.lookup(bobHash); if (bobData != null) { return bobData; } BoBIQ requestBoBIQ = new BoBIQ(bobHash); requestBoBIQ.setType(Type.get); requestBoBIQ.setTo(to); XMPPConnection connection = getAuthenticatedConnectionOrThrow(); BoBIQ responseBoBIQ = connection.createStanzaCollectorAndSend(requestBoBIQ).nextResultOrThrow(); bobData = responseBoBIQ.getBoBData(); BOB_CACHE.put(bobHash, bobData); return bobData; }
[ "public", "BoBData", "requestBoB", "(", "Jid", "to", ",", "BoBHash", "bobHash", ")", "throws", "NotLoggedInException", ",", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "BoBData", "bobData", "=", "BOB_CACHE", ".", "lookup", "(", "bobHash", ")", ";", "if", "(", "bobData", "!=", "null", ")", "{", "return", "bobData", ";", "}", "BoBIQ", "requestBoBIQ", "=", "new", "BoBIQ", "(", "bobHash", ")", ";", "requestBoBIQ", ".", "setType", "(", "Type", ".", "get", ")", ";", "requestBoBIQ", ".", "setTo", "(", "to", ")", ";", "XMPPConnection", "connection", "=", "getAuthenticatedConnectionOrThrow", "(", ")", ";", "BoBIQ", "responseBoBIQ", "=", "connection", ".", "createStanzaCollectorAndSend", "(", "requestBoBIQ", ")", ".", "nextResultOrThrow", "(", ")", ";", "bobData", "=", "responseBoBIQ", ".", "getBoBData", "(", ")", ";", "BOB_CACHE", ".", "put", "(", "bobHash", ",", "bobData", ")", ";", "return", "bobData", ";", "}" ]
Request BoB data. @param to @param bobHash @return the BoB data @throws NotLoggedInException @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Request", "BoB", "data", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/bob/BoBManager.java#L140-L158
26,522
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/Async.java
Async.go
public static Thread go(Runnable runnable) { Thread thread = daemonThreadFrom(runnable); thread.start(); return thread; }
java
public static Thread go(Runnable runnable) { Thread thread = daemonThreadFrom(runnable); thread.start(); return thread; }
[ "public", "static", "Thread", "go", "(", "Runnable", "runnable", ")", "{", "Thread", "thread", "=", "daemonThreadFrom", "(", "runnable", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
Creates a new thread with the given Runnable, marks it daemon, starts it and returns the started thread. @param runnable @return the started thread.
[ "Creates", "a", "new", "thread", "with", "the", "given", "Runnable", "marks", "it", "daemon", "starts", "it", "and", "returns", "the", "started", "thread", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/Async.java#L30-L34
26,523
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/Async.java
Async.go
public static Thread go(Runnable runnable, String threadName) { Thread thread = daemonThreadFrom(runnable); thread.setName(threadName); thread.start(); return thread; }
java
public static Thread go(Runnable runnable, String threadName) { Thread thread = daemonThreadFrom(runnable); thread.setName(threadName); thread.start(); return thread; }
[ "public", "static", "Thread", "go", "(", "Runnable", "runnable", ",", "String", "threadName", ")", "{", "Thread", "thread", "=", "daemonThreadFrom", "(", "runnable", ")", ";", "thread", ".", "setName", "(", "threadName", ")", ";", "thread", ".", "start", "(", ")", ";", "return", "thread", ";", "}" ]
Creates a new thread with the given Runnable, marks it daemon, sets the name, starts it and returns the started thread. @param runnable @param threadName the thread name. @return the started thread.
[ "Creates", "a", "new", "thread", "with", "the", "given", "Runnable", "marks", "it", "daemon", "sets", "the", "name", "starts", "it", "and", "returns", "the", "started", "thread", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/Async.java#L44-L49
26,524
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
HttpFileUploadManager.getInstanceFor
public static synchronized HttpFileUploadManager getInstanceFor(XMPPConnection connection) { HttpFileUploadManager httpFileUploadManager = INSTANCES.get(connection); if (httpFileUploadManager == null) { httpFileUploadManager = new HttpFileUploadManager(connection); INSTANCES.put(connection, httpFileUploadManager); } return httpFileUploadManager; }
java
public static synchronized HttpFileUploadManager getInstanceFor(XMPPConnection connection) { HttpFileUploadManager httpFileUploadManager = INSTANCES.get(connection); if (httpFileUploadManager == null) { httpFileUploadManager = new HttpFileUploadManager(connection); INSTANCES.put(connection, httpFileUploadManager); } return httpFileUploadManager; }
[ "public", "static", "synchronized", "HttpFileUploadManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "HttpFileUploadManager", "httpFileUploadManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "httpFileUploadManager", "==", "null", ")", "{", "httpFileUploadManager", "=", "new", "HttpFileUploadManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "httpFileUploadManager", ")", ";", "}", "return", "httpFileUploadManager", ";", "}" ]
Obtain the HttpFileUploadManager responsible for a connection. @param connection the connection object. @return a HttpFileUploadManager instance
[ "Obtain", "the", "HttpFileUploadManager", "responsible", "for", "a", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java#L104-L113
26,525
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
HttpFileUploadManager.discoverUploadService
public boolean discoverUploadService() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); List<DiscoverInfo> servicesDiscoverInfo = sdm .findServicesDiscoverInfo(NAMESPACE, true, true); if (servicesDiscoverInfo.isEmpty()) { servicesDiscoverInfo = sdm.findServicesDiscoverInfo(NAMESPACE_0_2, true, true); if (servicesDiscoverInfo.isEmpty()) { return false; } } DiscoverInfo discoverInfo = servicesDiscoverInfo.get(0); defaultUploadService = uploadServiceFrom(discoverInfo); return true; }
java
public boolean discoverUploadService() throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException, SmackException.NoResponseException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); List<DiscoverInfo> servicesDiscoverInfo = sdm .findServicesDiscoverInfo(NAMESPACE, true, true); if (servicesDiscoverInfo.isEmpty()) { servicesDiscoverInfo = sdm.findServicesDiscoverInfo(NAMESPACE_0_2, true, true); if (servicesDiscoverInfo.isEmpty()) { return false; } } DiscoverInfo discoverInfo = servicesDiscoverInfo.get(0); defaultUploadService = uploadServiceFrom(discoverInfo); return true; }
[ "public", "boolean", "discoverUploadService", "(", ")", "throws", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ".", "NotConnectedException", ",", "InterruptedException", ",", "SmackException", ".", "NoResponseException", "{", "ServiceDiscoveryManager", "sdm", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ";", "List", "<", "DiscoverInfo", ">", "servicesDiscoverInfo", "=", "sdm", ".", "findServicesDiscoverInfo", "(", "NAMESPACE", ",", "true", ",", "true", ")", ";", "if", "(", "servicesDiscoverInfo", ".", "isEmpty", "(", ")", ")", "{", "servicesDiscoverInfo", "=", "sdm", ".", "findServicesDiscoverInfo", "(", "NAMESPACE_0_2", ",", "true", ",", "true", ")", ";", "if", "(", "servicesDiscoverInfo", ".", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "}", "DiscoverInfo", "discoverInfo", "=", "servicesDiscoverInfo", ".", "get", "(", "0", ")", ";", "defaultUploadService", "=", "uploadServiceFrom", "(", "discoverInfo", ")", ";", "return", "true", ";", "}" ]
Discover upload service. Called automatically when connection is authenticated. Note that this is a synchronous call -- Smack must wait for the server response. @return true if upload service was discovered @throws XMPPException.XMPPErrorException @throws SmackException.NotConnectedException @throws InterruptedException @throws SmackException.NoResponseException
[ "Discover", "upload", "service", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java#L186-L203
26,526
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
HttpFileUploadManager.uploadFile
public URL uploadFile(File file) throws InterruptedException, XMPPException.XMPPErrorException, SmackException, IOException { return uploadFile(file, null); }
java
public URL uploadFile(File file) throws InterruptedException, XMPPException.XMPPErrorException, SmackException, IOException { return uploadFile(file, null); }
[ "public", "URL", "uploadFile", "(", "File", "file", ")", "throws", "InterruptedException", ",", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ",", "IOException", "{", "return", "uploadFile", "(", "file", ",", "null", ")", ";", "}" ]
Request slot and uploaded file to HTTP file upload service. You don't need to request slot and upload file separately, this method will do both. Note that this is a synchronous call -- Smack must wait for the server response. @param file file to be uploaded @return public URL for sharing uploaded file @throws InterruptedException @throws XMPPException.XMPPErrorException @throws SmackException @throws IOException in case of HTTP upload errors
[ "Request", "slot", "and", "uploaded", "file", "to", "HTTP", "file", "upload", "service", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java#L236-L239
26,527
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
HttpFileUploadManager.uploadFile
public URL uploadFile(File file, UploadProgressListener listener) throws InterruptedException, XMPPException.XMPPErrorException, SmackException, IOException { if (!file.isFile()) { throw new FileNotFoundException("The path " + file.getAbsolutePath() + " is not a file"); } final Slot slot = requestSlot(file.getName(), file.length(), "application/octet-stream"); uploadFile(file, slot, listener); return slot.getGetUrl(); }
java
public URL uploadFile(File file, UploadProgressListener listener) throws InterruptedException, XMPPException.XMPPErrorException, SmackException, IOException { if (!file.isFile()) { throw new FileNotFoundException("The path " + file.getAbsolutePath() + " is not a file"); } final Slot slot = requestSlot(file.getName(), file.length(), "application/octet-stream"); uploadFile(file, slot, listener); return slot.getGetUrl(); }
[ "public", "URL", "uploadFile", "(", "File", "file", ",", "UploadProgressListener", "listener", ")", "throws", "InterruptedException", ",", "XMPPException", ".", "XMPPErrorException", ",", "SmackException", ",", "IOException", "{", "if", "(", "!", "file", ".", "isFile", "(", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "\"The path \"", "+", "file", ".", "getAbsolutePath", "(", ")", "+", "\" is not a file\"", ")", ";", "}", "final", "Slot", "slot", "=", "requestSlot", "(", "file", ".", "getName", "(", ")", ",", "file", ".", "length", "(", ")", ",", "\"application/octet-stream\"", ")", ";", "uploadFile", "(", "file", ",", "slot", ",", "listener", ")", ";", "return", "slot", ".", "getGetUrl", "(", ")", ";", "}" ]
Request slot and uploaded file to HTTP file upload service with progress callback. You don't need to request slot and upload file separately, this method will do both. Note that this is a synchronous call -- Smack must wait for the server response. @param file file to be uploaded @param listener upload progress listener of null @return public URL for sharing uploaded file @throws InterruptedException @throws XMPPException.XMPPErrorException @throws SmackException @throws IOException
[ "Request", "slot", "and", "uploaded", "file", "to", "HTTP", "file", "upload", "service", "with", "progress", "callback", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java#L256-L266
26,528
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java
HttpFileUploadManager.requestSlot
public Slot requestSlot(String filename, long fileSize, String contentType, DomainBareJid uploadServiceAddress) throws SmackException, InterruptedException, XMPPException.XMPPErrorException { final XMPPConnection connection = connection(); final UploadService defaultUploadService = this.defaultUploadService; // The upload service we are going to use. UploadService uploadService; if (uploadServiceAddress == null) { uploadService = defaultUploadService; } else { if (defaultUploadService != null && defaultUploadService.getAddress().equals(uploadServiceAddress)) { // Avoid performing a service discovery if we already know about the given service. uploadService = defaultUploadService; } else { DiscoverInfo discoverInfo = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(uploadServiceAddress); if (!containsHttpFileUploadNamespace(discoverInfo)) { throw new IllegalArgumentException("There is no HTTP upload service running at the given address '" + uploadServiceAddress + '\''); } uploadService = uploadServiceFrom(discoverInfo); } } if (uploadService == null) { throw new SmackException.SmackMessageException("No upload service specified and also none discovered."); } if (!uploadService.acceptsFileOfSize(fileSize)) { throw new IllegalArgumentException( "Requested file size " + fileSize + " is greater than max allowed size " + uploadService.getMaxFileSize()); } SlotRequest slotRequest; switch (uploadService.getVersion()) { case v0_3: slotRequest = new SlotRequest(uploadService.getAddress(), filename, fileSize, contentType); break; case v0_2: slotRequest = new SlotRequest_V0_2(uploadService.getAddress(), filename, fileSize, contentType); break; default: throw new AssertionError(); } return connection.createStanzaCollectorAndSend(slotRequest).nextResultOrThrow(); }
java
public Slot requestSlot(String filename, long fileSize, String contentType, DomainBareJid uploadServiceAddress) throws SmackException, InterruptedException, XMPPException.XMPPErrorException { final XMPPConnection connection = connection(); final UploadService defaultUploadService = this.defaultUploadService; // The upload service we are going to use. UploadService uploadService; if (uploadServiceAddress == null) { uploadService = defaultUploadService; } else { if (defaultUploadService != null && defaultUploadService.getAddress().equals(uploadServiceAddress)) { // Avoid performing a service discovery if we already know about the given service. uploadService = defaultUploadService; } else { DiscoverInfo discoverInfo = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(uploadServiceAddress); if (!containsHttpFileUploadNamespace(discoverInfo)) { throw new IllegalArgumentException("There is no HTTP upload service running at the given address '" + uploadServiceAddress + '\''); } uploadService = uploadServiceFrom(discoverInfo); } } if (uploadService == null) { throw new SmackException.SmackMessageException("No upload service specified and also none discovered."); } if (!uploadService.acceptsFileOfSize(fileSize)) { throw new IllegalArgumentException( "Requested file size " + fileSize + " is greater than max allowed size " + uploadService.getMaxFileSize()); } SlotRequest slotRequest; switch (uploadService.getVersion()) { case v0_3: slotRequest = new SlotRequest(uploadService.getAddress(), filename, fileSize, contentType); break; case v0_2: slotRequest = new SlotRequest_V0_2(uploadService.getAddress(), filename, fileSize, contentType); break; default: throw new AssertionError(); } return connection.createStanzaCollectorAndSend(slotRequest).nextResultOrThrow(); }
[ "public", "Slot", "requestSlot", "(", "String", "filename", ",", "long", "fileSize", ",", "String", "contentType", ",", "DomainBareJid", "uploadServiceAddress", ")", "throws", "SmackException", ",", "InterruptedException", ",", "XMPPException", ".", "XMPPErrorException", "{", "final", "XMPPConnection", "connection", "=", "connection", "(", ")", ";", "final", "UploadService", "defaultUploadService", "=", "this", ".", "defaultUploadService", ";", "// The upload service we are going to use.", "UploadService", "uploadService", ";", "if", "(", "uploadServiceAddress", "==", "null", ")", "{", "uploadService", "=", "defaultUploadService", ";", "}", "else", "{", "if", "(", "defaultUploadService", "!=", "null", "&&", "defaultUploadService", ".", "getAddress", "(", ")", ".", "equals", "(", "uploadServiceAddress", ")", ")", "{", "// Avoid performing a service discovery if we already know about the given service.", "uploadService", "=", "defaultUploadService", ";", "}", "else", "{", "DiscoverInfo", "discoverInfo", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ".", "discoverInfo", "(", "uploadServiceAddress", ")", ";", "if", "(", "!", "containsHttpFileUploadNamespace", "(", "discoverInfo", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"There is no HTTP upload service running at the given address '\"", "+", "uploadServiceAddress", "+", "'", "'", ")", ";", "}", "uploadService", "=", "uploadServiceFrom", "(", "discoverInfo", ")", ";", "}", "}", "if", "(", "uploadService", "==", "null", ")", "{", "throw", "new", "SmackException", ".", "SmackMessageException", "(", "\"No upload service specified and also none discovered.\"", ")", ";", "}", "if", "(", "!", "uploadService", ".", "acceptsFileOfSize", "(", "fileSize", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Requested file size \"", "+", "fileSize", "+", "\" is greater than max allowed size \"", "+", "uploadService", ".", "getMaxFileSize", "(", ")", ")", ";", "}", "SlotRequest", "slotRequest", ";", "switch", "(", "uploadService", ".", "getVersion", "(", ")", ")", "{", "case", "v0_3", ":", "slotRequest", "=", "new", "SlotRequest", "(", "uploadService", ".", "getAddress", "(", ")", ",", "filename", ",", "fileSize", ",", "contentType", ")", ";", "break", ";", "case", "v0_2", ":", "slotRequest", "=", "new", "SlotRequest_V0_2", "(", "uploadService", ".", "getAddress", "(", ")", ",", "filename", ",", "fileSize", ",", "contentType", ")", ";", "break", ";", "default", ":", "throw", "new", "AssertionError", "(", ")", ";", "}", "return", "connection", ".", "createStanzaCollectorAndSend", "(", "slotRequest", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Request a new upload slot with optional content type from custom upload service. When you get slot you should upload file to PUT URL and share GET URL. Note that this is a synchronous call -- Smack must wait for the server response. @param filename name of file to be uploaded @param fileSize file size in bytes. @param contentType file content-type or null @param uploadServiceAddress the address of the upload service to use or null for default one @return file upload Slot in case of success @throws IllegalArgumentException if fileSize is less than or equal to zero or greater than the maximum size supported by the service. @throws SmackException @throws InterruptedException @throws XMPPException.XMPPErrorException
[ "Request", "a", "new", "upload", "slot", "with", "optional", "content", "type", "from", "custom", "upload", "service", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/httpfileupload/HttpFileUploadManager.java#L328-L374
26,529
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.getInstanceFor
public static synchronized MultiUserChatLightManager getInstanceFor(XMPPConnection connection) { MultiUserChatLightManager multiUserChatLightManager = INSTANCES.get(connection); if (multiUserChatLightManager == null) { multiUserChatLightManager = new MultiUserChatLightManager(connection); INSTANCES.put(connection, multiUserChatLightManager); } return multiUserChatLightManager; }
java
public static synchronized MultiUserChatLightManager getInstanceFor(XMPPConnection connection) { MultiUserChatLightManager multiUserChatLightManager = INSTANCES.get(connection); if (multiUserChatLightManager == null) { multiUserChatLightManager = new MultiUserChatLightManager(connection); INSTANCES.put(connection, multiUserChatLightManager); } return multiUserChatLightManager; }
[ "public", "static", "synchronized", "MultiUserChatLightManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "MultiUserChatLightManager", "multiUserChatLightManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "multiUserChatLightManager", "==", "null", ")", "{", "multiUserChatLightManager", "=", "new", "MultiUserChatLightManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "multiUserChatLightManager", ")", ";", "}", "return", "multiUserChatLightManager", ";", "}" ]
Get a instance of a MUC Light manager for the given connection. @param connection @return a MUCLight manager.
[ "Get", "a", "instance", "of", "a", "MUC", "Light", "manager", "for", "the", "given", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L60-L67
26,530
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.getMultiUserChatLight
public synchronized MultiUserChatLight getMultiUserChatLight(EntityBareJid jid) { WeakReference<MultiUserChatLight> weakRefMultiUserChat = multiUserChatLights.get(jid); if (weakRefMultiUserChat == null) { return createNewMucLightAndAddToMap(jid); } MultiUserChatLight multiUserChatLight = weakRefMultiUserChat.get(); if (multiUserChatLight == null) { return createNewMucLightAndAddToMap(jid); } return multiUserChatLight; }
java
public synchronized MultiUserChatLight getMultiUserChatLight(EntityBareJid jid) { WeakReference<MultiUserChatLight> weakRefMultiUserChat = multiUserChatLights.get(jid); if (weakRefMultiUserChat == null) { return createNewMucLightAndAddToMap(jid); } MultiUserChatLight multiUserChatLight = weakRefMultiUserChat.get(); if (multiUserChatLight == null) { return createNewMucLightAndAddToMap(jid); } return multiUserChatLight; }
[ "public", "synchronized", "MultiUserChatLight", "getMultiUserChatLight", "(", "EntityBareJid", "jid", ")", "{", "WeakReference", "<", "MultiUserChatLight", ">", "weakRefMultiUserChat", "=", "multiUserChatLights", ".", "get", "(", "jid", ")", ";", "if", "(", "weakRefMultiUserChat", "==", "null", ")", "{", "return", "createNewMucLightAndAddToMap", "(", "jid", ")", ";", "}", "MultiUserChatLight", "multiUserChatLight", "=", "weakRefMultiUserChat", ".", "get", "(", ")", ";", "if", "(", "multiUserChatLight", "==", "null", ")", "{", "return", "createNewMucLightAndAddToMap", "(", "jid", ")", ";", "}", "return", "multiUserChatLight", ";", "}" ]
Obtain the MUC Light. @param jid @return the MUCLight.
[ "Obtain", "the", "MUC", "Light", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L85-L95
26,531
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.isFeatureSupported
public boolean isFeatureSupported(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(mucLightService) .containsFeature(MultiUserChatLight.NAMESPACE); }
java
public boolean isFeatureSupported(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).discoverInfo(mucLightService) .containsFeature(MultiUserChatLight.NAMESPACE); }
[ "public", "boolean", "isFeatureSupported", "(", "DomainBareJid", "mucLightService", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ".", "discoverInfo", "(", "mucLightService", ")", ".", "containsFeature", "(", "MultiUserChatLight", ".", "NAMESPACE", ")", ";", "}" ]
Returns true if Multi-User Chat Light feature is supported by the server. @param mucLightService @return true if Multi-User Chat Light feature is supported by the server. @throws NotConnectedException @throws XMPPErrorException @throws NoResponseException @throws InterruptedException
[ "Returns", "true", "if", "Multi", "-", "User", "Chat", "Light", "feature", "is", "supported", "by", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L113-L117
26,532
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.getOccupiedRooms
public List<Jid> getOccupiedRooms(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection()).discoverItems(mucLightService); List<DiscoverItems.Item> items = result.getItems(); List<Jid> answer = new ArrayList<>(items.size()); for (DiscoverItems.Item item : items) { Jid mucLight = item.getEntityID(); answer.add(mucLight); } return answer; }
java
public List<Jid> getOccupiedRooms(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverItems result = ServiceDiscoveryManager.getInstanceFor(connection()).discoverItems(mucLightService); List<DiscoverItems.Item> items = result.getItems(); List<Jid> answer = new ArrayList<>(items.size()); for (DiscoverItems.Item item : items) { Jid mucLight = item.getEntityID(); answer.add(mucLight); } return answer; }
[ "public", "List", "<", "Jid", ">", "getOccupiedRooms", "(", "DomainBareJid", "mucLightService", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "DiscoverItems", "result", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ".", "discoverItems", "(", "mucLightService", ")", ";", "List", "<", "DiscoverItems", ".", "Item", ">", "items", "=", "result", ".", "getItems", "(", ")", ";", "List", "<", "Jid", ">", "answer", "=", "new", "ArrayList", "<>", "(", "items", ".", "size", "(", ")", ")", ";", "for", "(", "DiscoverItems", ".", "Item", "item", ":", "items", ")", "{", "Jid", "mucLight", "=", "item", ".", "getEntityID", "(", ")", ";", "answer", ".", "add", "(", "mucLight", ")", ";", "}", "return", "answer", ";", "}" ]
Returns a List of the rooms the user occupies. @param mucLightService @return a List of the rooms the user occupies. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "a", "List", "of", "the", "rooms", "the", "user", "occupies", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L129-L141
26,533
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.getLocalServices
public List<DomainBareJid> getLocalServices() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); return sdm.findServices(MultiUserChatLight.NAMESPACE, false, false); }
java
public List<DomainBareJid> getLocalServices() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection()); return sdm.findServices(MultiUserChatLight.NAMESPACE, false, false); }
[ "public", "List", "<", "DomainBareJid", ">", "getLocalServices", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ServiceDiscoveryManager", "sdm", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ";", "return", "sdm", ".", "findServices", "(", "MultiUserChatLight", ".", "NAMESPACE", ",", "false", ",", "false", ")", ";", "}" ]
Returns a collection with the XMPP addresses of the MUC Light services. @return a collection with the XMPP addresses of the MUC Light services. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "a", "collection", "with", "the", "XMPP", "addresses", "of", "the", "MUC", "Light", "services", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L152-L156
26,534
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.getUsersAndRoomsBlocked
public List<Jid> getUsersAndRoomsBlocked(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightBlockingIQ muclIghtBlockingIQResult = getBlockingList(mucLightService); List<Jid> jids = new ArrayList<>(); if (muclIghtBlockingIQResult.getRooms() != null) { jids.addAll(muclIghtBlockingIQResult.getRooms().keySet()); } if (muclIghtBlockingIQResult.getUsers() != null) { jids.addAll(muclIghtBlockingIQResult.getUsers().keySet()); } return jids; }
java
public List<Jid> getUsersAndRoomsBlocked(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightBlockingIQ muclIghtBlockingIQResult = getBlockingList(mucLightService); List<Jid> jids = new ArrayList<>(); if (muclIghtBlockingIQResult.getRooms() != null) { jids.addAll(muclIghtBlockingIQResult.getRooms().keySet()); } if (muclIghtBlockingIQResult.getUsers() != null) { jids.addAll(muclIghtBlockingIQResult.getUsers().keySet()); } return jids; }
[ "public", "List", "<", "Jid", ">", "getUsersAndRoomsBlocked", "(", "DomainBareJid", "mucLightService", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightBlockingIQ", "muclIghtBlockingIQResult", "=", "getBlockingList", "(", "mucLightService", ")", ";", "List", "<", "Jid", ">", "jids", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "muclIghtBlockingIQResult", ".", "getRooms", "(", ")", "!=", "null", ")", "{", "jids", ".", "addAll", "(", "muclIghtBlockingIQResult", ".", "getRooms", "(", ")", ".", "keySet", "(", ")", ")", ";", "}", "if", "(", "muclIghtBlockingIQResult", ".", "getUsers", "(", ")", "!=", "null", ")", "{", "jids", ".", "addAll", "(", "muclIghtBlockingIQResult", ".", "getUsers", "(", ")", ".", "keySet", "(", ")", ")", ";", "}", "return", "jids", ";", "}" ]
Get users and rooms blocked. @param mucLightService @return the list of users and rooms blocked @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Get", "users", "and", "rooms", "blocked", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L168-L182
26,535
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.getRoomsBlocked
public List<Jid> getRoomsBlocked(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightBlockingIQ mucLightBlockingIQResult = getBlockingList(mucLightService); List<Jid> jids = new ArrayList<>(); if (mucLightBlockingIQResult.getRooms() != null) { jids.addAll(mucLightBlockingIQResult.getRooms().keySet()); } return jids; }
java
public List<Jid> getRoomsBlocked(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCLightBlockingIQ mucLightBlockingIQResult = getBlockingList(mucLightService); List<Jid> jids = new ArrayList<>(); if (mucLightBlockingIQResult.getRooms() != null) { jids.addAll(mucLightBlockingIQResult.getRooms().keySet()); } return jids; }
[ "public", "List", "<", "Jid", ">", "getRoomsBlocked", "(", "DomainBareJid", "mucLightService", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "MUCLightBlockingIQ", "mucLightBlockingIQResult", "=", "getBlockingList", "(", "mucLightService", ")", ";", "List", "<", "Jid", ">", "jids", "=", "new", "ArrayList", "<>", "(", ")", ";", "if", "(", "mucLightBlockingIQResult", ".", "getRooms", "(", ")", "!=", "null", ")", "{", "jids", ".", "addAll", "(", "mucLightBlockingIQResult", ".", "getRooms", "(", ")", ".", "keySet", "(", ")", ")", ";", "}", "return", "jids", ";", "}" ]
Get rooms blocked. @param mucLightService @return the list of rooms blocked @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Get", "rooms", "blocked", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L194-L204
26,536
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.blockRoom
public void blockRoom(DomainBareJid mucLightService, Jid roomJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); rooms.put(roomJid, false); sendBlockRooms(mucLightService, rooms); }
java
public void blockRoom(DomainBareJid mucLightService, Jid roomJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); rooms.put(roomJid, false); sendBlockRooms(mucLightService, rooms); }
[ "public", "void", "blockRoom", "(", "DomainBareJid", "mucLightService", ",", "Jid", "roomJid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "rooms", "=", "new", "HashMap", "<>", "(", ")", ";", "rooms", ".", "put", "(", "roomJid", ",", "false", ")", ";", "sendBlockRooms", "(", "mucLightService", ",", "rooms", ")", ";", "}" ]
Block a room. @param mucLightService @param roomJid @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Block", "a", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L252-L257
26,537
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.blockRooms
public void blockRooms(DomainBareJid mucLightService, List<Jid> roomsJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); for (Jid jid : roomsJids) { rooms.put(jid, false); } sendBlockRooms(mucLightService, rooms); }
java
public void blockRooms(DomainBareJid mucLightService, List<Jid> roomsJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); for (Jid jid : roomsJids) { rooms.put(jid, false); } sendBlockRooms(mucLightService, rooms); }
[ "public", "void", "blockRooms", "(", "DomainBareJid", "mucLightService", ",", "List", "<", "Jid", ">", "roomsJids", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "rooms", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Jid", "jid", ":", "roomsJids", ")", "{", "rooms", ".", "put", "(", "jid", ",", "false", ")", ";", "}", "sendBlockRooms", "(", "mucLightService", ",", "rooms", ")", ";", "}" ]
Block rooms. @param mucLightService @param roomsJids @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Block", "rooms", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L269-L276
26,538
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.blockUser
public void blockUser(DomainBareJid mucLightService, Jid userJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); users.put(userJid, false); sendBlockUsers(mucLightService, users); }
java
public void blockUser(DomainBareJid mucLightService, Jid userJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); users.put(userJid, false); sendBlockUsers(mucLightService, users); }
[ "public", "void", "blockUser", "(", "DomainBareJid", "mucLightService", ",", "Jid", "userJid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "users", "=", "new", "HashMap", "<>", "(", ")", ";", "users", ".", "put", "(", "userJid", ",", "false", ")", ";", "sendBlockUsers", "(", "mucLightService", ",", "users", ")", ";", "}" ]
Block a user. @param mucLightService @param userJid @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Block", "a", "user", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L296-L301
26,539
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.blockUsers
public void blockUsers(DomainBareJid mucLightService, List<Jid> usersJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); for (Jid jid : usersJids) { users.put(jid, false); } sendBlockUsers(mucLightService, users); }
java
public void blockUsers(DomainBareJid mucLightService, List<Jid> usersJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); for (Jid jid : usersJids) { users.put(jid, false); } sendBlockUsers(mucLightService, users); }
[ "public", "void", "blockUsers", "(", "DomainBareJid", "mucLightService", ",", "List", "<", "Jid", ">", "usersJids", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "users", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Jid", "jid", ":", "usersJids", ")", "{", "users", ".", "put", "(", "jid", ",", "false", ")", ";", "}", "sendBlockUsers", "(", "mucLightService", ",", "users", ")", ";", "}" ]
Block users. @param mucLightService @param usersJids @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Block", "users", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L313-L320
26,540
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.unblockRoom
public void unblockRoom(DomainBareJid mucLightService, Jid roomJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); rooms.put(roomJid, true); sendUnblockRooms(mucLightService, rooms); }
java
public void unblockRoom(DomainBareJid mucLightService, Jid roomJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); rooms.put(roomJid, true); sendUnblockRooms(mucLightService, rooms); }
[ "public", "void", "unblockRoom", "(", "DomainBareJid", "mucLightService", ",", "Jid", "roomJid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "rooms", "=", "new", "HashMap", "<>", "(", ")", ";", "rooms", ".", "put", "(", "roomJid", ",", "true", ")", ";", "sendUnblockRooms", "(", "mucLightService", ",", "rooms", ")", ";", "}" ]
Unblock a room. @param mucLightService @param roomJid @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Unblock", "a", "room", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L340-L345
26,541
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.unblockRooms
public void unblockRooms(DomainBareJid mucLightService, List<Jid> roomsJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); for (Jid jid : roomsJids) { rooms.put(jid, true); } sendUnblockRooms(mucLightService, rooms); }
java
public void unblockRooms(DomainBareJid mucLightService, List<Jid> roomsJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> rooms = new HashMap<>(); for (Jid jid : roomsJids) { rooms.put(jid, true); } sendUnblockRooms(mucLightService, rooms); }
[ "public", "void", "unblockRooms", "(", "DomainBareJid", "mucLightService", ",", "List", "<", "Jid", ">", "roomsJids", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "rooms", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Jid", "jid", ":", "roomsJids", ")", "{", "rooms", ".", "put", "(", "jid", ",", "true", ")", ";", "}", "sendUnblockRooms", "(", "mucLightService", ",", "rooms", ")", ";", "}" ]
Unblock rooms. @param mucLightService @param roomsJids @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Unblock", "rooms", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L357-L364
26,542
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.unblockUser
public void unblockUser(DomainBareJid mucLightService, Jid userJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); users.put(userJid, true); sendUnblockUsers(mucLightService, users); }
java
public void unblockUser(DomainBareJid mucLightService, Jid userJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); users.put(userJid, true); sendUnblockUsers(mucLightService, users); }
[ "public", "void", "unblockUser", "(", "DomainBareJid", "mucLightService", ",", "Jid", "userJid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "users", "=", "new", "HashMap", "<>", "(", ")", ";", "users", ".", "put", "(", "userJid", ",", "true", ")", ";", "sendUnblockUsers", "(", "mucLightService", ",", "users", ")", ";", "}" ]
Unblock a user. @param mucLightService @param userJid @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Unblock", "a", "user", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L384-L389
26,543
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java
MultiUserChatLightManager.unblockUsers
public void unblockUsers(DomainBareJid mucLightService, List<Jid> usersJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); for (Jid jid : usersJids) { users.put(jid, true); } sendUnblockUsers(mucLightService, users); }
java
public void unblockUsers(DomainBareJid mucLightService, List<Jid> usersJids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { HashMap<Jid, Boolean> users = new HashMap<>(); for (Jid jid : usersJids) { users.put(jid, true); } sendUnblockUsers(mucLightService, users); }
[ "public", "void", "unblockUsers", "(", "DomainBareJid", "mucLightService", ",", "List", "<", "Jid", ">", "usersJids", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "HashMap", "<", "Jid", ",", "Boolean", ">", "users", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "Jid", "jid", ":", "usersJids", ")", "{", "users", ".", "put", "(", "jid", ",", "true", ")", ";", "}", "sendUnblockUsers", "(", "mucLightService", ",", "users", ")", ";", "}" ]
Unblock users. @param mucLightService @param usersJids @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Unblock", "users", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/muclight/MultiUserChatLightManager.java#L401-L408
26,544
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java
PrivateDataManager.addPrivateDataProvider
public static void addPrivateDataProvider(String elementName, String namespace, PrivateDataProvider provider) { String key = XmppStringUtils.generateKey(elementName, namespace); privateDataProviders.put(key, provider); }
java
public static void addPrivateDataProvider(String elementName, String namespace, PrivateDataProvider provider) { String key = XmppStringUtils.generateKey(elementName, namespace); privateDataProviders.put(key, provider); }
[ "public", "static", "void", "addPrivateDataProvider", "(", "String", "elementName", ",", "String", "namespace", ",", "PrivateDataProvider", "provider", ")", "{", "String", "key", "=", "XmppStringUtils", ".", "generateKey", "(", "elementName", ",", "namespace", ")", ";", "privateDataProviders", ".", "put", "(", "key", ",", "provider", ")", ";", "}" ]
Adds a private data provider with the specified element name and name space. The provider will override any providers loaded through the classpath. @param elementName the XML element name. @param namespace the XML namespace. @param provider the private data provider.
[ "Adds", "a", "private", "data", "provider", "with", "the", "specified", "element", "name", "and", "name", "space", ".", "The", "provider", "will", "override", "any", "providers", "loaded", "through", "the", "classpath", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java#L117-L121
26,545
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java
PrivateDataManager.removePrivateDataProvider
public static void removePrivateDataProvider(String elementName, String namespace) { String key = XmppStringUtils.generateKey(elementName, namespace); privateDataProviders.remove(key); }
java
public static void removePrivateDataProvider(String elementName, String namespace) { String key = XmppStringUtils.generateKey(elementName, namespace); privateDataProviders.remove(key); }
[ "public", "static", "void", "removePrivateDataProvider", "(", "String", "elementName", ",", "String", "namespace", ")", "{", "String", "key", "=", "XmppStringUtils", ".", "generateKey", "(", "elementName", ",", "namespace", ")", ";", "privateDataProviders", ".", "remove", "(", "key", ")", ";", "}" ]
Removes a private data provider with the specified element name and namespace. @param elementName The XML element name. @param namespace The XML namespace.
[ "Removes", "a", "private", "data", "provider", "with", "the", "specified", "element", "name", "and", "namespace", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java#L129-L132
26,546
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java
PrivateDataManager.setPrivateData
public void setPrivateData(final PrivateData privateData) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Create an IQ packet to set the private data. IQ privateDataSet = new PrivateDataIQ(privateData); connection().createStanzaCollectorAndSend(privateDataSet).nextResultOrThrow(); }
java
public void setPrivateData(final PrivateData privateData) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Create an IQ packet to set the private data. IQ privateDataSet = new PrivateDataIQ(privateData); connection().createStanzaCollectorAndSend(privateDataSet).nextResultOrThrow(); }
[ "public", "void", "setPrivateData", "(", "final", "PrivateData", "privateData", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "// Create an IQ packet to set the private data.", "IQ", "privateDataSet", "=", "new", "PrivateDataIQ", "(", "privateData", ")", ";", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "privateDataSet", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Sets a private data value. Each chunk of private data is uniquely identified by an element name and namespace pair. If private data has already been set with the element name and namespace, then the new private data will overwrite the old value. @param privateData the private data. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Sets", "a", "private", "data", "value", ".", "Each", "chunk", "of", "private", "data", "is", "uniquely", "identified", "by", "an", "element", "name", "and", "namespace", "pair", ".", "If", "private", "data", "has", "already", "been", "set", "with", "the", "element", "name", "and", "namespace", "then", "the", "new", "private", "data", "will", "overwrite", "the", "old", "value", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java#L181-L186
26,547
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java
PrivateDataManager.isSupported
public boolean isSupported() throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException { // This is just a primitive hack, since XEP-49 does not specify a way to determine if the // service supports it try { setPrivateData(DUMMY_PRIVATE_DATA); return true; } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == Condition.service_unavailable) { return false; } else { throw e; } } }
java
public boolean isSupported() throws NoResponseException, NotConnectedException, InterruptedException, XMPPErrorException { // This is just a primitive hack, since XEP-49 does not specify a way to determine if the // service supports it try { setPrivateData(DUMMY_PRIVATE_DATA); return true; } catch (XMPPErrorException e) { if (e.getStanzaError().getCondition() == Condition.service_unavailable) { return false; } else { throw e; } } }
[ "public", "boolean", "isSupported", "(", ")", "throws", "NoResponseException", ",", "NotConnectedException", ",", "InterruptedException", ",", "XMPPErrorException", "{", "// This is just a primitive hack, since XEP-49 does not specify a way to determine if the", "// service supports it", "try", "{", "setPrivateData", "(", "DUMMY_PRIVATE_DATA", ")", ";", "return", "true", ";", "}", "catch", "(", "XMPPErrorException", "e", ")", "{", "if", "(", "e", ".", "getStanzaError", "(", ")", ".", "getCondition", "(", ")", "==", "Condition", ".", "service_unavailable", ")", "{", "return", "false", ";", "}", "else", "{", "throw", "e", ";", "}", "}", "}" ]
Check if the service supports private data. @return true if the service supports private data, false otherwise. @throws NoResponseException @throws NotConnectedException @throws InterruptedException @throws XMPPErrorException @since 4.2
[ "Check", "if", "the", "service", "supports", "private", "data", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/iqprivate/PrivateDataManager.java#L215-L231
26,548
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java
OmemoMessageBuilder.moveAuthTag
static void moveAuthTag(byte[] messageKey, byte[] cipherText, byte[] messageKeyWithAuthTag, byte[] cipherTextWithoutAuthTag) { // Check dimensions of arrays if (messageKeyWithAuthTag.length != messageKey.length + 16) { throw new IllegalArgumentException("Length of messageKeyWithAuthTag must be length of messageKey + " + "length of AuthTag (16)"); } if (cipherTextWithoutAuthTag.length != cipherText.length - 16) { throw new IllegalArgumentException("Length of cipherTextWithoutAuthTag must be length of cipherText " + "- length of AuthTag (16)"); } // Move auth tag from cipherText to messageKey System.arraycopy(messageKey, 0, messageKeyWithAuthTag, 0, 16); System.arraycopy(cipherText, 0, cipherTextWithoutAuthTag, 0, cipherTextWithoutAuthTag.length); System.arraycopy(cipherText, cipherText.length - 16, messageKeyWithAuthTag, 16, 16); }
java
static void moveAuthTag(byte[] messageKey, byte[] cipherText, byte[] messageKeyWithAuthTag, byte[] cipherTextWithoutAuthTag) { // Check dimensions of arrays if (messageKeyWithAuthTag.length != messageKey.length + 16) { throw new IllegalArgumentException("Length of messageKeyWithAuthTag must be length of messageKey + " + "length of AuthTag (16)"); } if (cipherTextWithoutAuthTag.length != cipherText.length - 16) { throw new IllegalArgumentException("Length of cipherTextWithoutAuthTag must be length of cipherText " + "- length of AuthTag (16)"); } // Move auth tag from cipherText to messageKey System.arraycopy(messageKey, 0, messageKeyWithAuthTag, 0, 16); System.arraycopy(cipherText, 0, cipherTextWithoutAuthTag, 0, cipherTextWithoutAuthTag.length); System.arraycopy(cipherText, cipherText.length - 16, messageKeyWithAuthTag, 16, 16); }
[ "static", "void", "moveAuthTag", "(", "byte", "[", "]", "messageKey", ",", "byte", "[", "]", "cipherText", ",", "byte", "[", "]", "messageKeyWithAuthTag", ",", "byte", "[", "]", "cipherTextWithoutAuthTag", ")", "{", "// Check dimensions of arrays", "if", "(", "messageKeyWithAuthTag", ".", "length", "!=", "messageKey", ".", "length", "+", "16", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Length of messageKeyWithAuthTag must be length of messageKey + \"", "+", "\"length of AuthTag (16)\"", ")", ";", "}", "if", "(", "cipherTextWithoutAuthTag", ".", "length", "!=", "cipherText", ".", "length", "-", "16", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Length of cipherTextWithoutAuthTag must be length of cipherText \"", "+", "\"- length of AuthTag (16)\"", ")", ";", "}", "// Move auth tag from cipherText to messageKey", "System", ".", "arraycopy", "(", "messageKey", ",", "0", ",", "messageKeyWithAuthTag", ",", "0", ",", "16", ")", ";", "System", ".", "arraycopy", "(", "cipherText", ",", "0", ",", "cipherTextWithoutAuthTag", ",", "0", ",", "cipherTextWithoutAuthTag", ".", "length", ")", ";", "System", ".", "arraycopy", "(", "cipherText", ",", "cipherText", ".", "length", "-", "16", ",", "messageKeyWithAuthTag", ",", "16", ",", "16", ")", ";", "}" ]
Move the auth tag from the end of the cipherText to the messageKey. @param messageKey source messageKey without authTag @param cipherText source cipherText with authTag @param messageKeyWithAuthTag destination messageKey with authTag @param cipherTextWithoutAuthTag destination cipherText without authTag
[ "Move", "the", "auth", "tag", "from", "the", "end", "of", "the", "cipherText", "to", "the", "messageKey", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java#L191-L210
26,549
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java
OmemoMessageBuilder.addRecipient
public void addRecipient(OmemoDevice contactsDevice) throws NoIdentityKeyException, CorruptedOmemoKeyException, UndecidedOmemoIdentityException, UntrustedOmemoIdentityException { OmemoFingerprint fingerprint; fingerprint = OmemoService.getInstance().getOmemoStoreBackend().getFingerprint(userDevice, contactsDevice); switch (trustCallback.getTrust(contactsDevice, fingerprint)) { case undecided: throw new UndecidedOmemoIdentityException(contactsDevice); case trusted: CiphertextTuple encryptedKey = ratchet.doubleRatchetEncrypt(contactsDevice, messageKey); keys.add(new OmemoKeyElement(encryptedKey.getCiphertext(), contactsDevice.getDeviceId(), encryptedKey.isPreKeyMessage())); break; case untrusted: throw new UntrustedOmemoIdentityException(contactsDevice, fingerprint); } }
java
public void addRecipient(OmemoDevice contactsDevice) throws NoIdentityKeyException, CorruptedOmemoKeyException, UndecidedOmemoIdentityException, UntrustedOmemoIdentityException { OmemoFingerprint fingerprint; fingerprint = OmemoService.getInstance().getOmemoStoreBackend().getFingerprint(userDevice, contactsDevice); switch (trustCallback.getTrust(contactsDevice, fingerprint)) { case undecided: throw new UndecidedOmemoIdentityException(contactsDevice); case trusted: CiphertextTuple encryptedKey = ratchet.doubleRatchetEncrypt(contactsDevice, messageKey); keys.add(new OmemoKeyElement(encryptedKey.getCiphertext(), contactsDevice.getDeviceId(), encryptedKey.isPreKeyMessage())); break; case untrusted: throw new UntrustedOmemoIdentityException(contactsDevice, fingerprint); } }
[ "public", "void", "addRecipient", "(", "OmemoDevice", "contactsDevice", ")", "throws", "NoIdentityKeyException", ",", "CorruptedOmemoKeyException", ",", "UndecidedOmemoIdentityException", ",", "UntrustedOmemoIdentityException", "{", "OmemoFingerprint", "fingerprint", ";", "fingerprint", "=", "OmemoService", ".", "getInstance", "(", ")", ".", "getOmemoStoreBackend", "(", ")", ".", "getFingerprint", "(", "userDevice", ",", "contactsDevice", ")", ";", "switch", "(", "trustCallback", ".", "getTrust", "(", "contactsDevice", ",", "fingerprint", ")", ")", "{", "case", "undecided", ":", "throw", "new", "UndecidedOmemoIdentityException", "(", "contactsDevice", ")", ";", "case", "trusted", ":", "CiphertextTuple", "encryptedKey", "=", "ratchet", ".", "doubleRatchetEncrypt", "(", "contactsDevice", ",", "messageKey", ")", ";", "keys", ".", "add", "(", "new", "OmemoKeyElement", "(", "encryptedKey", ".", "getCiphertext", "(", ")", ",", "contactsDevice", ".", "getDeviceId", "(", ")", ",", "encryptedKey", ".", "isPreKeyMessage", "(", ")", ")", ")", ";", "break", ";", "case", "untrusted", ":", "throw", "new", "UntrustedOmemoIdentityException", "(", "contactsDevice", ",", "fingerprint", ")", ";", "}", "}" ]
Add a new recipient device to the message. @param contactsDevice device of the recipient @throws NoIdentityKeyException if we have no identityKey of that device. Can be fixed by fetching and processing the devices bundle. @throws CorruptedOmemoKeyException if the identityKey of that device is corrupted. @throws UndecidedOmemoIdentityException if the user hasn't yet decided whether to trust that device or not. @throws UntrustedOmemoIdentityException if the user has decided not to trust that device.
[ "Add", "a", "new", "recipient", "device", "to", "the", "message", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java#L222-L243
26,550
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java
OmemoMessageBuilder.finish
public OmemoElement finish() { OmemoHeaderElement_VAxolotl header = new OmemoHeaderElement_VAxolotl( userDevice.getDeviceId(), keys, initializationVector ); return new OmemoElement_VAxolotl(header, ciphertextMessage); }
java
public OmemoElement finish() { OmemoHeaderElement_VAxolotl header = new OmemoHeaderElement_VAxolotl( userDevice.getDeviceId(), keys, initializationVector ); return new OmemoElement_VAxolotl(header, ciphertextMessage); }
[ "public", "OmemoElement", "finish", "(", ")", "{", "OmemoHeaderElement_VAxolotl", "header", "=", "new", "OmemoHeaderElement_VAxolotl", "(", "userDevice", ".", "getDeviceId", "(", ")", ",", "keys", ",", "initializationVector", ")", ";", "return", "new", "OmemoElement_VAxolotl", "(", "header", ",", "ciphertextMessage", ")", ";", "}" ]
Assemble an OmemoMessageElement from the current state of the builder. @return OmemoMessageElement
[ "Assemble", "an", "OmemoMessageElement", "from", "the", "current", "state", "of", "the", "builder", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java#L250-L257
26,551
igniterealtime/Smack
smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java
OmemoMessageBuilder.generateKey
public static byte[] generateKey(String keyType, int keyLength) throws NoSuchAlgorithmException { KeyGenerator generator = KeyGenerator.getInstance(keyType); generator.init(keyLength); return generator.generateKey().getEncoded(); }
java
public static byte[] generateKey(String keyType, int keyLength) throws NoSuchAlgorithmException { KeyGenerator generator = KeyGenerator.getInstance(keyType); generator.init(keyLength); return generator.generateKey().getEncoded(); }
[ "public", "static", "byte", "[", "]", "generateKey", "(", "String", "keyType", ",", "int", "keyLength", ")", "throws", "NoSuchAlgorithmException", "{", "KeyGenerator", "generator", "=", "KeyGenerator", ".", "getInstance", "(", "keyType", ")", ";", "generator", ".", "init", "(", "keyLength", ")", ";", "return", "generator", ".", "generateKey", "(", ")", ".", "getEncoded", "(", ")", ";", "}" ]
Generate a new AES key used to encrypt the message. @param keyType Key Type @param keyLength Key Length in bit @return new AES key @throws NoSuchAlgorithmException
[ "Generate", "a", "new", "AES", "key", "used", "to", "encrypt", "the", "message", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/util/OmemoMessageBuilder.java#L267-L271
26,552
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/VersionManager.java
VersionManager.getVersion
public Version getVersion(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (!isSupported(jid)) { return null; } return connection().createStanzaCollectorAndSend(new Version(jid)).nextResultOrThrow(); }
java
public Version getVersion(Jid jid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (!isSupported(jid)) { return null; } return connection().createStanzaCollectorAndSend(new Version(jid)).nextResultOrThrow(); }
[ "public", "Version", "getVersion", "(", "Jid", "jid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "if", "(", "!", "isSupported", "(", "jid", ")", ")", "{", "return", "null", ";", "}", "return", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "new", "Version", "(", "jid", ")", ")", ".", "nextResultOrThrow", "(", ")", ";", "}" ]
Request version information from a given JID. @param jid @return the version information or {@code null} if not supported by JID @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Request", "version", "information", "from", "a", "given", "JID", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/iqversion/VersionManager.java#L145-L151
26,553
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java
MultipleRecipientManager.reply
public static void reply(XMPPConnection connection, Message original, Message reply) throws XMPPErrorException, InterruptedException, NotConnectedException, NoResponseException, FeatureNotSupportedException { MultipleRecipientInfo info = getMultipleRecipientInfo(original); if (info == null) { throw new IllegalArgumentException("Original message does not contain multiple recipient info"); } if (info.shouldNotReply()) { throw new IllegalArgumentException("Original message should not be replied"); } if (info.getReplyRoom() != null) { throw new IllegalArgumentException("Reply should be sent through a room"); } // Any <thread/> element from the initial message MUST be copied into the reply. if (original.getThread() != null) { reply.setThread(original.getThread()); } MultipleAddresses.Address replyAddress = info.getReplyAddress(); if (replyAddress != null && replyAddress.getJid() != null) { // Send reply to the reply_to address reply.setTo(replyAddress.getJid()); connection.sendStanza(reply); } else { // Send reply to multiple recipients List<Jid> to = new ArrayList<>(info.getTOAddresses().size()); List<Jid> cc = new ArrayList<>(info.getCCAddresses().size()); for (MultipleAddresses.Address jid : info.getTOAddresses()) { to.add(jid.getJid()); } for (MultipleAddresses.Address jid : info.getCCAddresses()) { cc.add(jid.getJid()); } // Add original sender as a 'to' address (if not already present) if (!to.contains(original.getFrom()) && !cc.contains(original.getFrom())) { to.add(original.getFrom()); } // Remove the sender from the TO/CC list (try with bare JID too) EntityFullJid from = connection.getUser(); if (!to.remove(from) && !cc.remove(from)) { EntityBareJid bareJID = from.asEntityBareJid(); to.remove(bareJID); cc.remove(bareJID); } send(connection, reply, to, cc, null, null, null, false); } }
java
public static void reply(XMPPConnection connection, Message original, Message reply) throws XMPPErrorException, InterruptedException, NotConnectedException, NoResponseException, FeatureNotSupportedException { MultipleRecipientInfo info = getMultipleRecipientInfo(original); if (info == null) { throw new IllegalArgumentException("Original message does not contain multiple recipient info"); } if (info.shouldNotReply()) { throw new IllegalArgumentException("Original message should not be replied"); } if (info.getReplyRoom() != null) { throw new IllegalArgumentException("Reply should be sent through a room"); } // Any <thread/> element from the initial message MUST be copied into the reply. if (original.getThread() != null) { reply.setThread(original.getThread()); } MultipleAddresses.Address replyAddress = info.getReplyAddress(); if (replyAddress != null && replyAddress.getJid() != null) { // Send reply to the reply_to address reply.setTo(replyAddress.getJid()); connection.sendStanza(reply); } else { // Send reply to multiple recipients List<Jid> to = new ArrayList<>(info.getTOAddresses().size()); List<Jid> cc = new ArrayList<>(info.getCCAddresses().size()); for (MultipleAddresses.Address jid : info.getTOAddresses()) { to.add(jid.getJid()); } for (MultipleAddresses.Address jid : info.getCCAddresses()) { cc.add(jid.getJid()); } // Add original sender as a 'to' address (if not already present) if (!to.contains(original.getFrom()) && !cc.contains(original.getFrom())) { to.add(original.getFrom()); } // Remove the sender from the TO/CC list (try with bare JID too) EntityFullJid from = connection.getUser(); if (!to.remove(from) && !cc.remove(from)) { EntityBareJid bareJID = from.asEntityBareJid(); to.remove(bareJID); cc.remove(bareJID); } send(connection, reply, to, cc, null, null, null, false); } }
[ "public", "static", "void", "reply", "(", "XMPPConnection", "connection", ",", "Message", "original", ",", "Message", "reply", ")", "throws", "XMPPErrorException", ",", "InterruptedException", ",", "NotConnectedException", ",", "NoResponseException", ",", "FeatureNotSupportedException", "{", "MultipleRecipientInfo", "info", "=", "getMultipleRecipientInfo", "(", "original", ")", ";", "if", "(", "info", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Original message does not contain multiple recipient info\"", ")", ";", "}", "if", "(", "info", ".", "shouldNotReply", "(", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Original message should not be replied\"", ")", ";", "}", "if", "(", "info", ".", "getReplyRoom", "(", ")", "!=", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Reply should be sent through a room\"", ")", ";", "}", "// Any <thread/> element from the initial message MUST be copied into the reply.", "if", "(", "original", ".", "getThread", "(", ")", "!=", "null", ")", "{", "reply", ".", "setThread", "(", "original", ".", "getThread", "(", ")", ")", ";", "}", "MultipleAddresses", ".", "Address", "replyAddress", "=", "info", ".", "getReplyAddress", "(", ")", ";", "if", "(", "replyAddress", "!=", "null", "&&", "replyAddress", ".", "getJid", "(", ")", "!=", "null", ")", "{", "// Send reply to the reply_to address", "reply", ".", "setTo", "(", "replyAddress", ".", "getJid", "(", ")", ")", ";", "connection", ".", "sendStanza", "(", "reply", ")", ";", "}", "else", "{", "// Send reply to multiple recipients", "List", "<", "Jid", ">", "to", "=", "new", "ArrayList", "<>", "(", "info", ".", "getTOAddresses", "(", ")", ".", "size", "(", ")", ")", ";", "List", "<", "Jid", ">", "cc", "=", "new", "ArrayList", "<>", "(", "info", ".", "getCCAddresses", "(", ")", ".", "size", "(", ")", ")", ";", "for", "(", "MultipleAddresses", ".", "Address", "jid", ":", "info", ".", "getTOAddresses", "(", ")", ")", "{", "to", ".", "add", "(", "jid", ".", "getJid", "(", ")", ")", ";", "}", "for", "(", "MultipleAddresses", ".", "Address", "jid", ":", "info", ".", "getCCAddresses", "(", ")", ")", "{", "cc", ".", "add", "(", "jid", ".", "getJid", "(", ")", ")", ";", "}", "// Add original sender as a 'to' address (if not already present)", "if", "(", "!", "to", ".", "contains", "(", "original", ".", "getFrom", "(", ")", ")", "&&", "!", "cc", ".", "contains", "(", "original", ".", "getFrom", "(", ")", ")", ")", "{", "to", ".", "add", "(", "original", ".", "getFrom", "(", ")", ")", ";", "}", "// Remove the sender from the TO/CC list (try with bare JID too)", "EntityFullJid", "from", "=", "connection", ".", "getUser", "(", ")", ";", "if", "(", "!", "to", ".", "remove", "(", "from", ")", "&&", "!", "cc", ".", "remove", "(", "from", ")", ")", "{", "EntityBareJid", "bareJID", "=", "from", ".", "asEntityBareJid", "(", ")", ";", "to", ".", "remove", "(", "bareJID", ")", ";", "cc", ".", "remove", "(", "bareJID", ")", ";", "}", "send", "(", "connection", ",", "reply", ",", "to", ",", "cc", ",", "null", ",", "null", ",", "null", ",", "false", ")", ";", "}", "}" ]
Sends a reply to a previously received stanza that was sent to multiple recipients. Before attempting to send the reply message some checks are performed. If any of those checks fails, then an XMPPException is going to be thrown with the specific error detail. @param connection the connection to use to send the reply. @param original the previously received stanza that was sent to multiple recipients. @param reply the new message to send as a reply. @throws XMPPErrorException @throws InterruptedException @throws NotConnectedException @throws FeatureNotSupportedException @throws NoResponseException
[ "Sends", "a", "reply", "to", "a", "previously", "received", "stanza", "that", "was", "sent", "to", "multiple", "recipients", ".", "Before", "attempting", "to", "send", "the", "reply", "message", "some", "checks", "are", "performed", ".", "If", "any", "of", "those", "checks", "fails", "then", "an", "XMPPException", "is", "going", "to", "be", "thrown", "with", "the", "specific", "error", "detail", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java#L148-L194
26,554
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java
MultipleRecipientManager.getMultipleRecipientServiceAddress
private static DomainBareJid getMultipleRecipientServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); return sdm.findService(MultipleAddresses.NAMESPACE, true); }
java
private static DomainBareJid getMultipleRecipientServiceAddress(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); return sdm.findService(MultipleAddresses.NAMESPACE, true); }
[ "private", "static", "DomainBareJid", "getMultipleRecipientServiceAddress", "(", "XMPPConnection", "connection", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "ServiceDiscoveryManager", "sdm", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ";", "return", "sdm", ".", "findService", "(", "MultipleAddresses", ".", "NAMESPACE", ",", "true", ")", ";", "}" ]
Returns the address of the multiple recipients service. To obtain such address service discovery is going to be used on the connected server and if none was found then another attempt will be tried on the server items. The discovered information is going to be cached for 24 hours. @param connection the connection to use for disco. The connected server is going to be queried. @return the address of the multiple recipients service or <tt>null</tt> if none was found. @throws NoResponseException if there was no response from the server. @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "address", "of", "the", "multiple", "recipients", "service", ".", "To", "obtain", "such", "address", "service", "discovery", "is", "going", "to", "be", "used", "on", "the", "connected", "server", "and", "if", "none", "was", "found", "then", "another", "attempt", "will", "be", "tried", "on", "the", "server", "items", ".", "The", "discovered", "information", "is", "going", "to", "be", "cached", "for", "24", "hours", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/address/MultipleRecipientManager.java#L287-L290
26,555
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/delay/DelayInformationManager.java
DelayInformationManager.getDelayInformation
public static DelayInformation getDelayInformation(Stanza packet) { DelayInformation delayInformation = getXep203DelayInformation(packet); if (delayInformation != null) { return delayInformation; } return getLegacyDelayInformation(packet); }
java
public static DelayInformation getDelayInformation(Stanza packet) { DelayInformation delayInformation = getXep203DelayInformation(packet); if (delayInformation != null) { return delayInformation; } return getLegacyDelayInformation(packet); }
[ "public", "static", "DelayInformation", "getDelayInformation", "(", "Stanza", "packet", ")", "{", "DelayInformation", "delayInformation", "=", "getXep203DelayInformation", "(", "packet", ")", ";", "if", "(", "delayInformation", "!=", "null", ")", "{", "return", "delayInformation", ";", "}", "return", "getLegacyDelayInformation", "(", "packet", ")", ";", "}" ]
Get Delayed Delivery information. This method first looks for a PacketExtension with the XEP-203 namespace and falls back to the XEP-91 namespace. @param packet @return the Delayed Delivery information or <code>null</code>
[ "Get", "Delayed", "Delivery", "information", ".", "This", "method", "first", "looks", "for", "a", "PacketExtension", "with", "the", "XEP", "-", "203", "namespace", "and", "falls", "back", "to", "the", "XEP", "-", "91", "namespace", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/delay/DelayInformationManager.java#L70-L76
26,556
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
PushNotificationsManager.getInstanceFor
public static synchronized PushNotificationsManager getInstanceFor(XMPPConnection connection) { PushNotificationsManager pushNotificationsManager = INSTANCES.get(connection); if (pushNotificationsManager == null) { pushNotificationsManager = new PushNotificationsManager(connection); INSTANCES.put(connection, pushNotificationsManager); } return pushNotificationsManager; }
java
public static synchronized PushNotificationsManager getInstanceFor(XMPPConnection connection) { PushNotificationsManager pushNotificationsManager = INSTANCES.get(connection); if (pushNotificationsManager == null) { pushNotificationsManager = new PushNotificationsManager(connection); INSTANCES.put(connection, pushNotificationsManager); } return pushNotificationsManager; }
[ "public", "static", "synchronized", "PushNotificationsManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "PushNotificationsManager", "pushNotificationsManager", "=", "INSTANCES", ".", "get", "(", "connection", ")", ";", "if", "(", "pushNotificationsManager", "==", "null", ")", "{", "pushNotificationsManager", "=", "new", "PushNotificationsManager", "(", "connection", ")", ";", "INSTANCES", ".", "put", "(", "connection", ",", "pushNotificationsManager", ")", ";", "}", "return", "pushNotificationsManager", ";", "}" ]
Get the singleton instance of PushNotificationsManager. @param connection @return the instance of PushNotificationsManager
[ "Get", "the", "singleton", "instance", "of", "PushNotificationsManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java#L67-L76
26,557
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
PushNotificationsManager.isSupported
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).accountSupportsFeatures( PushNotificationsElements.NAMESPACE); }
java
public boolean isSupported() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return ServiceDiscoveryManager.getInstanceFor(connection()).accountSupportsFeatures( PushNotificationsElements.NAMESPACE); }
[ "public", "boolean", "isSupported", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", "(", ")", ")", ".", "accountSupportsFeatures", "(", "PushNotificationsElements", ".", "NAMESPACE", ")", ";", "}" ]
Returns true if Push Notifications are supported by this account. @return true if Push Notifications are supported by this account. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @since 4.2.2
[ "Returns", "true", "if", "Push", "Notifications", "are", "supported", "by", "this", "account", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java#L92-L96
26,558
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
PushNotificationsManager.disableAll
public boolean disableAll(Jid pushJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return disable(pushJid, null); }
java
public boolean disableAll(Jid pushJid) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return disable(pushJid, null); }
[ "public", "boolean", "disableAll", "(", "Jid", "pushJid", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "disable", "(", "pushJid", ",", "null", ")", ";", "}" ]
Disable all push notifications. @param pushJid @return true if it was successfully disabled, false if not @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Disable", "all", "push", "notifications", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java#L143-L146
26,559
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java
PushNotificationsManager.disable
public boolean disable(Jid pushJid, String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(pushJid, node); return changePushNotificationsStatus(disablePushNotificationsIQ); }
java
public boolean disable(Jid pushJid, String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DisablePushNotificationsIQ disablePushNotificationsIQ = new DisablePushNotificationsIQ(pushJid, node); return changePushNotificationsStatus(disablePushNotificationsIQ); }
[ "public", "boolean", "disable", "(", "Jid", "pushJid", ",", "String", "node", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "DisablePushNotificationsIQ", "disablePushNotificationsIQ", "=", "new", "DisablePushNotificationsIQ", "(", "pushJid", ",", "node", ")", ";", "return", "changePushNotificationsStatus", "(", "disablePushNotificationsIQ", ")", ";", "}" ]
Disable push notifications of an specific node. @param pushJid @param node @return true if it was successfully disabled, false if not @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "Disable", "push", "notifications", "of", "an", "specific", "node", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/push_notifications/PushNotificationsManager.java#L159-L163
26,560
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.removeIdentity
public synchronized boolean removeIdentity(DiscoverInfo.Identity identity) { if (identity.equals(this.identity)) return false; identities.remove(identity); // Notify others of a state change of SDM. In order to keep the state consistent, this // method is synchronized renewEntityCapsVersion(); return true; }
java
public synchronized boolean removeIdentity(DiscoverInfo.Identity identity) { if (identity.equals(this.identity)) return false; identities.remove(identity); // Notify others of a state change of SDM. In order to keep the state consistent, this // method is synchronized renewEntityCapsVersion(); return true; }
[ "public", "synchronized", "boolean", "removeIdentity", "(", "DiscoverInfo", ".", "Identity", "identity", ")", "{", "if", "(", "identity", ".", "equals", "(", "this", ".", "identity", ")", ")", "return", "false", ";", "identities", ".", "remove", "(", "identity", ")", ";", "// Notify others of a state change of SDM. In order to keep the state consistent, this", "// method is synchronized", "renewEntityCapsVersion", "(", ")", ";", "return", "true", ";", "}" ]
Remove an identity from the client. Note that the client needs at least one identity, the default identity, which can not be removed. @param identity @return true, if successful. Otherwise the default identity was given.
[ "Remove", "an", "identity", "from", "the", "client", ".", "Note", "that", "the", "client", "needs", "at", "least", "one", "identity", "the", "default", "identity", "which", "can", "not", "be", "removed", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L258-L265
26,561
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.getIdentities
public Set<DiscoverInfo.Identity> getIdentities() { Set<Identity> res = new HashSet<>(identities); // Add the main identity that must exist res.add(identity); return Collections.unmodifiableSet(res); }
java
public Set<DiscoverInfo.Identity> getIdentities() { Set<Identity> res = new HashSet<>(identities); // Add the main identity that must exist res.add(identity); return Collections.unmodifiableSet(res); }
[ "public", "Set", "<", "DiscoverInfo", ".", "Identity", ">", "getIdentities", "(", ")", "{", "Set", "<", "Identity", ">", "res", "=", "new", "HashSet", "<>", "(", "identities", ")", ";", "// Add the main identity that must exist", "res", ".", "add", "(", "identity", ")", ";", "return", "Collections", ".", "unmodifiableSet", "(", "res", ")", ";", "}" ]
Returns all identities of this client as unmodifiable Collection. @return all identies as set
[ "Returns", "all", "identities", "of", "this", "client", "as", "unmodifiable", "Collection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L272-L277
26,562
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.getInstanceFor
public static synchronized ServiceDiscoveryManager getInstanceFor(XMPPConnection connection) { ServiceDiscoveryManager sdm = instances.get(connection); if (sdm == null) { sdm = new ServiceDiscoveryManager(connection); // Register the new instance and associate it with the connection instances.put(connection, sdm); } return sdm; }
java
public static synchronized ServiceDiscoveryManager getInstanceFor(XMPPConnection connection) { ServiceDiscoveryManager sdm = instances.get(connection); if (sdm == null) { sdm = new ServiceDiscoveryManager(connection); // Register the new instance and associate it with the connection instances.put(connection, sdm); } return sdm; }
[ "public", "static", "synchronized", "ServiceDiscoveryManager", "getInstanceFor", "(", "XMPPConnection", "connection", ")", "{", "ServiceDiscoveryManager", "sdm", "=", "instances", ".", "get", "(", "connection", ")", ";", "if", "(", "sdm", "==", "null", ")", "{", "sdm", "=", "new", "ServiceDiscoveryManager", "(", "connection", ")", ";", "// Register the new instance and associate it with the connection", "instances", ".", "put", "(", "connection", ",", "sdm", ")", ";", "}", "return", "sdm", ";", "}" ]
Returns the ServiceDiscoveryManager instance associated with a given XMPPConnection. @param connection the connection used to look for the proper ServiceDiscoveryManager. @return the ServiceDiscoveryManager associated with a given XMPPConnection.
[ "Returns", "the", "ServiceDiscoveryManager", "instance", "associated", "with", "a", "given", "XMPPConnection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L285-L293
26,563
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.addDiscoverInfoTo
public synchronized void addDiscoverInfoTo(DiscoverInfo response) { // First add the identities of the connection response.addIdentities(getIdentities()); // Add the registered features to the response for (String feature : getFeatures()) { response.addFeature(feature); } response.addExtension(extendedInfo); }
java
public synchronized void addDiscoverInfoTo(DiscoverInfo response) { // First add the identities of the connection response.addIdentities(getIdentities()); // Add the registered features to the response for (String feature : getFeatures()) { response.addFeature(feature); } response.addExtension(extendedInfo); }
[ "public", "synchronized", "void", "addDiscoverInfoTo", "(", "DiscoverInfo", "response", ")", "{", "// First add the identities of the connection", "response", ".", "addIdentities", "(", "getIdentities", "(", ")", ")", ";", "// Add the registered features to the response", "for", "(", "String", "feature", ":", "getFeatures", "(", ")", ")", "{", "response", ".", "addFeature", "(", "feature", ")", ";", "}", "response", ".", "addExtension", "(", "extendedInfo", ")", ";", "}" ]
Add discover info response data. @see <a href="http://xmpp.org/extensions/xep-0030.html#info-basic">XEP-30 Basic Protocol; Example 2</a> @param response the discover info response packet
[ "Add", "discover", "info", "response", "data", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L302-L311
26,564
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.discoverInfo
public DiscoverInfo discoverInfo(Jid entityID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (entityID == null) return discoverInfo(null, null); synchronized (discoInfoLookupShortcutMechanisms) { for (DiscoInfoLookupShortcutMechanism discoInfoLookupShortcutMechanism : discoInfoLookupShortcutMechanisms) { DiscoverInfo info = discoInfoLookupShortcutMechanism.getDiscoverInfoByUser(this, entityID); if (info != null) { // We were able to retrieve the information from Entity Caps and // avoided a disco request, hurray! return info; } } } // Last resort: Standard discovery. return discoverInfo(entityID, null); }
java
public DiscoverInfo discoverInfo(Jid entityID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (entityID == null) return discoverInfo(null, null); synchronized (discoInfoLookupShortcutMechanisms) { for (DiscoInfoLookupShortcutMechanism discoInfoLookupShortcutMechanism : discoInfoLookupShortcutMechanisms) { DiscoverInfo info = discoInfoLookupShortcutMechanism.getDiscoverInfoByUser(this, entityID); if (info != null) { // We were able to retrieve the information from Entity Caps and // avoided a disco request, hurray! return info; } } } // Last resort: Standard discovery. return discoverInfo(entityID, null); }
[ "public", "DiscoverInfo", "discoverInfo", "(", "Jid", "entityID", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "if", "(", "entityID", "==", "null", ")", "return", "discoverInfo", "(", "null", ",", "null", ")", ";", "synchronized", "(", "discoInfoLookupShortcutMechanisms", ")", "{", "for", "(", "DiscoInfoLookupShortcutMechanism", "discoInfoLookupShortcutMechanism", ":", "discoInfoLookupShortcutMechanisms", ")", "{", "DiscoverInfo", "info", "=", "discoInfoLookupShortcutMechanism", ".", "getDiscoverInfoByUser", "(", "this", ",", "entityID", ")", ";", "if", "(", "info", "!=", "null", ")", "{", "// We were able to retrieve the information from Entity Caps and", "// avoided a disco request, hurray!", "return", "info", ";", "}", "}", "}", "// Last resort: Standard discovery.", "return", "discoverInfo", "(", "entityID", ",", "null", ")", ";", "}" ]
Returns the discovered information of a given XMPP entity addressed by its JID. Use null as entityID to query the server @param entityID the address of the XMPP entity or null. @return the discovered information. @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "discovered", "information", "of", "a", "given", "XMPP", "entity", "addressed", "by", "its", "JID", ".", "Use", "null", "as", "entityID", "to", "query", "the", "server" ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L489-L506
26,565
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.discoverInfo
public DiscoverInfo discoverInfo(Jid entityID, String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Discover the entity's info DiscoverInfo disco = new DiscoverInfo(); disco.setType(IQ.Type.get); disco.setTo(entityID); disco.setNode(node); Stanza result = connection().createStanzaCollectorAndSend(disco).nextResultOrThrow(); return (DiscoverInfo) result; }
java
public DiscoverInfo discoverInfo(Jid entityID, String node) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { // Discover the entity's info DiscoverInfo disco = new DiscoverInfo(); disco.setType(IQ.Type.get); disco.setTo(entityID); disco.setNode(node); Stanza result = connection().createStanzaCollectorAndSend(disco).nextResultOrThrow(); return (DiscoverInfo) result; }
[ "public", "DiscoverInfo", "discoverInfo", "(", "Jid", "entityID", ",", "String", "node", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "// Discover the entity's info", "DiscoverInfo", "disco", "=", "new", "DiscoverInfo", "(", ")", ";", "disco", ".", "setType", "(", "IQ", ".", "Type", ".", "get", ")", ";", "disco", ".", "setTo", "(", "entityID", ")", ";", "disco", ".", "setNode", "(", "node", ")", ";", "Stanza", "result", "=", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "disco", ")", ".", "nextResultOrThrow", "(", ")", ";", "return", "(", "DiscoverInfo", ")", "result", ";", "}" ]
Returns the discovered information of a given XMPP entity addressed by its JID and note attribute. Use this message only when trying to query information which is not directly addressable. @see <a href="http://xmpp.org/extensions/xep-0030.html#info-basic">XEP-30 Basic Protocol</a> @see <a href="http://xmpp.org/extensions/xep-0030.html#info-nodes">XEP-30 Info Nodes</a> @param entityID the address of the XMPP entity. @param node the optional attribute that supplements the 'jid' attribute. @return the discovered information. @throws XMPPErrorException if the operation failed for some reason. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "discovered", "information", "of", "a", "given", "XMPP", "entity", "addressed", "by", "its", "JID", "and", "note", "attribute", ".", "Use", "this", "message", "only", "when", "trying", "to", "query", "information", "which", "is", "not", "directly", "addressable", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L524-L534
26,566
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.discoverItems
public DiscoverItems discoverItems(Jid entityID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return discoverItems(entityID, null); }
java
public DiscoverItems discoverItems(Jid entityID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return discoverItems(entityID, null); }
[ "public", "DiscoverItems", "discoverItems", "(", "Jid", "entityID", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "discoverItems", "(", "entityID", ",", "null", ")", ";", "}" ]
Returns the discovered items of a given XMPP entity addressed by its JID. @param entityID the address of the XMPP entity. @return the discovered information. @throws XMPPErrorException if the operation failed for some reason. @throws NoResponseException if there was no response from the server. @throws NotConnectedException @throws InterruptedException
[ "Returns", "the", "discovered", "items", "of", "a", "given", "XMPP", "entity", "addressed", "by", "its", "JID", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L546-L548
26,567
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.accountSupportsFeatures
public boolean accountSupportsFeatures(CharSequence... features) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return accountSupportsFeatures(Arrays.asList(features)); }
java
public boolean accountSupportsFeatures(CharSequence... features) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return accountSupportsFeatures(Arrays.asList(features)); }
[ "public", "boolean", "accountSupportsFeatures", "(", "CharSequence", "...", "features", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "accountSupportsFeatures", "(", "Arrays", ".", "asList", "(", "features", ")", ")", ";", "}" ]
Check if the given features are supported by the connection account. This means that the discovery information lookup will be performed on the bare JID of the connection managed by this ServiceDiscoveryManager. @param features the features to check @return <code>true</code> if all features are supported by the connection account, <code>false</code> otherwise @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @since 4.2.2
[ "Check", "if", "the", "given", "features", "are", "supported", "by", "the", "connection", "account", ".", "This", "means", "that", "the", "discovery", "information", "lookup", "will", "be", "performed", "on", "the", "bare", "JID", "of", "the", "connection", "managed", "by", "this", "ServiceDiscoveryManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L613-L616
26,568
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.accountSupportsFeatures
public boolean accountSupportsFeatures(Collection<? extends CharSequence> features) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { EntityBareJid accountJid = connection().getUser().asEntityBareJid(); return supportsFeatures(accountJid, features); }
java
public boolean accountSupportsFeatures(Collection<? extends CharSequence> features) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { EntityBareJid accountJid = connection().getUser().asEntityBareJid(); return supportsFeatures(accountJid, features); }
[ "public", "boolean", "accountSupportsFeatures", "(", "Collection", "<", "?", "extends", "CharSequence", ">", "features", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "EntityBareJid", "accountJid", "=", "connection", "(", ")", ".", "getUser", "(", ")", ".", "asEntityBareJid", "(", ")", ";", "return", "supportsFeatures", "(", "accountJid", ",", "features", ")", ";", "}" ]
Check if the given collection of features are supported by the connection account. This means that the discovery information lookup will be performed on the bare JID of the connection managed by this ServiceDiscoveryManager. @param features a collection of features @return <code>true</code> if all features are supported by the connection account, <code>false</code> otherwise @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @since 4.2.2
[ "Check", "if", "the", "given", "collection", "of", "features", "are", "supported", "by", "the", "connection", "account", ".", "This", "means", "that", "the", "discovery", "information", "lookup", "will", "be", "performed", "on", "the", "bare", "JID", "of", "the", "connection", "managed", "by", "this", "ServiceDiscoveryManager", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L630-L634
26,569
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.supportsFeature
public boolean supportsFeature(Jid jid, CharSequence feature) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return supportsFeatures(jid, feature); }
java
public boolean supportsFeature(Jid jid, CharSequence feature) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { return supportsFeatures(jid, feature); }
[ "public", "boolean", "supportsFeature", "(", "Jid", "jid", ",", "CharSequence", "feature", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "return", "supportsFeatures", "(", "jid", ",", "feature", ")", ";", "}" ]
Queries the remote entity for it's features and returns true if the given feature is found. @param jid the JID of the remote entity @param feature @return true if the entity supports the feature, false otherwise @throws XMPPErrorException @throws NoResponseException @throws NotConnectedException @throws InterruptedException
[ "Queries", "the", "remote", "entity", "for", "it", "s", "features", "and", "returns", "true", "if", "the", "given", "feature", "is", "found", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L647-L649
26,570
igniterealtime/Smack
smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java
ServiceDiscoveryManager.findServicesDiscoverInfo
public List<DiscoverInfo> findServicesDiscoverInfo(DomainBareJid serviceName, String feature, boolean stopOnFirst, boolean useCache, Map<? super Jid, Exception> encounteredExceptions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List<DiscoverInfo> serviceDiscoInfo; if (useCache) { serviceDiscoInfo = services.lookup(feature); if (serviceDiscoInfo != null) { return serviceDiscoInfo; } } serviceDiscoInfo = new LinkedList<>(); // Send the disco packet to the server itself DiscoverInfo info; try { info = discoverInfo(serviceName); } catch (XMPPErrorException e) { if (encounteredExceptions != null) { encounteredExceptions.put(serviceName, e); } return serviceDiscoInfo; } // Check if the server supports the feature if (info.containsFeature(feature)) { serviceDiscoInfo.add(info); if (stopOnFirst) { if (useCache) { // Cache the discovered information services.put(feature, serviceDiscoInfo); } return serviceDiscoInfo; } } DiscoverItems items; try { // Get the disco items and send the disco packet to each server item items = discoverItems(serviceName); } catch (XMPPErrorException e) { if (encounteredExceptions != null) { encounteredExceptions.put(serviceName, e); } return serviceDiscoInfo; } for (DiscoverItems.Item item : items.getItems()) { Jid address = item.getEntityID(); try { // TODO is it OK here in all cases to query without the node attribute? // MultipleRecipientManager queried initially also with the node attribute, but this // could be simply a fault instead of intentional. info = discoverInfo(address); } catch (XMPPErrorException | NoResponseException e) { if (encounteredExceptions != null) { encounteredExceptions.put(address, e); } continue; } if (info.containsFeature(feature)) { serviceDiscoInfo.add(info); if (stopOnFirst) { break; } } } if (useCache) { // Cache the discovered information services.put(feature, serviceDiscoInfo); } return serviceDiscoInfo; }
java
public List<DiscoverInfo> findServicesDiscoverInfo(DomainBareJid serviceName, String feature, boolean stopOnFirst, boolean useCache, Map<? super Jid, Exception> encounteredExceptions) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { List<DiscoverInfo> serviceDiscoInfo; if (useCache) { serviceDiscoInfo = services.lookup(feature); if (serviceDiscoInfo != null) { return serviceDiscoInfo; } } serviceDiscoInfo = new LinkedList<>(); // Send the disco packet to the server itself DiscoverInfo info; try { info = discoverInfo(serviceName); } catch (XMPPErrorException e) { if (encounteredExceptions != null) { encounteredExceptions.put(serviceName, e); } return serviceDiscoInfo; } // Check if the server supports the feature if (info.containsFeature(feature)) { serviceDiscoInfo.add(info); if (stopOnFirst) { if (useCache) { // Cache the discovered information services.put(feature, serviceDiscoInfo); } return serviceDiscoInfo; } } DiscoverItems items; try { // Get the disco items and send the disco packet to each server item items = discoverItems(serviceName); } catch (XMPPErrorException e) { if (encounteredExceptions != null) { encounteredExceptions.put(serviceName, e); } return serviceDiscoInfo; } for (DiscoverItems.Item item : items.getItems()) { Jid address = item.getEntityID(); try { // TODO is it OK here in all cases to query without the node attribute? // MultipleRecipientManager queried initially also with the node attribute, but this // could be simply a fault instead of intentional. info = discoverInfo(address); } catch (XMPPErrorException | NoResponseException e) { if (encounteredExceptions != null) { encounteredExceptions.put(address, e); } continue; } if (info.containsFeature(feature)) { serviceDiscoInfo.add(info); if (stopOnFirst) { break; } } } if (useCache) { // Cache the discovered information services.put(feature, serviceDiscoInfo); } return serviceDiscoInfo; }
[ "public", "List", "<", "DiscoverInfo", ">", "findServicesDiscoverInfo", "(", "DomainBareJid", "serviceName", ",", "String", "feature", ",", "boolean", "stopOnFirst", ",", "boolean", "useCache", ",", "Map", "<", "?", "super", "Jid", ",", "Exception", ">", "encounteredExceptions", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "List", "<", "DiscoverInfo", ">", "serviceDiscoInfo", ";", "if", "(", "useCache", ")", "{", "serviceDiscoInfo", "=", "services", ".", "lookup", "(", "feature", ")", ";", "if", "(", "serviceDiscoInfo", "!=", "null", ")", "{", "return", "serviceDiscoInfo", ";", "}", "}", "serviceDiscoInfo", "=", "new", "LinkedList", "<>", "(", ")", ";", "// Send the disco packet to the server itself", "DiscoverInfo", "info", ";", "try", "{", "info", "=", "discoverInfo", "(", "serviceName", ")", ";", "}", "catch", "(", "XMPPErrorException", "e", ")", "{", "if", "(", "encounteredExceptions", "!=", "null", ")", "{", "encounteredExceptions", ".", "put", "(", "serviceName", ",", "e", ")", ";", "}", "return", "serviceDiscoInfo", ";", "}", "// Check if the server supports the feature", "if", "(", "info", ".", "containsFeature", "(", "feature", ")", ")", "{", "serviceDiscoInfo", ".", "add", "(", "info", ")", ";", "if", "(", "stopOnFirst", ")", "{", "if", "(", "useCache", ")", "{", "// Cache the discovered information", "services", ".", "put", "(", "feature", ",", "serviceDiscoInfo", ")", ";", "}", "return", "serviceDiscoInfo", ";", "}", "}", "DiscoverItems", "items", ";", "try", "{", "// Get the disco items and send the disco packet to each server item", "items", "=", "discoverItems", "(", "serviceName", ")", ";", "}", "catch", "(", "XMPPErrorException", "e", ")", "{", "if", "(", "encounteredExceptions", "!=", "null", ")", "{", "encounteredExceptions", ".", "put", "(", "serviceName", ",", "e", ")", ";", "}", "return", "serviceDiscoInfo", ";", "}", "for", "(", "DiscoverItems", ".", "Item", "item", ":", "items", ".", "getItems", "(", ")", ")", "{", "Jid", "address", "=", "item", ".", "getEntityID", "(", ")", ";", "try", "{", "// TODO is it OK here in all cases to query without the node attribute?", "// MultipleRecipientManager queried initially also with the node attribute, but this", "// could be simply a fault instead of intentional.", "info", "=", "discoverInfo", "(", "address", ")", ";", "}", "catch", "(", "XMPPErrorException", "|", "NoResponseException", "e", ")", "{", "if", "(", "encounteredExceptions", "!=", "null", ")", "{", "encounteredExceptions", ".", "put", "(", "address", ",", "e", ")", ";", "}", "continue", ";", "}", "if", "(", "info", ".", "containsFeature", "(", "feature", ")", ")", "{", "serviceDiscoInfo", ".", "add", "(", "info", ")", ";", "if", "(", "stopOnFirst", ")", "{", "break", ";", "}", "}", "}", "if", "(", "useCache", ")", "{", "// Cache the discovered information", "services", ".", "put", "(", "feature", ",", "serviceDiscoInfo", ")", ";", "}", "return", "serviceDiscoInfo", ";", "}" ]
Find all services under a given service that provide a given feature. @param serviceName the service to query @param feature the feature to search for @param stopOnFirst if true, stop searching after the first service was found @param useCache if true, query a cache first to avoid network I/O @param encounteredExceptions an optional map which will be filled with the exceptions encountered @return a possible empty list of services providing the given feature @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @since 4.3.0
[ "Find", "all", "services", "under", "a", "given", "service", "that", "provide", "a", "given", "feature", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/ServiceDiscoveryManager.java#L724-L792
26,571
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java
IoTProvisioningManager.findProvisioningServerComponent
public DomainBareJid findProvisioningServerComponent() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final XMPPConnection connection = connection(); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); List<DiscoverInfo> discoverInfos = sdm.findServicesDiscoverInfo(Constants.IOT_PROVISIONING_NAMESPACE, true, true); if (discoverInfos.isEmpty()) { return null; } Jid jid = discoverInfos.get(0).getFrom(); assert (jid.isDomainBareJid()); return jid.asDomainBareJid(); }
java
public DomainBareJid findProvisioningServerComponent() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { final XMPPConnection connection = connection(); ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection); List<DiscoverInfo> discoverInfos = sdm.findServicesDiscoverInfo(Constants.IOT_PROVISIONING_NAMESPACE, true, true); if (discoverInfos.isEmpty()) { return null; } Jid jid = discoverInfos.get(0).getFrom(); assert (jid.isDomainBareJid()); return jid.asDomainBareJid(); }
[ "public", "DomainBareJid", "findProvisioningServerComponent", "(", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "final", "XMPPConnection", "connection", "=", "connection", "(", ")", ";", "ServiceDiscoveryManager", "sdm", "=", "ServiceDiscoveryManager", ".", "getInstanceFor", "(", "connection", ")", ";", "List", "<", "DiscoverInfo", ">", "discoverInfos", "=", "sdm", ".", "findServicesDiscoverInfo", "(", "Constants", ".", "IOT_PROVISIONING_NAMESPACE", ",", "true", ",", "true", ")", ";", "if", "(", "discoverInfos", ".", "isEmpty", "(", ")", ")", "{", "return", "null", ";", "}", "Jid", "jid", "=", "discoverInfos", ".", "get", "(", "0", ")", ".", "getFrom", "(", ")", ";", "assert", "(", "jid", ".", "isDomainBareJid", "(", ")", ")", ";", "return", "jid", ".", "asDomainBareJid", "(", ")", ";", "}" ]
Try to find a provisioning server component. @return the XMPP address of the provisioning server component if one was found. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException @see <a href="http://xmpp.org/extensions/xep-0324.html#servercomponent">XEP-0324 § 3.1.2 Provisioning Server as a server component</a>
[ "Try", "to", "find", "a", "provisioning", "server", "component", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java#L311-L321
26,572
igniterealtime/Smack
smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java
IoTProvisioningManager.isFriend
public boolean isFriend(Jid provisioningServer, BareJid friendInQuestion) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { LruCache<BareJid, Void> cache = negativeFriendshipRequestCache.lookup(provisioningServer); if (cache != null && cache.containsKey(friendInQuestion)) { // We hit a cached negative isFriend response for this provisioning server. return false; } IoTIsFriend iotIsFriend = new IoTIsFriend(friendInQuestion); iotIsFriend.setTo(provisioningServer); IoTIsFriendResponse response = connection().createStanzaCollectorAndSend(iotIsFriend).nextResultOrThrow(); assert (response.getJid().equals(friendInQuestion)); boolean isFriend = response.getIsFriendResult(); if (!isFriend) { // Cache the negative is friend response. if (cache == null) { cache = new LruCache<>(1024); negativeFriendshipRequestCache.put(provisioningServer, cache); } cache.put(friendInQuestion, null); } return isFriend; }
java
public boolean isFriend(Jid provisioningServer, BareJid friendInQuestion) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { LruCache<BareJid, Void> cache = negativeFriendshipRequestCache.lookup(provisioningServer); if (cache != null && cache.containsKey(friendInQuestion)) { // We hit a cached negative isFriend response for this provisioning server. return false; } IoTIsFriend iotIsFriend = new IoTIsFriend(friendInQuestion); iotIsFriend.setTo(provisioningServer); IoTIsFriendResponse response = connection().createStanzaCollectorAndSend(iotIsFriend).nextResultOrThrow(); assert (response.getJid().equals(friendInQuestion)); boolean isFriend = response.getIsFriendResult(); if (!isFriend) { // Cache the negative is friend response. if (cache == null) { cache = new LruCache<>(1024); negativeFriendshipRequestCache.put(provisioningServer, cache); } cache.put(friendInQuestion, null); } return isFriend; }
[ "public", "boolean", "isFriend", "(", "Jid", "provisioningServer", ",", "BareJid", "friendInQuestion", ")", "throws", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "LruCache", "<", "BareJid", ",", "Void", ">", "cache", "=", "negativeFriendshipRequestCache", ".", "lookup", "(", "provisioningServer", ")", ";", "if", "(", "cache", "!=", "null", "&&", "cache", ".", "containsKey", "(", "friendInQuestion", ")", ")", "{", "// We hit a cached negative isFriend response for this provisioning server.", "return", "false", ";", "}", "IoTIsFriend", "iotIsFriend", "=", "new", "IoTIsFriend", "(", "friendInQuestion", ")", ";", "iotIsFriend", ".", "setTo", "(", "provisioningServer", ")", ";", "IoTIsFriendResponse", "response", "=", "connection", "(", ")", ".", "createStanzaCollectorAndSend", "(", "iotIsFriend", ")", ".", "nextResultOrThrow", "(", ")", ";", "assert", "(", "response", ".", "getJid", "(", ")", ".", "equals", "(", "friendInQuestion", ")", ")", ";", "boolean", "isFriend", "=", "response", ".", "getIsFriendResult", "(", ")", ";", "if", "(", "!", "isFriend", ")", "{", "// Cache the negative is friend response.", "if", "(", "cache", "==", "null", ")", "{", "cache", "=", "new", "LruCache", "<>", "(", "1024", ")", ";", "negativeFriendshipRequestCache", ".", "put", "(", "provisioningServer", ",", "cache", ")", ";", "}", "cache", ".", "put", "(", "friendInQuestion", ",", "null", ")", ";", "}", "return", "isFriend", ";", "}" ]
As the given provisioning server is the given JID is a friend. @param provisioningServer the provisioning server to ask. @param friendInQuestion the JID to ask about. @return <code>true</code> if the JID is a friend, <code>false</code> otherwise. @throws NoResponseException @throws XMPPErrorException @throws NotConnectedException @throws InterruptedException
[ "As", "the", "given", "provisioning", "server", "is", "the", "given", "JID", "is", "a", "friend", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-experimental/src/main/java/org/jivesoftware/smackx/iot/provisioning/IoTProvisioningManager.java#L334-L355
26,573
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
AbstractXMPPConnection.disconnect
public void disconnect() { Presence unavailablePresence = null; if (isAuthenticated()) { unavailablePresence = new Presence(Presence.Type.unavailable); } try { disconnect(unavailablePresence); } catch (NotConnectedException e) { LOGGER.log(Level.FINEST, "Connection is already disconnected", e); } }
java
public void disconnect() { Presence unavailablePresence = null; if (isAuthenticated()) { unavailablePresence = new Presence(Presence.Type.unavailable); } try { disconnect(unavailablePresence); } catch (NotConnectedException e) { LOGGER.log(Level.FINEST, "Connection is already disconnected", e); } }
[ "public", "void", "disconnect", "(", ")", "{", "Presence", "unavailablePresence", "=", "null", ";", "if", "(", "isAuthenticated", "(", ")", ")", "{", "unavailablePresence", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "}", "try", "{", "disconnect", "(", "unavailablePresence", ")", ";", "}", "catch", "(", "NotConnectedException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "FINEST", ",", "\"Connection is already disconnected\"", ",", "e", ")", ";", "}", "}" ]
Closes the connection by setting presence to unavailable then closing the connection to the XMPP server. The XMPPConnection can still be used for connecting to the server again.
[ "Closes", "the", "connection", "by", "setting", "presence", "to", "unavailable", "then", "closing", "the", "connection", "to", "the", "XMPP", "server", ".", "The", "XMPPConnection", "can", "still", "be", "used", "for", "connecting", "to", "the", "server", "again", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java#L820-L831
26,574
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
AbstractXMPPConnection.disconnect
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException { if (unavailablePresence != null) { try { sendStanza(unavailablePresence); } catch (InterruptedException e) { LOGGER.log(Level.FINE, "Was interrupted while sending unavailable presence. Continuing to disconnect the connection", e); } } shutdown(); callConnectionClosedListener(); }
java
public synchronized void disconnect(Presence unavailablePresence) throws NotConnectedException { if (unavailablePresence != null) { try { sendStanza(unavailablePresence); } catch (InterruptedException e) { LOGGER.log(Level.FINE, "Was interrupted while sending unavailable presence. Continuing to disconnect the connection", e); } } shutdown(); callConnectionClosedListener(); }
[ "public", "synchronized", "void", "disconnect", "(", "Presence", "unavailablePresence", ")", "throws", "NotConnectedException", "{", "if", "(", "unavailablePresence", "!=", "null", ")", "{", "try", "{", "sendStanza", "(", "unavailablePresence", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "FINE", ",", "\"Was interrupted while sending unavailable presence. Continuing to disconnect the connection\"", ",", "e", ")", ";", "}", "}", "shutdown", "(", ")", ";", "callConnectionClosedListener", "(", ")", ";", "}" ]
Closes the connection. A custom unavailable presence is sent to the server, followed by closing the stream. The XMPPConnection can still be used for connecting to the server again. A custom unavailable presence is useful for communicating offline presence information such as "On vacation". Typically, just the status text of the presence stanza is set with online information, but most XMPP servers will deliver the full presence stanza with whatever data is set. @param unavailablePresence the optional presence stanza to send during shutdown. @throws NotConnectedException
[ "Closes", "the", "connection", ".", "A", "custom", "unavailable", "presence", "is", "sent", "to", "the", "server", "followed", "by", "closing", "the", "stream", ".", "The", "XMPPConnection", "can", "still", "be", "used", "for", "connecting", "to", "the", "server", "again", ".", "A", "custom", "unavailable", "presence", "is", "useful", "for", "communicating", "offline", "presence", "information", "such", "as", "On", "vacation", ".", "Typically", "just", "the", "status", "text", "of", "the", "presence", "stanza", "is", "set", "with", "online", "information", "but", "most", "XMPP", "servers", "will", "deliver", "the", "full", "presence", "stanza", "with", "whatever", "data", "is", "set", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java#L844-L856
26,575
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
AbstractXMPPConnection.notifyConnectionError
protected final void notifyConnectionError(final Exception exception) { if (!isConnected()) { LOGGER.log(Level.INFO, "Connection was already disconnected when attempting to handle " + exception, exception); return; } ASYNC_BUT_ORDERED.performAsyncButOrdered(this, () -> { currentConnectionException = exception; for (StanzaCollector collector : collectors) { collector.notifyConnectionError(exception); } SmackWrappedException smackWrappedException = new SmackWrappedException(exception); tlsHandled.reportGenericFailure(smackWrappedException); saslFeatureReceived.reportGenericFailure(smackWrappedException); lastFeaturesReceived.reportGenericFailure(smackWrappedException); // TODO From XMPPTCPConnection. Was called in Smack 4.3 where notifyConnectionError() was part of // XMPPTCPConnection. Create delegation method? // maybeCompressFeaturesReceived.reportGenericFailure(smackWrappedException); synchronized (AbstractXMPPConnection.this) { notifyAll(); // Closes the connection temporary. A if the connection supports stream management, then a reconnection is // possible. Note that a connection listener of e.g. XMPPTCPConnection will drop the SM state in // case the Exception is a StreamErrorException. instantShutdown(); } Async.go(() -> { // Notify connection listeners of the error. callConnectionClosedOnErrorListener(exception); }, AbstractXMPPConnection.this + " callConnectionClosedOnErrorListener()"); }); }
java
protected final void notifyConnectionError(final Exception exception) { if (!isConnected()) { LOGGER.log(Level.INFO, "Connection was already disconnected when attempting to handle " + exception, exception); return; } ASYNC_BUT_ORDERED.performAsyncButOrdered(this, () -> { currentConnectionException = exception; for (StanzaCollector collector : collectors) { collector.notifyConnectionError(exception); } SmackWrappedException smackWrappedException = new SmackWrappedException(exception); tlsHandled.reportGenericFailure(smackWrappedException); saslFeatureReceived.reportGenericFailure(smackWrappedException); lastFeaturesReceived.reportGenericFailure(smackWrappedException); // TODO From XMPPTCPConnection. Was called in Smack 4.3 where notifyConnectionError() was part of // XMPPTCPConnection. Create delegation method? // maybeCompressFeaturesReceived.reportGenericFailure(smackWrappedException); synchronized (AbstractXMPPConnection.this) { notifyAll(); // Closes the connection temporary. A if the connection supports stream management, then a reconnection is // possible. Note that a connection listener of e.g. XMPPTCPConnection will drop the SM state in // case the Exception is a StreamErrorException. instantShutdown(); } Async.go(() -> { // Notify connection listeners of the error. callConnectionClosedOnErrorListener(exception); }, AbstractXMPPConnection.this + " callConnectionClosedOnErrorListener()"); }); }
[ "protected", "final", "void", "notifyConnectionError", "(", "final", "Exception", "exception", ")", "{", "if", "(", "!", "isConnected", "(", ")", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "INFO", ",", "\"Connection was already disconnected when attempting to handle \"", "+", "exception", ",", "exception", ")", ";", "return", ";", "}", "ASYNC_BUT_ORDERED", ".", "performAsyncButOrdered", "(", "this", ",", "(", ")", "->", "{", "currentConnectionException", "=", "exception", ";", "for", "(", "StanzaCollector", "collector", ":", "collectors", ")", "{", "collector", ".", "notifyConnectionError", "(", "exception", ")", ";", "}", "SmackWrappedException", "smackWrappedException", "=", "new", "SmackWrappedException", "(", "exception", ")", ";", "tlsHandled", ".", "reportGenericFailure", "(", "smackWrappedException", ")", ";", "saslFeatureReceived", ".", "reportGenericFailure", "(", "smackWrappedException", ")", ";", "lastFeaturesReceived", ".", "reportGenericFailure", "(", "smackWrappedException", ")", ";", "// TODO From XMPPTCPConnection. Was called in Smack 4.3 where notifyConnectionError() was part of", "// XMPPTCPConnection. Create delegation method?", "// maybeCompressFeaturesReceived.reportGenericFailure(smackWrappedException);", "synchronized", "(", "AbstractXMPPConnection", ".", "this", ")", "{", "notifyAll", "(", ")", ";", "// Closes the connection temporary. A if the connection supports stream management, then a reconnection is", "// possible. Note that a connection listener of e.g. XMPPTCPConnection will drop the SM state in", "// case the Exception is a StreamErrorException.", "instantShutdown", "(", ")", ";", "}", "Async", ".", "go", "(", "(", ")", "->", "{", "// Notify connection listeners of the error.", "callConnectionClosedOnErrorListener", "(", "exception", ")", ";", "}", ",", "AbstractXMPPConnection", ".", "this", "+", "\" callConnectionClosedOnErrorListener()\"", ")", ";", "}", ")", ";", "}" ]
Sends out a notification that there was an error with the connection and closes the connection. @param exception the exception that causes the connection close event.
[ "Sends", "out", "a", "notification", "that", "there", "was", "an", "error", "with", "the", "connection", "and", "closes", "the", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java#L864-L899
26,576
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
AbstractXMPPConnection.firePacketInterceptors
private void firePacketInterceptors(Stanza packet) { List<StanzaListener> interceptorsToInvoke = new LinkedList<>(); synchronized (interceptors) { for (InterceptorWrapper interceptorWrapper : interceptors.values()) { if (interceptorWrapper.filterMatches(packet)) { interceptorsToInvoke.add(interceptorWrapper.getInterceptor()); } } } for (StanzaListener interceptor : interceptorsToInvoke) { try { interceptor.processStanza(packet); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Packet interceptor threw exception", e); } } }
java
private void firePacketInterceptors(Stanza packet) { List<StanzaListener> interceptorsToInvoke = new LinkedList<>(); synchronized (interceptors) { for (InterceptorWrapper interceptorWrapper : interceptors.values()) { if (interceptorWrapper.filterMatches(packet)) { interceptorsToInvoke.add(interceptorWrapper.getInterceptor()); } } } for (StanzaListener interceptor : interceptorsToInvoke) { try { interceptor.processStanza(packet); } catch (Exception e) { LOGGER.log(Level.SEVERE, "Packet interceptor threw exception", e); } } }
[ "private", "void", "firePacketInterceptors", "(", "Stanza", "packet", ")", "{", "List", "<", "StanzaListener", ">", "interceptorsToInvoke", "=", "new", "LinkedList", "<>", "(", ")", ";", "synchronized", "(", "interceptors", ")", "{", "for", "(", "InterceptorWrapper", "interceptorWrapper", ":", "interceptors", ".", "values", "(", ")", ")", "{", "if", "(", "interceptorWrapper", ".", "filterMatches", "(", "packet", ")", ")", "{", "interceptorsToInvoke", ".", "add", "(", "interceptorWrapper", ".", "getInterceptor", "(", ")", ")", ";", "}", "}", "}", "for", "(", "StanzaListener", "interceptor", ":", "interceptorsToInvoke", ")", "{", "try", "{", "interceptor", ".", "processStanza", "(", "packet", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "SEVERE", ",", "\"Packet interceptor threw exception\"", ",", "e", ")", ";", "}", "}", "}" ]
Process interceptors. Interceptors may modify the stanza that is about to be sent. Since the thread that requested to send the stanza will invoke all interceptors, it is important that interceptors perform their work as soon as possible so that the thread does not remain blocked for a long period. @param packet the stanza that is going to be sent to the server
[ "Process", "interceptors", ".", "Interceptors", "may", "modify", "the", "stanza", "that", "is", "about", "to", "be", "sent", ".", "Since", "the", "thread", "that", "requested", "to", "send", "the", "stanza", "will", "invoke", "all", "interceptors", "it", "is", "important", "that", "interceptors", "perform", "their", "work", "as", "soon", "as", "possible", "so", "that", "the", "thread", "does", "not", "remain", "blocked", "for", "a", "long", "period", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java#L1143-L1159
26,577
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
AbstractXMPPConnection.processStanza
protected void processStanza(final Stanza stanza) throws InterruptedException { assert (stanza != null); final SmackDebugger debugger = this.debugger; if (debugger != null) { debugger.onIncomingStreamElement(stanza); } lastStanzaReceived = System.currentTimeMillis(); // Deliver the incoming packet to listeners. invokeStanzaCollectorsAndNotifyRecvListeners(stanza); }
java
protected void processStanza(final Stanza stanza) throws InterruptedException { assert (stanza != null); final SmackDebugger debugger = this.debugger; if (debugger != null) { debugger.onIncomingStreamElement(stanza); } lastStanzaReceived = System.currentTimeMillis(); // Deliver the incoming packet to listeners. invokeStanzaCollectorsAndNotifyRecvListeners(stanza); }
[ "protected", "void", "processStanza", "(", "final", "Stanza", "stanza", ")", "throws", "InterruptedException", "{", "assert", "(", "stanza", "!=", "null", ")", ";", "final", "SmackDebugger", "debugger", "=", "this", ".", "debugger", ";", "if", "(", "debugger", "!=", "null", ")", "{", "debugger", ".", "onIncomingStreamElement", "(", "stanza", ")", ";", "}", "lastStanzaReceived", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "// Deliver the incoming packet to listeners.", "invokeStanzaCollectorsAndNotifyRecvListeners", "(", "stanza", ")", ";", "}" ]
Processes a stanza after it's been fully parsed by looping through the installed stanza collectors and listeners and letting them examine the stanza to see if they are a match with the filter. @param stanza the stanza to process. @throws InterruptedException
[ "Processes", "a", "stanza", "after", "it", "s", "been", "fully", "parsed", "by", "looping", "through", "the", "installed", "stanza", "collectors", "and", "listeners", "and", "letting", "them", "examine", "the", "stanza", "to", "see", "if", "they", "are", "a", "match", "with", "the", "filter", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java#L1269-L1280
26,578
igniterealtime/Smack
smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java
XMPPBOSHConnection.send
protected void send(ComposableBody body) throws BOSHException { if (!connected) { throw new IllegalStateException("Not connected to a server!"); } if (body == null) { throw new NullPointerException("Body mustn't be null!"); } if (sessionID != null) { body = body.rebuild().setAttribute( BodyQName.create(BOSH_URI, "sid"), sessionID).build(); } client.send(body); }
java
protected void send(ComposableBody body) throws BOSHException { if (!connected) { throw new IllegalStateException("Not connected to a server!"); } if (body == null) { throw new NullPointerException("Body mustn't be null!"); } if (sessionID != null) { body = body.rebuild().setAttribute( BodyQName.create(BOSH_URI, "sid"), sessionID).build(); } client.send(body); }
[ "protected", "void", "send", "(", "ComposableBody", "body", ")", "throws", "BOSHException", "{", "if", "(", "!", "connected", ")", "{", "throw", "new", "IllegalStateException", "(", "\"Not connected to a server!\"", ")", ";", "}", "if", "(", "body", "==", "null", ")", "{", "throw", "new", "NullPointerException", "(", "\"Body mustn't be null!\"", ")", ";", "}", "if", "(", "sessionID", "!=", "null", ")", "{", "body", "=", "body", ".", "rebuild", "(", ")", ".", "setAttribute", "(", "BodyQName", ".", "create", "(", "BOSH_URI", ",", "\"sid\"", ")", ",", "sessionID", ")", ".", "build", "(", ")", ";", "}", "client", ".", "send", "(", "body", ")", ";", "}" ]
Send a HTTP request to the connection manager with the provided body element. @param body the body which will be sent. @throws BOSHException
[ "Send", "a", "HTTP", "request", "to", "the", "connection", "manager", "with", "the", "provided", "body", "element", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java#L304-L316
26,579
igniterealtime/Smack
smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java
XMPPBOSHConnection.initDebugger
@Override protected void initDebugger() { // TODO: Maybe we want to extend the SmackDebugger for simplification // and a performance boost. // Initialize a empty writer which discards all data. writer = new Writer() { @Override public void write(char[] cbuf, int off, int len) { /* ignore */ } @Override public void close() { /* ignore */ } @Override public void flush() { /* ignore */ } }; // Initialize a pipe for received raw data. try { readerPipe = new PipedWriter(); reader = new PipedReader(readerPipe); } catch (IOException e) { // Ignore } // Call the method from the parent class which initializes the debugger. super.initDebugger(); // Add listeners for the received and sent raw data. client.addBOSHClientResponseListener(new BOSHClientResponseListener() { @Override public void responseReceived(BOSHMessageEvent event) { if (event.getBody() != null) { try { readerPipe.write(event.getBody().toXML()); readerPipe.flush(); } catch (Exception e) { // Ignore } } } }); client.addBOSHClientRequestListener(new BOSHClientRequestListener() { @Override public void requestSent(BOSHMessageEvent event) { if (event.getBody() != null) { try { writer.write(event.getBody().toXML()); } catch (Exception e) { // Ignore } } } }); // Create and start a thread which discards all read data. readerConsumer = new Thread() { private Thread thread = this; private int bufferLength = 1024; @Override public void run() { try { char[] cbuf = new char[bufferLength]; while (readerConsumer == thread && !done) { reader.read(cbuf, 0, bufferLength); } } catch (IOException e) { // Ignore } } }; readerConsumer.setDaemon(true); readerConsumer.start(); }
java
@Override protected void initDebugger() { // TODO: Maybe we want to extend the SmackDebugger for simplification // and a performance boost. // Initialize a empty writer which discards all data. writer = new Writer() { @Override public void write(char[] cbuf, int off, int len) { /* ignore */ } @Override public void close() { /* ignore */ } @Override public void flush() { /* ignore */ } }; // Initialize a pipe for received raw data. try { readerPipe = new PipedWriter(); reader = new PipedReader(readerPipe); } catch (IOException e) { // Ignore } // Call the method from the parent class which initializes the debugger. super.initDebugger(); // Add listeners for the received and sent raw data. client.addBOSHClientResponseListener(new BOSHClientResponseListener() { @Override public void responseReceived(BOSHMessageEvent event) { if (event.getBody() != null) { try { readerPipe.write(event.getBody().toXML()); readerPipe.flush(); } catch (Exception e) { // Ignore } } } }); client.addBOSHClientRequestListener(new BOSHClientRequestListener() { @Override public void requestSent(BOSHMessageEvent event) { if (event.getBody() != null) { try { writer.write(event.getBody().toXML()); } catch (Exception e) { // Ignore } } } }); // Create and start a thread which discards all read data. readerConsumer = new Thread() { private Thread thread = this; private int bufferLength = 1024; @Override public void run() { try { char[] cbuf = new char[bufferLength]; while (readerConsumer == thread && !done) { reader.read(cbuf, 0, bufferLength); } } catch (IOException e) { // Ignore } } }; readerConsumer.setDaemon(true); readerConsumer.start(); }
[ "@", "Override", "protected", "void", "initDebugger", "(", ")", "{", "// TODO: Maybe we want to extend the SmackDebugger for simplification", "// and a performance boost.", "// Initialize a empty writer which discards all data.", "writer", "=", "new", "Writer", "(", ")", "{", "@", "Override", "public", "void", "write", "(", "char", "[", "]", "cbuf", ",", "int", "off", ",", "int", "len", ")", "{", "/* ignore */", "}", "@", "Override", "public", "void", "close", "(", ")", "{", "/* ignore */", "}", "@", "Override", "public", "void", "flush", "(", ")", "{", "/* ignore */", "}", "}", ";", "// Initialize a pipe for received raw data.", "try", "{", "readerPipe", "=", "new", "PipedWriter", "(", ")", ";", "reader", "=", "new", "PipedReader", "(", "readerPipe", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// Ignore", "}", "// Call the method from the parent class which initializes the debugger.", "super", ".", "initDebugger", "(", ")", ";", "// Add listeners for the received and sent raw data.", "client", ".", "addBOSHClientResponseListener", "(", "new", "BOSHClientResponseListener", "(", ")", "{", "@", "Override", "public", "void", "responseReceived", "(", "BOSHMessageEvent", "event", ")", "{", "if", "(", "event", ".", "getBody", "(", ")", "!=", "null", ")", "{", "try", "{", "readerPipe", ".", "write", "(", "event", ".", "getBody", "(", ")", ".", "toXML", "(", ")", ")", ";", "readerPipe", ".", "flush", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Ignore", "}", "}", "}", "}", ")", ";", "client", ".", "addBOSHClientRequestListener", "(", "new", "BOSHClientRequestListener", "(", ")", "{", "@", "Override", "public", "void", "requestSent", "(", "BOSHMessageEvent", "event", ")", "{", "if", "(", "event", ".", "getBody", "(", ")", "!=", "null", ")", "{", "try", "{", "writer", ".", "write", "(", "event", ".", "getBody", "(", ")", ".", "toXML", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "// Ignore", "}", "}", "}", "}", ")", ";", "// Create and start a thread which discards all read data.", "readerConsumer", "=", "new", "Thread", "(", ")", "{", "private", "Thread", "thread", "=", "this", ";", "private", "int", "bufferLength", "=", "1024", ";", "@", "Override", "public", "void", "run", "(", ")", "{", "try", "{", "char", "[", "]", "cbuf", "=", "new", "char", "[", "bufferLength", "]", ";", "while", "(", "readerConsumer", "==", "thread", "&&", "!", "done", ")", "{", "reader", ".", "read", "(", "cbuf", ",", "0", ",", "bufferLength", ")", ";", "}", "}", "catch", "(", "IOException", "e", ")", "{", "// Ignore", "}", "}", "}", ";", "readerConsumer", ".", "setDaemon", "(", "true", ")", ";", "readerConsumer", ".", "start", "(", ")", ";", "}" ]
Initialize the SmackDebugger which allows to log and debug XML traffic.
[ "Initialize", "the", "SmackDebugger", "which", "allows", "to", "log", "and", "debug", "XML", "traffic", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-bosh/src/main/java/org/jivesoftware/smack/bosh/XMPPBOSHConnection.java#L321-L399
26,580
igniterealtime/Smack
smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleTransport.java
JingleTransport.toXML
@Override public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { StringBuilder buf = new StringBuilder(); buf.append('<').append(getElementName()).append(" xmlns=\""); buf.append(getNamespace()).append("\" "); synchronized (candidates) { if (getCandidatesCount() > 0) { buf.append('>'); Iterator<JingleTransportCandidate> iter = getCandidates(); while (iter.hasNext()) { JingleTransportCandidate candidate = iter.next(); buf.append(candidate.toXML()); } buf.append("</").append(getElementName()).append('>'); } else { buf.append("/>"); } } return buf.toString(); }
java
@Override public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) { StringBuilder buf = new StringBuilder(); buf.append('<').append(getElementName()).append(" xmlns=\""); buf.append(getNamespace()).append("\" "); synchronized (candidates) { if (getCandidatesCount() > 0) { buf.append('>'); Iterator<JingleTransportCandidate> iter = getCandidates(); while (iter.hasNext()) { JingleTransportCandidate candidate = iter.next(); buf.append(candidate.toXML()); } buf.append("</").append(getElementName()).append('>'); } else { buf.append("/>"); } } return buf.toString(); }
[ "@", "Override", "public", "String", "toXML", "(", "org", ".", "jivesoftware", ".", "smack", ".", "packet", ".", "XmlEnvironment", "enclosingNamespace", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "buf", ".", "append", "(", "'", "'", ")", ".", "append", "(", "getElementName", "(", ")", ")", ".", "append", "(", "\" xmlns=\\\"\"", ")", ";", "buf", ".", "append", "(", "getNamespace", "(", ")", ")", ".", "append", "(", "\"\\\" \"", ")", ";", "synchronized", "(", "candidates", ")", "{", "if", "(", "getCandidatesCount", "(", ")", ">", "0", ")", "{", "buf", ".", "append", "(", "'", "'", ")", ";", "Iterator", "<", "JingleTransportCandidate", ">", "iter", "=", "getCandidates", "(", ")", ";", "while", "(", "iter", ".", "hasNext", "(", ")", ")", "{", "JingleTransportCandidate", "candidate", "=", "iter", ".", "next", "(", ")", ";", "buf", ".", "append", "(", "candidate", ".", "toXML", "(", ")", ")", ";", "}", "buf", ".", "append", "(", "\"</\"", ")", ".", "append", "(", "getElementName", "(", ")", ")", ".", "append", "(", "'", "'", ")", ";", "}", "else", "{", "buf", ".", "append", "(", "\"/>\"", ")", ";", "}", "}", "return", "buf", ".", "toString", "(", ")", ";", "}" ]
Return the XML representation for this element.
[ "Return", "the", "XML", "representation", "for", "this", "element", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleTransport.java#L154-L177
26,581
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.setRosterStore
public boolean setRosterStore(RosterStore rosterStore) { this.rosterStore = rosterStore; try { reload(); } catch (InterruptedException | NotLoggedInException | NotConnectedException e) { LOGGER.log(Level.FINER, "Could not reload roster", e); return false; } return true; }
java
public boolean setRosterStore(RosterStore rosterStore) { this.rosterStore = rosterStore; try { reload(); } catch (InterruptedException | NotLoggedInException | NotConnectedException e) { LOGGER.log(Level.FINER, "Could not reload roster", e); return false; } return true; }
[ "public", "boolean", "setRosterStore", "(", "RosterStore", "rosterStore", ")", "{", "this", ".", "rosterStore", "=", "rosterStore", ";", "try", "{", "reload", "(", ")", ";", "}", "catch", "(", "InterruptedException", "|", "NotLoggedInException", "|", "NotConnectedException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "FINER", ",", "\"Could not reload roster\"", ",", "e", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Set the roster store, may cause a roster reload. @param rosterStore @return true if the roster reload was initiated, false otherwise. @since 4.1
[ "Set", "the", "roster", "store", "may", "cause", "a", "roster", "reload", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L494-L504
26,582
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.createItemAndRequestSubscription
public void createItemAndRequestSubscription(BareJid jid, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { createItem(jid, name, groups); sendSubscriptionRequest(jid); }
java
public void createItemAndRequestSubscription(BareJid jid, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { createItem(jid, name, groups); sendSubscriptionRequest(jid); }
[ "public", "void", "createItemAndRequestSubscription", "(", "BareJid", "jid", ",", "String", "name", ",", "String", "[", "]", "groups", ")", "throws", "NotLoggedInException", ",", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", "{", "createItem", "(", "jid", ",", "name", ",", "groups", ")", ";", "sendSubscriptionRequest", "(", "jid", ")", ";", "}" ]
Creates a new roster entry and presence subscription. The server will asynchronously update the roster with the subscription status. @param jid the XMPP address of the contact (e.g. johndoe@jabber.org) @param name the nickname of the user. @param groups the list of group names the entry will belong to, or <tt>null</tt> if the the roster entry won't belong to a group. @throws NoResponseException if there was no response from the server. @throws XMPPErrorException if an XMPP exception occurs. @throws NotLoggedInException If not logged in. @throws NotConnectedException @throws InterruptedException @since 4.4.0
[ "Creates", "a", "new", "roster", "entry", "and", "presence", "subscription", ".", "The", "server", "will", "asynchronously", "update", "the", "roster", "with", "the", "subscription", "status", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L707-L711
26,583
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.preApproveAndCreateEntry
public void preApproveAndCreateEntry(BareJid user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, FeatureNotSupportedException { preApprove(user); createItemAndRequestSubscription(user, name, groups); }
java
public void preApproveAndCreateEntry(BareJid user, String name, String[] groups) throws NotLoggedInException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, FeatureNotSupportedException { preApprove(user); createItemAndRequestSubscription(user, name, groups); }
[ "public", "void", "preApproveAndCreateEntry", "(", "BareJid", "user", ",", "String", "name", ",", "String", "[", "]", "groups", ")", "throws", "NotLoggedInException", ",", "NoResponseException", ",", "XMPPErrorException", ",", "NotConnectedException", ",", "InterruptedException", ",", "FeatureNotSupportedException", "{", "preApprove", "(", "user", ")", ";", "createItemAndRequestSubscription", "(", "user", ",", "name", ",", "groups", ")", ";", "}" ]
Creates a new pre-approved roster entry and presence subscription. The server will asynchronously update the roster with the subscription status. @param user the user. (e.g. johndoe@jabber.org) @param name the nickname of the user. @param groups the list of group names the entry will belong to, or <tt>null</tt> if the the roster entry won't belong to a group. @throws NoResponseException if there was no response from the server. @throws XMPPErrorException if an XMPP exception occurs. @throws NotLoggedInException if not logged in. @throws NotConnectedException @throws InterruptedException @throws FeatureNotSupportedException if pre-approving is not supported. @since 4.2
[ "Creates", "a", "new", "pre", "-", "approved", "roster", "entry", "and", "presence", "subscription", ".", "The", "server", "will", "asynchronously", "update", "the", "roster", "with", "the", "subscription", "status", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L729-L732
26,584
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.preApprove
public void preApprove(BareJid user) throws NotLoggedInException, NotConnectedException, InterruptedException, FeatureNotSupportedException { final XMPPConnection connection = connection(); if (!isSubscriptionPreApprovalSupported()) { throw new FeatureNotSupportedException("Pre-approving"); } Presence presencePacket = new Presence(Presence.Type.subscribed); presencePacket.setTo(user); connection.sendStanza(presencePacket); }
java
public void preApprove(BareJid user) throws NotLoggedInException, NotConnectedException, InterruptedException, FeatureNotSupportedException { final XMPPConnection connection = connection(); if (!isSubscriptionPreApprovalSupported()) { throw new FeatureNotSupportedException("Pre-approving"); } Presence presencePacket = new Presence(Presence.Type.subscribed); presencePacket.setTo(user); connection.sendStanza(presencePacket); }
[ "public", "void", "preApprove", "(", "BareJid", "user", ")", "throws", "NotLoggedInException", ",", "NotConnectedException", ",", "InterruptedException", ",", "FeatureNotSupportedException", "{", "final", "XMPPConnection", "connection", "=", "connection", "(", ")", ";", "if", "(", "!", "isSubscriptionPreApprovalSupported", "(", ")", ")", "{", "throw", "new", "FeatureNotSupportedException", "(", "\"Pre-approving\"", ")", ";", "}", "Presence", "presencePacket", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "subscribed", ")", ";", "presencePacket", ".", "setTo", "(", "user", ")", ";", "connection", ".", "sendStanza", "(", "presencePacket", ")", ";", "}" ]
Pre-approve user presence subscription. @param user the user. (e.g. johndoe@jabber.org) @throws NotLoggedInException if not logged in. @throws NotConnectedException @throws InterruptedException @throws FeatureNotSupportedException if pre-approving is not supported. @since 4.2
[ "Pre", "-", "approve", "user", "presence", "subscription", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L744-L753
26,585
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.isSubscriptionPreApprovalSupported
public boolean isSubscriptionPreApprovalSupported() throws NotLoggedInException { final XMPPConnection connection = getAuthenticatedConnectionOrThrow(); return connection.hasFeature(SubscriptionPreApproval.ELEMENT, SubscriptionPreApproval.NAMESPACE); }
java
public boolean isSubscriptionPreApprovalSupported() throws NotLoggedInException { final XMPPConnection connection = getAuthenticatedConnectionOrThrow(); return connection.hasFeature(SubscriptionPreApproval.ELEMENT, SubscriptionPreApproval.NAMESPACE); }
[ "public", "boolean", "isSubscriptionPreApprovalSupported", "(", ")", "throws", "NotLoggedInException", "{", "final", "XMPPConnection", "connection", "=", "getAuthenticatedConnectionOrThrow", "(", ")", ";", "return", "connection", ".", "hasFeature", "(", "SubscriptionPreApproval", ".", "ELEMENT", ",", "SubscriptionPreApproval", ".", "NAMESPACE", ")", ";", "}" ]
Check for subscription pre-approval support. @return true if subscription pre-approval is supported by the server. @throws NotLoggedInException if not logged in. @since 4.2
[ "Check", "for", "subscription", "pre", "-", "approval", "support", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L762-L765
26,586
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.removeSubscribeListener
public boolean removeSubscribeListener(SubscribeListener subscribeListener) { boolean removed = subscribeListeners.remove(subscribeListener); if (removed && subscribeListeners.isEmpty()) { setSubscriptionMode(previousSubscriptionMode); } return removed; }
java
public boolean removeSubscribeListener(SubscribeListener subscribeListener) { boolean removed = subscribeListeners.remove(subscribeListener); if (removed && subscribeListeners.isEmpty()) { setSubscriptionMode(previousSubscriptionMode); } return removed; }
[ "public", "boolean", "removeSubscribeListener", "(", "SubscribeListener", "subscribeListener", ")", "{", "boolean", "removed", "=", "subscribeListeners", ".", "remove", "(", "subscribeListener", ")", ";", "if", "(", "removed", "&&", "subscribeListeners", ".", "isEmpty", "(", ")", ")", "{", "setSubscriptionMode", "(", "previousSubscriptionMode", ")", ";", "}", "return", "removed", ";", "}" ]
Remove a subscribe listener. Also restores the previous subscription mode state, if the last listener got removed. @param subscribeListener the subscribe listener to remove. @return <code>true</code> if the listener registered and got removed. @since 4.2
[ "Remove", "a", "subscribe", "listener", ".", "Also", "restores", "the", "previous", "subscription", "mode", "state", "if", "the", "last", "listener", "got", "removed", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L803-L809
26,587
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.getEntries
public Set<RosterEntry> getEntries() { Set<RosterEntry> allEntries; synchronized (rosterListenersAndEntriesLock) { allEntries = new HashSet<>(entries.size()); for (RosterEntry entry : entries.values()) { allEntries.add(entry); } } return allEntries; }
java
public Set<RosterEntry> getEntries() { Set<RosterEntry> allEntries; synchronized (rosterListenersAndEntriesLock) { allEntries = new HashSet<>(entries.size()); for (RosterEntry entry : entries.values()) { allEntries.add(entry); } } return allEntries; }
[ "public", "Set", "<", "RosterEntry", ">", "getEntries", "(", ")", "{", "Set", "<", "RosterEntry", ">", "allEntries", ";", "synchronized", "(", "rosterListenersAndEntriesLock", ")", "{", "allEntries", "=", "new", "HashSet", "<>", "(", "entries", ".", "size", "(", ")", ")", ";", "for", "(", "RosterEntry", "entry", ":", "entries", ".", "values", "(", ")", ")", "{", "allEntries", ".", "add", "(", "entry", ")", ";", "}", "}", "return", "allEntries", ";", "}" ]
Returns a set of all entries in the roster, including entries that don't belong to any groups. @return all entries in the roster.
[ "Returns", "a", "set", "of", "all", "entries", "in", "the", "roster", "including", "entries", "that", "don", "t", "belong", "to", "any", "groups", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L883-L892
26,588
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.getPresenceResource
public Presence getPresenceResource(FullJid userWithResource) { BareJid key = userWithResource.asBareJid(); Resourcepart resource = userWithResource.getResourcepart(); Map<Resourcepart, Presence> userPresences = getPresencesInternal(key); if (userPresences == null) { Presence presence = new Presence(Presence.Type.unavailable); presence.setFrom(userWithResource); return presence; } else { Presence presence = userPresences.get(resource); if (presence == null) { presence = new Presence(Presence.Type.unavailable); presence.setFrom(userWithResource); return presence; } else { return presence.clone(); } } }
java
public Presence getPresenceResource(FullJid userWithResource) { BareJid key = userWithResource.asBareJid(); Resourcepart resource = userWithResource.getResourcepart(); Map<Resourcepart, Presence> userPresences = getPresencesInternal(key); if (userPresences == null) { Presence presence = new Presence(Presence.Type.unavailable); presence.setFrom(userWithResource); return presence; } else { Presence presence = userPresences.get(resource); if (presence == null) { presence = new Presence(Presence.Type.unavailable); presence.setFrom(userWithResource); return presence; } else { return presence.clone(); } } }
[ "public", "Presence", "getPresenceResource", "(", "FullJid", "userWithResource", ")", "{", "BareJid", "key", "=", "userWithResource", ".", "asBareJid", "(", ")", ";", "Resourcepart", "resource", "=", "userWithResource", ".", "getResourcepart", "(", ")", ";", "Map", "<", "Resourcepart", ",", "Presence", ">", "userPresences", "=", "getPresencesInternal", "(", "key", ")", ";", "if", "(", "userPresences", "==", "null", ")", "{", "Presence", "presence", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "presence", ".", "setFrom", "(", "userWithResource", ")", ";", "return", "presence", ";", "}", "else", "{", "Presence", "presence", "=", "userPresences", ".", "get", "(", "resource", ")", ";", "if", "(", "presence", "==", "null", ")", "{", "presence", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "presence", ".", "setFrom", "(", "userWithResource", ")", ";", "return", "presence", ";", "}", "else", "{", "return", "presence", ".", "clone", "(", ")", ";", "}", "}", "}" ]
Returns the presence info for a particular user's resource, or unavailable presence if the user is offline or if no presence information is available, such as when you are not subscribed to the user's presence updates. @param userWithResource a fully qualified XMPP ID including a resource (user@domain/resource). @return the user's current presence, or unavailable presence if the user is offline or if no presence information is available.
[ "Returns", "the", "presence", "info", "for", "a", "particular", "user", "s", "resource", "or", "unavailable", "presence", "if", "the", "user", "is", "offline", "or", "if", "no", "presence", "information", "is", "available", "such", "as", "when", "you", "are", "not", "subscribed", "to", "the", "user", "s", "presence", "updates", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1065-L1085
26,589
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.getAllPresences
public List<Presence> getAllPresences(BareJid bareJid) { Map<Resourcepart, Presence> userPresences = getPresencesInternal(bareJid); List<Presence> res; if (userPresences == null) { // Create an unavailable presence if none was found Presence unavailable = new Presence(Presence.Type.unavailable); unavailable.setFrom(bareJid); res = new ArrayList<>(Arrays.asList(unavailable)); } else { res = new ArrayList<>(userPresences.values().size()); for (Presence presence : userPresences.values()) { res.add(presence.clone()); } } return res; }
java
public List<Presence> getAllPresences(BareJid bareJid) { Map<Resourcepart, Presence> userPresences = getPresencesInternal(bareJid); List<Presence> res; if (userPresences == null) { // Create an unavailable presence if none was found Presence unavailable = new Presence(Presence.Type.unavailable); unavailable.setFrom(bareJid); res = new ArrayList<>(Arrays.asList(unavailable)); } else { res = new ArrayList<>(userPresences.values().size()); for (Presence presence : userPresences.values()) { res.add(presence.clone()); } } return res; }
[ "public", "List", "<", "Presence", ">", "getAllPresences", "(", "BareJid", "bareJid", ")", "{", "Map", "<", "Resourcepart", ",", "Presence", ">", "userPresences", "=", "getPresencesInternal", "(", "bareJid", ")", ";", "List", "<", "Presence", ">", "res", ";", "if", "(", "userPresences", "==", "null", ")", "{", "// Create an unavailable presence if none was found", "Presence", "unavailable", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "unavailable", ".", "setFrom", "(", "bareJid", ")", ";", "res", "=", "new", "ArrayList", "<>", "(", "Arrays", ".", "asList", "(", "unavailable", ")", ")", ";", "}", "else", "{", "res", "=", "new", "ArrayList", "<>", "(", "userPresences", ".", "values", "(", ")", ".", "size", "(", ")", ")", ";", "for", "(", "Presence", "presence", ":", "userPresences", ".", "values", "(", ")", ")", "{", "res", ".", "add", "(", "presence", ".", "clone", "(", ")", ")", ";", "}", "}", "return", "res", ";", "}" ]
Returns a List of Presence objects for all of a user's current presences if no presence information is available, such as when you are not subscribed to the user's presence updates. @param bareJid an XMPP ID, e.g. jdoe@example.com. @return a List of Presence objects for all the user's current presences, or an unavailable presence if no presence information is available.
[ "Returns", "a", "List", "of", "Presence", "objects", "for", "all", "of", "a", "user", "s", "current", "presences", "if", "no", "presence", "information", "is", "available", "such", "as", "when", "you", "are", "not", "subscribed", "to", "the", "user", "s", "presence", "updates", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1095-L1110
26,590
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.iAmSubscribedTo
public boolean iAmSubscribedTo(Jid jid) { if (jid == null) { return false; } BareJid bareJid = jid.asBareJid(); RosterEntry entry = getEntry(bareJid); if (entry == null) { return false; } return entry.canSeeHisPresence(); }
java
public boolean iAmSubscribedTo(Jid jid) { if (jid == null) { return false; } BareJid bareJid = jid.asBareJid(); RosterEntry entry = getEntry(bareJid); if (entry == null) { return false; } return entry.canSeeHisPresence(); }
[ "public", "boolean", "iAmSubscribedTo", "(", "Jid", "jid", ")", "{", "if", "(", "jid", "==", "null", ")", "{", "return", "false", ";", "}", "BareJid", "bareJid", "=", "jid", ".", "asBareJid", "(", ")", ";", "RosterEntry", "entry", "=", "getEntry", "(", "bareJid", ")", ";", "if", "(", "entry", "==", "null", ")", "{", "return", "false", ";", "}", "return", "entry", ".", "canSeeHisPresence", "(", ")", ";", "}" ]
Check if the XMPP entity this roster belongs to is subscribed to the presence of the given JID. @param jid the jid to check. @return <code>true</code> if we are subscribed to the presence of the given jid. @since 4.2
[ "Check", "if", "the", "XMPP", "entity", "this", "roster", "belongs", "to", "is", "subscribed", "to", "the", "presence", "of", "the", "given", "JID", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1213-L1223
26,591
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.setOfflinePresences
private void setOfflinePresences() { Presence packetUnavailable; outerloop: for (Jid user : presenceMap.keySet()) { Map<Resourcepart, Presence> resources = presenceMap.get(user); if (resources != null) { for (Resourcepart resource : resources.keySet()) { packetUnavailable = new Presence(Presence.Type.unavailable); EntityBareJid bareUserJid = user.asEntityBareJidIfPossible(); if (bareUserJid == null) { LOGGER.warning("Can not transform user JID to bare JID: '" + user + "'"); continue; } packetUnavailable.setFrom(JidCreate.fullFrom(bareUserJid, resource)); try { presencePacketListener.processStanza(packetUnavailable); } catch (NotConnectedException e) { throw new IllegalStateException( "presencePacketListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable", e); } catch (InterruptedException e) { break outerloop; } } } } }
java
private void setOfflinePresences() { Presence packetUnavailable; outerloop: for (Jid user : presenceMap.keySet()) { Map<Resourcepart, Presence> resources = presenceMap.get(user); if (resources != null) { for (Resourcepart resource : resources.keySet()) { packetUnavailable = new Presence(Presence.Type.unavailable); EntityBareJid bareUserJid = user.asEntityBareJidIfPossible(); if (bareUserJid == null) { LOGGER.warning("Can not transform user JID to bare JID: '" + user + "'"); continue; } packetUnavailable.setFrom(JidCreate.fullFrom(bareUserJid, resource)); try { presencePacketListener.processStanza(packetUnavailable); } catch (NotConnectedException e) { throw new IllegalStateException( "presencePacketListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable", e); } catch (InterruptedException e) { break outerloop; } } } } }
[ "private", "void", "setOfflinePresences", "(", ")", "{", "Presence", "packetUnavailable", ";", "outerloop", ":", "for", "(", "Jid", "user", ":", "presenceMap", ".", "keySet", "(", ")", ")", "{", "Map", "<", "Resourcepart", ",", "Presence", ">", "resources", "=", "presenceMap", ".", "get", "(", "user", ")", ";", "if", "(", "resources", "!=", "null", ")", "{", "for", "(", "Resourcepart", "resource", ":", "resources", ".", "keySet", "(", ")", ")", "{", "packetUnavailable", "=", "new", "Presence", "(", "Presence", ".", "Type", ".", "unavailable", ")", ";", "EntityBareJid", "bareUserJid", "=", "user", ".", "asEntityBareJidIfPossible", "(", ")", ";", "if", "(", "bareUserJid", "==", "null", ")", "{", "LOGGER", ".", "warning", "(", "\"Can not transform user JID to bare JID: '\"", "+", "user", "+", "\"'\"", ")", ";", "continue", ";", "}", "packetUnavailable", ".", "setFrom", "(", "JidCreate", ".", "fullFrom", "(", "bareUserJid", ",", "resource", ")", ")", ";", "try", "{", "presencePacketListener", ".", "processStanza", "(", "packetUnavailable", ")", ";", "}", "catch", "(", "NotConnectedException", "e", ")", "{", "throw", "new", "IllegalStateException", "(", "\"presencePacketListener should never throw a NotConnectedException when processStanza is called with a presence of type unavailable\"", ",", "e", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "break", "outerloop", ";", "}", "}", "}", "}", "}" ]
Changes the presence of available contacts offline by simulating an unavailable presence sent from the server.
[ "Changes", "the", "presence", "of", "available", "contacts", "offline", "by", "simulating", "an", "unavailable", "presence", "sent", "from", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1268-L1295
26,592
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.fireRosterPresenceEvent
private void fireRosterPresenceEvent(final Presence presence) { synchronized (rosterListenersAndEntriesLock) { for (RosterListener listener : rosterListeners) { listener.presenceChanged(presence); } } }
java
private void fireRosterPresenceEvent(final Presence presence) { synchronized (rosterListenersAndEntriesLock) { for (RosterListener listener : rosterListeners) { listener.presenceChanged(presence); } } }
[ "private", "void", "fireRosterPresenceEvent", "(", "final", "Presence", "presence", ")", "{", "synchronized", "(", "rosterListenersAndEntriesLock", ")", "{", "for", "(", "RosterListener", "listener", ":", "rosterListeners", ")", "{", "listener", ".", "presenceChanged", "(", "presence", ")", ";", "}", "}", "}" ]
Fires roster presence changed event to roster listeners. @param presence the presence change.
[ "Fires", "roster", "presence", "changed", "event", "to", "roster", "listeners", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1338-L1344
26,593
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.removeEmptyGroups
private void removeEmptyGroups() { // We have to do this because RosterGroup.removeEntry removes the entry immediately // (locally) and the group could remain empty. // TODO Check the performance/logic for rosters with large number of groups for (RosterGroup group : getGroups()) { if (group.getEntryCount() == 0) { groups.remove(group.getName()); } } }
java
private void removeEmptyGroups() { // We have to do this because RosterGroup.removeEntry removes the entry immediately // (locally) and the group could remain empty. // TODO Check the performance/logic for rosters with large number of groups for (RosterGroup group : getGroups()) { if (group.getEntryCount() == 0) { groups.remove(group.getName()); } } }
[ "private", "void", "removeEmptyGroups", "(", ")", "{", "// We have to do this because RosterGroup.removeEntry removes the entry immediately", "// (locally) and the group could remain empty.", "// TODO Check the performance/logic for rosters with large number of groups", "for", "(", "RosterGroup", "group", ":", "getGroups", "(", ")", ")", "{", "if", "(", "group", ".", "getEntryCount", "(", ")", "==", "0", ")", "{", "groups", ".", "remove", "(", "group", ".", "getName", "(", ")", ")", ";", "}", "}", "}" ]
Removes all the groups with no entries. This is used by {@link RosterPushListener} and {@link RosterResultListener} to cleanup groups after removing contacts.
[ "Removes", "all", "the", "groups", "with", "no", "entries", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1432-L1441
26,594
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.move
private static void move(BareJid entity, Map<BareJid, Map<Resourcepart, Presence>> from, Map<BareJid, Map<Resourcepart, Presence>> to) { Map<Resourcepart, Presence> presences = from.remove(entity); if (presences != null && !presences.isEmpty()) { to.put(entity, presences); } }
java
private static void move(BareJid entity, Map<BareJid, Map<Resourcepart, Presence>> from, Map<BareJid, Map<Resourcepart, Presence>> to) { Map<Resourcepart, Presence> presences = from.remove(entity); if (presences != null && !presences.isEmpty()) { to.put(entity, presences); } }
[ "private", "static", "void", "move", "(", "BareJid", "entity", ",", "Map", "<", "BareJid", ",", "Map", "<", "Resourcepart", ",", "Presence", ">", ">", "from", ",", "Map", "<", "BareJid", ",", "Map", "<", "Resourcepart", ",", "Presence", ">", ">", "to", ")", "{", "Map", "<", "Resourcepart", ",", "Presence", ">", "presences", "=", "from", ".", "remove", "(", "entity", ")", ";", "if", "(", "presences", "!=", "null", "&&", "!", "presences", ".", "isEmpty", "(", ")", ")", "{", "to", ".", "put", "(", "entity", ",", "presences", ")", ";", "}", "}" ]
Move presences from 'entity' from one presence map to another. @param entity the entity @param from the map to move presences from @param to the map to move presences to
[ "Move", "presences", "from", "entity", "from", "one", "presence", "map", "to", "another", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1450-L1455
26,595
igniterealtime/Smack
smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java
Roster.hasValidSubscriptionType
private static boolean hasValidSubscriptionType(RosterPacket.Item item) { switch (item.getItemType()) { case none: case from: case to: case both: return true; default: return false; } }
java
private static boolean hasValidSubscriptionType(RosterPacket.Item item) { switch (item.getItemType()) { case none: case from: case to: case both: return true; default: return false; } }
[ "private", "static", "boolean", "hasValidSubscriptionType", "(", "RosterPacket", ".", "Item", "item", ")", "{", "switch", "(", "item", ".", "getItemType", "(", ")", ")", "{", "case", "none", ":", "case", "from", ":", "case", "to", ":", "case", "both", ":", "return", "true", ";", "default", ":", "return", "false", ";", "}", "}" ]
Ignore ItemTypes as of RFC 6121, 2.1.2.5. This is used by {@link RosterPushListener} and {@link RosterResultListener}.
[ "Ignore", "ItemTypes", "as", "of", "RFC", "6121", "2", ".", "1", ".", "2", ".", "5", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/Roster.java#L1462-L1472
26,596
igniterealtime/Smack
smack-core/src/main/java/org/jivesoftware/smack/util/ObservableReader.java
ObservableReader.addReaderListener
public void addReaderListener(ReaderListener readerListener) { if (readerListener == null) { return; } synchronized (listeners) { if (!listeners.contains(readerListener)) { listeners.add(readerListener); } } }
java
public void addReaderListener(ReaderListener readerListener) { if (readerListener == null) { return; } synchronized (listeners) { if (!listeners.contains(readerListener)) { listeners.add(readerListener); } } }
[ "public", "void", "addReaderListener", "(", "ReaderListener", "readerListener", ")", "{", "if", "(", "readerListener", "==", "null", ")", "{", "return", ";", "}", "synchronized", "(", "listeners", ")", "{", "if", "(", "!", "listeners", ".", "contains", "(", "readerListener", ")", ")", "{", "listeners", ".", "add", "(", "readerListener", ")", ";", "}", "}", "}" ]
Adds a reader listener to this reader that will be notified when new strings are read. @param readerListener a reader listener.
[ "Adds", "a", "reader", "listener", "to", "this", "reader", "that", "will", "be", "notified", "when", "new", "strings", "are", "read", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/ObservableReader.java#L104-L113
26,597
igniterealtime/Smack
smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java
XMPPTCPConnection.shutdown
@Override protected void shutdown() { if (isSmEnabled()) { try { // Try to send a last SM Acknowledgement. Most servers won't find this information helpful, as the SM // state is dropped after a clean disconnect anyways. OTOH it doesn't hurt much either. sendSmAcknowledgementInternal(); } catch (InterruptedException | NotConnectedException e) { LOGGER.log(Level.FINE, "Can not send final SM ack as connection is not connected", e); } } shutdown(false); }
java
@Override protected void shutdown() { if (isSmEnabled()) { try { // Try to send a last SM Acknowledgement. Most servers won't find this information helpful, as the SM // state is dropped after a clean disconnect anyways. OTOH it doesn't hurt much either. sendSmAcknowledgementInternal(); } catch (InterruptedException | NotConnectedException e) { LOGGER.log(Level.FINE, "Can not send final SM ack as connection is not connected", e); } } shutdown(false); }
[ "@", "Override", "protected", "void", "shutdown", "(", ")", "{", "if", "(", "isSmEnabled", "(", ")", ")", "{", "try", "{", "// Try to send a last SM Acknowledgement. Most servers won't find this information helpful, as the SM", "// state is dropped after a clean disconnect anyways. OTOH it doesn't hurt much either.", "sendSmAcknowledgementInternal", "(", ")", ";", "}", "catch", "(", "InterruptedException", "|", "NotConnectedException", "e", ")", "{", "LOGGER", ".", "log", "(", "Level", ".", "FINE", ",", "\"Can not send final SM ack as connection is not connected\"", ",", "e", ")", ";", "}", "}", "shutdown", "(", "false", ")", ";", "}" ]
Shuts the current connection down. After this method returns, the connection must be ready for re-use by connect.
[ "Shuts", "the", "current", "connection", "down", ".", "After", "this", "method", "returns", "the", "connection", "must", "be", "ready", "for", "re", "-", "use", "by", "connect", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java#L464-L476
26,598
igniterealtime/Smack
smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java
XMPPTCPConnection.initConnection
private void initConnection() throws IOException, InterruptedException { compressionHandler = null; // Set the reader and writer instance variables initReaderAndWriter(); int availableReaderWriterSemaphorePermits = readerWriterSemaphore.availablePermits(); if (availableReaderWriterSemaphorePermits < 2) { Object[] logObjects = new Object[] { this, availableReaderWriterSemaphorePermits, }; LOGGER.log(Level.FINE, "Not every reader/writer threads where terminated on connection re-initializtion of {0}. Available permits {1}", logObjects); } readerWriterSemaphore.acquire(2); // Start the writer thread. This will open an XMPP stream to the server packetWriter.init(); // Start the reader thread. The startup() method will block until we // get an opening stream packet back from server packetReader.init(); }
java
private void initConnection() throws IOException, InterruptedException { compressionHandler = null; // Set the reader and writer instance variables initReaderAndWriter(); int availableReaderWriterSemaphorePermits = readerWriterSemaphore.availablePermits(); if (availableReaderWriterSemaphorePermits < 2) { Object[] logObjects = new Object[] { this, availableReaderWriterSemaphorePermits, }; LOGGER.log(Level.FINE, "Not every reader/writer threads where terminated on connection re-initializtion of {0}. Available permits {1}", logObjects); } readerWriterSemaphore.acquire(2); // Start the writer thread. This will open an XMPP stream to the server packetWriter.init(); // Start the reader thread. The startup() method will block until we // get an opening stream packet back from server packetReader.init(); }
[ "private", "void", "initConnection", "(", ")", "throws", "IOException", ",", "InterruptedException", "{", "compressionHandler", "=", "null", ";", "// Set the reader and writer instance variables", "initReaderAndWriter", "(", ")", ";", "int", "availableReaderWriterSemaphorePermits", "=", "readerWriterSemaphore", ".", "availablePermits", "(", ")", ";", "if", "(", "availableReaderWriterSemaphorePermits", "<", "2", ")", "{", "Object", "[", "]", "logObjects", "=", "new", "Object", "[", "]", "{", "this", ",", "availableReaderWriterSemaphorePermits", ",", "}", ";", "LOGGER", ".", "log", "(", "Level", ".", "FINE", ",", "\"Not every reader/writer threads where terminated on connection re-initializtion of {0}. Available permits {1}\"", ",", "logObjects", ")", ";", "}", "readerWriterSemaphore", ".", "acquire", "(", "2", ")", ";", "// Start the writer thread. This will open an XMPP stream to the server", "packetWriter", ".", "init", "(", ")", ";", "// Start the reader thread. The startup() method will block until we", "// get an opening stream packet back from server", "packetReader", ".", "init", "(", ")", ";", "}" ]
Initializes the connection by creating a stanza reader and writer and opening a XMPP stream to the server. @throws XMPPException if establishing a connection to the server fails. @throws SmackException if the server fails to respond back or if there is anther error. @throws IOException @throws InterruptedException
[ "Initializes", "the", "connection", "by", "creating", "a", "stanza", "reader", "and", "writer", "and", "opening", "a", "XMPP", "stream", "to", "the", "server", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java#L637-L657
26,599
igniterealtime/Smack
smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java
XMPPTCPConnection.proceedTLSReceived
@SuppressWarnings("LiteralClassName") private void proceedTLSReceived() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, NoSuchProviderException, UnrecoverableKeyException, KeyManagementException, SmackException { SmackTlsContext smackTlsContext = getSmackTlsContext(); Socket plain = socket; // Secure the plain connection socket = smackTlsContext.sslContext.getSocketFactory().createSocket(plain, config.getXMPPServiceDomain().toString(), plain.getPort(), true); final SSLSocket sslSocket = (SSLSocket) socket; // Immediately set the enabled SSL protocols and ciphers. See SMACK-712 why this is // important (at least on certain platforms) and it seems to be a good idea anyways to // prevent an accidental implicit handshake. TLSUtils.setEnabledProtocolsAndCiphers(sslSocket, config.getEnabledSSLProtocols(), config.getEnabledSSLCiphers()); // Initialize the reader and writer with the new secured version initReaderAndWriter(); // Proceed to do the handshake sslSocket.startHandshake(); if (smackTlsContext.daneVerifier != null) { smackTlsContext.daneVerifier.finish(sslSocket.getSession()); } final HostnameVerifier verifier = getConfiguration().getHostnameVerifier(); if (verifier == null) { throw new IllegalStateException("No HostnameVerifier set. Use connectionConfiguration.setHostnameVerifier() to configure."); } else if (!verifier.verify(getXMPPServiceDomain().toString(), sslSocket.getSession())) { throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getXMPPServiceDomain()); } // Set that TLS was successful secureSocket = sslSocket; }
java
@SuppressWarnings("LiteralClassName") private void proceedTLSReceived() throws NoSuchAlgorithmException, CertificateException, IOException, KeyStoreException, NoSuchProviderException, UnrecoverableKeyException, KeyManagementException, SmackException { SmackTlsContext smackTlsContext = getSmackTlsContext(); Socket plain = socket; // Secure the plain connection socket = smackTlsContext.sslContext.getSocketFactory().createSocket(plain, config.getXMPPServiceDomain().toString(), plain.getPort(), true); final SSLSocket sslSocket = (SSLSocket) socket; // Immediately set the enabled SSL protocols and ciphers. See SMACK-712 why this is // important (at least on certain platforms) and it seems to be a good idea anyways to // prevent an accidental implicit handshake. TLSUtils.setEnabledProtocolsAndCiphers(sslSocket, config.getEnabledSSLProtocols(), config.getEnabledSSLCiphers()); // Initialize the reader and writer with the new secured version initReaderAndWriter(); // Proceed to do the handshake sslSocket.startHandshake(); if (smackTlsContext.daneVerifier != null) { smackTlsContext.daneVerifier.finish(sslSocket.getSession()); } final HostnameVerifier verifier = getConfiguration().getHostnameVerifier(); if (verifier == null) { throw new IllegalStateException("No HostnameVerifier set. Use connectionConfiguration.setHostnameVerifier() to configure."); } else if (!verifier.verify(getXMPPServiceDomain().toString(), sslSocket.getSession())) { throw new CertificateException("Hostname verification of certificate failed. Certificate does not authenticate " + getXMPPServiceDomain()); } // Set that TLS was successful secureSocket = sslSocket; }
[ "@", "SuppressWarnings", "(", "\"LiteralClassName\"", ")", "private", "void", "proceedTLSReceived", "(", ")", "throws", "NoSuchAlgorithmException", ",", "CertificateException", ",", "IOException", ",", "KeyStoreException", ",", "NoSuchProviderException", ",", "UnrecoverableKeyException", ",", "KeyManagementException", ",", "SmackException", "{", "SmackTlsContext", "smackTlsContext", "=", "getSmackTlsContext", "(", ")", ";", "Socket", "plain", "=", "socket", ";", "// Secure the plain connection", "socket", "=", "smackTlsContext", ".", "sslContext", ".", "getSocketFactory", "(", ")", ".", "createSocket", "(", "plain", ",", "config", ".", "getXMPPServiceDomain", "(", ")", ".", "toString", "(", ")", ",", "plain", ".", "getPort", "(", ")", ",", "true", ")", ";", "final", "SSLSocket", "sslSocket", "=", "(", "SSLSocket", ")", "socket", ";", "// Immediately set the enabled SSL protocols and ciphers. See SMACK-712 why this is", "// important (at least on certain platforms) and it seems to be a good idea anyways to", "// prevent an accidental implicit handshake.", "TLSUtils", ".", "setEnabledProtocolsAndCiphers", "(", "sslSocket", ",", "config", ".", "getEnabledSSLProtocols", "(", ")", ",", "config", ".", "getEnabledSSLCiphers", "(", ")", ")", ";", "// Initialize the reader and writer with the new secured version", "initReaderAndWriter", "(", ")", ";", "// Proceed to do the handshake", "sslSocket", ".", "startHandshake", "(", ")", ";", "if", "(", "smackTlsContext", ".", "daneVerifier", "!=", "null", ")", "{", "smackTlsContext", ".", "daneVerifier", ".", "finish", "(", "sslSocket", ".", "getSession", "(", ")", ")", ";", "}", "final", "HostnameVerifier", "verifier", "=", "getConfiguration", "(", ")", ".", "getHostnameVerifier", "(", ")", ";", "if", "(", "verifier", "==", "null", ")", "{", "throw", "new", "IllegalStateException", "(", "\"No HostnameVerifier set. Use connectionConfiguration.setHostnameVerifier() to configure.\"", ")", ";", "}", "else", "if", "(", "!", "verifier", ".", "verify", "(", "getXMPPServiceDomain", "(", ")", ".", "toString", "(", ")", ",", "sslSocket", ".", "getSession", "(", ")", ")", ")", "{", "throw", "new", "CertificateException", "(", "\"Hostname verification of certificate failed. Certificate does not authenticate \"", "+", "getXMPPServiceDomain", "(", ")", ")", ";", "}", "// Set that TLS was successful", "secureSocket", "=", "sslSocket", ";", "}" ]
The server has indicated that TLS negotiation can start. We now need to secure the existing plain connection and perform a handshake. This method won't return until the connection has finished the handshake or an error occurred while securing the connection. @throws IOException @throws CertificateException @throws NoSuchAlgorithmException @throws NoSuchProviderException @throws KeyStoreException @throws UnrecoverableKeyException @throws KeyManagementException @throws SmackException @throws Exception if an exception occurs.
[ "The", "server", "has", "indicated", "that", "TLS", "negotiation", "can", "start", ".", "We", "now", "need", "to", "secure", "the", "existing", "plain", "connection", "and", "perform", "a", "handshake", ".", "This", "method", "won", "t", "return", "until", "the", "connection", "has", "finished", "the", "handshake", "or", "an", "error", "occurred", "while", "securing", "the", "connection", "." ]
870756997faec1e1bfabfac0cd6c2395b04da873
https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java#L688-L722