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,600 | igniterealtime/Smack | smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | XMPPTCPConnection.maybeGetCompressionHandler | private static XMPPInputOutputStream maybeGetCompressionHandler(Compress.Feature compression) {
for (XMPPInputOutputStream handler : SmackConfiguration.getCompressionHandlers()) {
String method = handler.getCompressionMethod();
if (compression.getMethods().contains(method))
return handler;
}
return null;
} | java | private static XMPPInputOutputStream maybeGetCompressionHandler(Compress.Feature compression) {
for (XMPPInputOutputStream handler : SmackConfiguration.getCompressionHandlers()) {
String method = handler.getCompressionMethod();
if (compression.getMethods().contains(method))
return handler;
}
return null;
} | [
"private",
"static",
"XMPPInputOutputStream",
"maybeGetCompressionHandler",
"(",
"Compress",
".",
"Feature",
"compression",
")",
"{",
"for",
"(",
"XMPPInputOutputStream",
"handler",
":",
"SmackConfiguration",
".",
"getCompressionHandlers",
"(",
")",
")",
"{",
"String",
"method",
"=",
"handler",
".",
"getCompressionMethod",
"(",
")",
";",
"if",
"(",
"compression",
".",
"getMethods",
"(",
")",
".",
"contains",
"(",
"method",
")",
")",
"return",
"handler",
";",
"}",
"return",
"null",
";",
"}"
] | Returns the compression handler that can be used for one compression methods offered by the server.
@return a instance of XMPPInputOutputStream or null if no suitable instance was found | [
"Returns",
"the",
"compression",
"handler",
"that",
"can",
"be",
"used",
"for",
"one",
"compression",
"methods",
"offered",
"by",
"the",
"server",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java#L730-L737 |
26,601 | igniterealtime/Smack | smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | XMPPTCPConnection.openStream | void openStream() throws SmackException, InterruptedException, XmlPullParserException {
sendStreamOpen();
packetReader.parser = PacketParserUtils.newXmppParser(reader);
} | java | void openStream() throws SmackException, InterruptedException, XmlPullParserException {
sendStreamOpen();
packetReader.parser = PacketParserUtils.newXmppParser(reader);
} | [
"void",
"openStream",
"(",
")",
"throws",
"SmackException",
",",
"InterruptedException",
",",
"XmlPullParserException",
"{",
"sendStreamOpen",
"(",
")",
";",
"packetReader",
".",
"parser",
"=",
"PacketParserUtils",
".",
"newXmppParser",
"(",
"reader",
")",
";",
"}"
] | Resets the parser using the latest connection's reader. Resetting the parser is necessary
when the plain connection has been secured or when a new opening stream element is going
to be sent by the server.
@throws SmackException if the parser could not be reset.
@throws InterruptedException
@throws XmlPullParserException | [
"Resets",
"the",
"parser",
"using",
"the",
"latest",
"connection",
"s",
"reader",
".",
"Resetting",
"the",
"parser",
"is",
"necessary",
"when",
"the",
"plain",
"connection",
"has",
"been",
"secured",
"or",
"when",
"a",
"new",
"opening",
"stream",
"element",
"is",
"going",
"to",
"be",
"sent",
"by",
"the",
"server",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java#L856-L859 |
26,602 | igniterealtime/Smack | smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java | XMPPTCPConnection.isSmResumptionPossible | public boolean isSmResumptionPossible() {
// There is no resumable stream available
if (smSessionId == null)
return false;
final Long shutdownTimestamp = packetWriter.shutdownTimestamp;
// Seems like we are already reconnected, report true
if (shutdownTimestamp == null) {
return true;
}
// See if resumption time is over
long current = System.currentTimeMillis();
long maxResumptionMillies = ((long) getMaxSmResumptionTime()) * 1000;
if (current > shutdownTimestamp + maxResumptionMillies) {
// Stream resumption is *not* possible if the current timestamp is greater then the greatest timestamp where
// resumption is possible
return false;
} else {
return true;
}
} | java | public boolean isSmResumptionPossible() {
// There is no resumable stream available
if (smSessionId == null)
return false;
final Long shutdownTimestamp = packetWriter.shutdownTimestamp;
// Seems like we are already reconnected, report true
if (shutdownTimestamp == null) {
return true;
}
// See if resumption time is over
long current = System.currentTimeMillis();
long maxResumptionMillies = ((long) getMaxSmResumptionTime()) * 1000;
if (current > shutdownTimestamp + maxResumptionMillies) {
// Stream resumption is *not* possible if the current timestamp is greater then the greatest timestamp where
// resumption is possible
return false;
} else {
return true;
}
} | [
"public",
"boolean",
"isSmResumptionPossible",
"(",
")",
"{",
"// There is no resumable stream available",
"if",
"(",
"smSessionId",
"==",
"null",
")",
"return",
"false",
";",
"final",
"Long",
"shutdownTimestamp",
"=",
"packetWriter",
".",
"shutdownTimestamp",
";",
"// Seems like we are already reconnected, report true",
"if",
"(",
"shutdownTimestamp",
"==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"// See if resumption time is over",
"long",
"current",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"maxResumptionMillies",
"=",
"(",
"(",
"long",
")",
"getMaxSmResumptionTime",
"(",
")",
")",
"*",
"1000",
";",
"if",
"(",
"current",
">",
"shutdownTimestamp",
"+",
"maxResumptionMillies",
")",
"{",
"// Stream resumption is *not* possible if the current timestamp is greater then the greatest timestamp where",
"// resumption is possible",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}"
] | Returns true if the stream is resumable.
@return true if the stream is resumable. | [
"Returns",
"true",
"if",
"the",
"stream",
"is",
"resumable",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/tcp/XMPPTCPConnection.java#L1728-L1749 |
26,603 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getInstanceFor | public static synchronized OmemoManager getInstanceFor(XMPPConnection connection, Integer deviceId) {
if (deviceId == null || deviceId < 1) {
throw new IllegalArgumentException("DeviceId MUST NOT be null and MUST be greater than 0.");
}
TreeMap<Integer,OmemoManager> managersOfConnection = INSTANCES.get(connection);
if (managersOfConnection == null) {
managersOfConnection = new TreeMap<>();
INSTANCES.put(connection, managersOfConnection);
}
OmemoManager manager = managersOfConnection.get(deviceId);
if (manager == null) {
manager = new OmemoManager(connection, deviceId);
managersOfConnection.put(deviceId, manager);
}
return manager;
} | java | public static synchronized OmemoManager getInstanceFor(XMPPConnection connection, Integer deviceId) {
if (deviceId == null || deviceId < 1) {
throw new IllegalArgumentException("DeviceId MUST NOT be null and MUST be greater than 0.");
}
TreeMap<Integer,OmemoManager> managersOfConnection = INSTANCES.get(connection);
if (managersOfConnection == null) {
managersOfConnection = new TreeMap<>();
INSTANCES.put(connection, managersOfConnection);
}
OmemoManager manager = managersOfConnection.get(deviceId);
if (manager == null) {
manager = new OmemoManager(connection, deviceId);
managersOfConnection.put(deviceId, manager);
}
return manager;
} | [
"public",
"static",
"synchronized",
"OmemoManager",
"getInstanceFor",
"(",
"XMPPConnection",
"connection",
",",
"Integer",
"deviceId",
")",
"{",
"if",
"(",
"deviceId",
"==",
"null",
"||",
"deviceId",
"<",
"1",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"\"DeviceId MUST NOT be null and MUST be greater than 0.\"",
")",
";",
"}",
"TreeMap",
"<",
"Integer",
",",
"OmemoManager",
">",
"managersOfConnection",
"=",
"INSTANCES",
".",
"get",
"(",
"connection",
")",
";",
"if",
"(",
"managersOfConnection",
"==",
"null",
")",
"{",
"managersOfConnection",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"INSTANCES",
".",
"put",
"(",
"connection",
",",
"managersOfConnection",
")",
";",
"}",
"OmemoManager",
"manager",
"=",
"managersOfConnection",
".",
"get",
"(",
"deviceId",
")",
";",
"if",
"(",
"manager",
"==",
"null",
")",
"{",
"manager",
"=",
"new",
"OmemoManager",
"(",
"connection",
",",
"deviceId",
")",
";",
"managersOfConnection",
".",
"put",
"(",
"deviceId",
",",
"manager",
")",
";",
"}",
"return",
"manager",
";",
"}"
] | Return an OmemoManager instance for the given connection and deviceId.
If there was an OmemoManager for the connection and id before, return it. Otherwise create a new OmemoManager
instance and return it.
@param connection XmppConnection.
@param deviceId MUST NOT be null and MUST be greater than 0.
@return manager | [
"Return",
"an",
"OmemoManager",
"instance",
"for",
"the",
"given",
"connection",
"and",
"deviceId",
".",
"If",
"there",
"was",
"an",
"OmemoManager",
"for",
"the",
"connection",
"and",
"id",
"before",
"return",
"it",
".",
"Otherwise",
"create",
"a",
"new",
"OmemoManager",
"instance",
"and",
"return",
"it",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L154-L172 |
26,604 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getInstanceFor | public static synchronized OmemoManager getInstanceFor(XMPPConnection connection) {
TreeMap<Integer, OmemoManager> managers = INSTANCES.get(connection);
if (managers == null) {
managers = new TreeMap<>();
INSTANCES.put(connection, managers);
}
OmemoManager manager;
if (managers.size() == 0) {
manager = new OmemoManager(connection, UNKNOWN_DEVICE_ID);
managers.put(UNKNOWN_DEVICE_ID, manager);
} else {
manager = managers.get(managers.firstKey());
}
return manager;
} | java | public static synchronized OmemoManager getInstanceFor(XMPPConnection connection) {
TreeMap<Integer, OmemoManager> managers = INSTANCES.get(connection);
if (managers == null) {
managers = new TreeMap<>();
INSTANCES.put(connection, managers);
}
OmemoManager manager;
if (managers.size() == 0) {
manager = new OmemoManager(connection, UNKNOWN_DEVICE_ID);
managers.put(UNKNOWN_DEVICE_ID, manager);
} else {
manager = managers.get(managers.firstKey());
}
return manager;
} | [
"public",
"static",
"synchronized",
"OmemoManager",
"getInstanceFor",
"(",
"XMPPConnection",
"connection",
")",
"{",
"TreeMap",
"<",
"Integer",
",",
"OmemoManager",
">",
"managers",
"=",
"INSTANCES",
".",
"get",
"(",
"connection",
")",
";",
"if",
"(",
"managers",
"==",
"null",
")",
"{",
"managers",
"=",
"new",
"TreeMap",
"<>",
"(",
")",
";",
"INSTANCES",
".",
"put",
"(",
"connection",
",",
"managers",
")",
";",
"}",
"OmemoManager",
"manager",
";",
"if",
"(",
"managers",
".",
"size",
"(",
")",
"==",
"0",
")",
"{",
"manager",
"=",
"new",
"OmemoManager",
"(",
"connection",
",",
"UNKNOWN_DEVICE_ID",
")",
";",
"managers",
".",
"put",
"(",
"UNKNOWN_DEVICE_ID",
",",
"manager",
")",
";",
"}",
"else",
"{",
"manager",
"=",
"managers",
".",
"get",
"(",
"managers",
".",
"firstKey",
"(",
")",
")",
";",
"}",
"return",
"manager",
";",
"}"
] | Returns an OmemoManager instance for the given connection. If there was one manager for the connection before,
return it. If there were multiple managers before, return the one with the lowest deviceId.
If there was no manager before, return a new one. As soon as the connection gets authenticated, the manager
will look for local deviceIDs and select the lowest one as its id. If there are not local deviceIds, the manager
will assign itself a random id.
@param connection XmppConnection.
@return manager | [
"Returns",
"an",
"OmemoManager",
"instance",
"for",
"the",
"given",
"connection",
".",
"If",
"there",
"was",
"one",
"manager",
"for",
"the",
"connection",
"before",
"return",
"it",
".",
"If",
"there",
"were",
"multiple",
"managers",
"before",
"return",
"the",
"one",
"with",
"the",
"lowest",
"deviceId",
".",
"If",
"there",
"was",
"no",
"manager",
"before",
"return",
"a",
"new",
"one",
".",
"As",
"soon",
"as",
"the",
"connection",
"gets",
"authenticated",
"the",
"manager",
"will",
"look",
"for",
"local",
"deviceIDs",
"and",
"select",
"the",
"lowest",
"one",
"as",
"its",
"id",
".",
"If",
"there",
"are",
"not",
"local",
"deviceIds",
"the",
"manager",
"will",
"assign",
"itself",
"a",
"random",
"id",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L185-L203 |
26,605 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.initialize | public void initialize()
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException,
SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException,
PubSubException.NotALeafNodeException {
synchronized (LOCK) {
if (!connection().isAuthenticated()) {
throw new SmackException.NotLoggedInException();
}
if (getTrustCallback() == null) {
throw new IllegalStateException("No TrustCallback set.");
}
getOmemoService().init(new LoggedInOmemoManager(this));
ServiceDiscoveryManager.getInstanceFor(connection()).addFeature(PEP_NODE_DEVICE_LIST_NOTIFY);
}
} | java | public void initialize()
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException,
SmackException.NoResponseException, SmackException.NotConnectedException, XMPPException.XMPPErrorException,
PubSubException.NotALeafNodeException {
synchronized (LOCK) {
if (!connection().isAuthenticated()) {
throw new SmackException.NotLoggedInException();
}
if (getTrustCallback() == null) {
throw new IllegalStateException("No TrustCallback set.");
}
getOmemoService().init(new LoggedInOmemoManager(this));
ServiceDiscoveryManager.getInstanceFor(connection()).addFeature(PEP_NODE_DEVICE_LIST_NOTIFY);
}
} | [
"public",
"void",
"initialize",
"(",
")",
"throws",
"SmackException",
".",
"NotLoggedInException",
",",
"CorruptedOmemoKeyException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"PubSubException",
".",
"NotALeafNodeException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"!",
"connection",
"(",
")",
".",
"isAuthenticated",
"(",
")",
")",
"{",
"throw",
"new",
"SmackException",
".",
"NotLoggedInException",
"(",
")",
";",
"}",
"if",
"(",
"getTrustCallback",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No TrustCallback set.\"",
")",
";",
"}",
"getOmemoService",
"(",
")",
".",
"init",
"(",
"new",
"LoggedInOmemoManager",
"(",
"this",
")",
")",
";",
"ServiceDiscoveryManager",
".",
"getInstanceFor",
"(",
"connection",
"(",
")",
")",
".",
"addFeature",
"(",
"PEP_NODE_DEVICE_LIST_NOTIFY",
")",
";",
"}",
"}"
] | Initializes the OmemoManager. This method must be called before the manager can be used.
@throws CorruptedOmemoKeyException
@throws InterruptedException
@throws SmackException.NoResponseException
@throws SmackException.NotConnectedException
@throws XMPPException.XMPPErrorException
@throws SmackException.NotLoggedInException
@throws PubSubException.NotALeafNodeException | [
"Initializes",
"the",
"OmemoManager",
".",
"This",
"method",
"must",
"be",
"called",
"before",
"the",
"manager",
"can",
"be",
"used",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L237-L253 |
26,606 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.initializeAsync | public void initializeAsync(final InitializationFinishedCallback finishedCallback) {
Async.go(new Runnable() {
@Override
public void run() {
try {
initialize();
finishedCallback.initializationFinished(OmemoManager.this);
} catch (Exception e) {
finishedCallback.initializationFailed(e);
}
}
});
} | java | public void initializeAsync(final InitializationFinishedCallback finishedCallback) {
Async.go(new Runnable() {
@Override
public void run() {
try {
initialize();
finishedCallback.initializationFinished(OmemoManager.this);
} catch (Exception e) {
finishedCallback.initializationFailed(e);
}
}
});
} | [
"public",
"void",
"initializeAsync",
"(",
"final",
"InitializationFinishedCallback",
"finishedCallback",
")",
"{",
"Async",
".",
"go",
"(",
"new",
"Runnable",
"(",
")",
"{",
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"initialize",
"(",
")",
";",
"finishedCallback",
".",
"initializationFinished",
"(",
"OmemoManager",
".",
"this",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"finishedCallback",
".",
"initializationFailed",
"(",
"e",
")",
";",
"}",
"}",
"}",
")",
";",
"}"
] | Initialize the manager without blocking. Once the manager is successfully initialized, the finishedCallback will
be notified. It will also get notified, if an error occurs.
@param finishedCallback callback that gets called once the manager is initialized. | [
"Initialize",
"the",
"manager",
"without",
"blocking",
".",
"Once",
"the",
"manager",
"is",
"successfully",
"initialized",
"the",
"finishedCallback",
"will",
"be",
"notified",
".",
"It",
"will",
"also",
"get",
"notified",
"if",
"an",
"error",
"occurs",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L261-L273 |
26,607 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getDevicesOf | public Set<OmemoDevice> getDevicesOf(BareJid contact) {
OmemoCachedDeviceList list = getOmemoService().getOmemoStoreBackend().loadCachedDeviceList(getOwnDevice(), contact);
HashSet<OmemoDevice> devices = new HashSet<>();
for (int deviceId : list.getActiveDevices()) {
devices.add(new OmemoDevice(contact, deviceId));
}
return devices;
} | java | public Set<OmemoDevice> getDevicesOf(BareJid contact) {
OmemoCachedDeviceList list = getOmemoService().getOmemoStoreBackend().loadCachedDeviceList(getOwnDevice(), contact);
HashSet<OmemoDevice> devices = new HashSet<>();
for (int deviceId : list.getActiveDevices()) {
devices.add(new OmemoDevice(contact, deviceId));
}
return devices;
} | [
"public",
"Set",
"<",
"OmemoDevice",
">",
"getDevicesOf",
"(",
"BareJid",
"contact",
")",
"{",
"OmemoCachedDeviceList",
"list",
"=",
"getOmemoService",
"(",
")",
".",
"getOmemoStoreBackend",
"(",
")",
".",
"loadCachedDeviceList",
"(",
"getOwnDevice",
"(",
")",
",",
"contact",
")",
";",
"HashSet",
"<",
"OmemoDevice",
">",
"devices",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"int",
"deviceId",
":",
"list",
".",
"getActiveDevices",
"(",
")",
")",
"{",
"devices",
".",
"add",
"(",
"new",
"OmemoDevice",
"(",
"contact",
",",
"deviceId",
")",
")",
";",
"}",
"return",
"devices",
";",
"}"
] | Return a set of all OMEMO capable devices of a contact.
Note, that this method does not explicitly refresh the device list of the contact, so it might be outdated.
@see #requestDeviceListUpdateFor(BareJid)
@param contact contact we want to get a set of device of.
@return set of known devices of that contact. | [
"Return",
"a",
"set",
"of",
"all",
"OMEMO",
"capable",
"devices",
"of",
"a",
"contact",
".",
"Note",
"that",
"this",
"method",
"does",
"not",
"explicitly",
"refresh",
"the",
"device",
"list",
"of",
"the",
"contact",
"so",
"it",
"might",
"be",
"outdated",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L282-L291 |
26,608 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.encrypt | public OmemoMessage.Sent encrypt(BareJid recipient, String message)
throws CryptoFailedException, UndecidedOmemoIdentityException,
InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, SmackException.NotLoggedInException {
synchronized (LOCK) {
Set<BareJid> recipients = new HashSet<>();
recipients.add(recipient);
return encrypt(recipients, message);
}
} | java | public OmemoMessage.Sent encrypt(BareJid recipient, String message)
throws CryptoFailedException, UndecidedOmemoIdentityException,
InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, SmackException.NotLoggedInException {
synchronized (LOCK) {
Set<BareJid> recipients = new HashSet<>();
recipients.add(recipient);
return encrypt(recipients, message);
}
} | [
"public",
"OmemoMessage",
".",
"Sent",
"encrypt",
"(",
"BareJid",
"recipient",
",",
"String",
"message",
")",
"throws",
"CryptoFailedException",
",",
"UndecidedOmemoIdentityException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"SmackException",
".",
"NotLoggedInException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"Set",
"<",
"BareJid",
">",
"recipients",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"recipients",
".",
"add",
"(",
"recipient",
")",
";",
"return",
"encrypt",
"(",
"recipients",
",",
"message",
")",
";",
"}",
"}"
] | OMEMO encrypt a cleartext message for a single recipient.
Note that this method does NOT set the 'to' attribute of the message.
@param recipient recipients bareJid
@param message text to encrypt
@return encrypted message
@throws CryptoFailedException when something crypto related fails
@throws UndecidedOmemoIdentityException When there are undecided devices
@throws InterruptedException
@throws SmackException.NotConnectedException
@throws SmackException.NoResponseException
@throws SmackException.NotLoggedInException | [
"OMEMO",
"encrypt",
"a",
"cleartext",
"message",
"for",
"a",
"single",
"recipient",
".",
"Note",
"that",
"this",
"method",
"does",
"NOT",
"set",
"the",
"to",
"attribute",
"of",
"the",
"message",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L307-L316 |
26,609 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.encrypt | public OmemoMessage.Sent encrypt(Set<BareJid> recipients, String message)
throws CryptoFailedException, UndecidedOmemoIdentityException,
InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, SmackException.NotLoggedInException {
synchronized (LOCK) {
LoggedInOmemoManager guard = new LoggedInOmemoManager(this);
Set<OmemoDevice> devices = getDevicesOf(getOwnJid());
for (BareJid recipient : recipients) {
devices.addAll(getDevicesOf(recipient));
}
return service.createOmemoMessage(guard, devices, message);
}
} | java | public OmemoMessage.Sent encrypt(Set<BareJid> recipients, String message)
throws CryptoFailedException, UndecidedOmemoIdentityException,
InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, SmackException.NotLoggedInException {
synchronized (LOCK) {
LoggedInOmemoManager guard = new LoggedInOmemoManager(this);
Set<OmemoDevice> devices = getDevicesOf(getOwnJid());
for (BareJid recipient : recipients) {
devices.addAll(getDevicesOf(recipient));
}
return service.createOmemoMessage(guard, devices, message);
}
} | [
"public",
"OmemoMessage",
".",
"Sent",
"encrypt",
"(",
"Set",
"<",
"BareJid",
">",
"recipients",
",",
"String",
"message",
")",
"throws",
"CryptoFailedException",
",",
"UndecidedOmemoIdentityException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"SmackException",
".",
"NotLoggedInException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"LoggedInOmemoManager",
"guard",
"=",
"new",
"LoggedInOmemoManager",
"(",
"this",
")",
";",
"Set",
"<",
"OmemoDevice",
">",
"devices",
"=",
"getDevicesOf",
"(",
"getOwnJid",
"(",
")",
")",
";",
"for",
"(",
"BareJid",
"recipient",
":",
"recipients",
")",
"{",
"devices",
".",
"addAll",
"(",
"getDevicesOf",
"(",
"recipient",
")",
")",
";",
"}",
"return",
"service",
".",
"createOmemoMessage",
"(",
"guard",
",",
"devices",
",",
"message",
")",
";",
"}",
"}"
] | OMEMO encrypt a cleartext message for multiple recipients.
@param recipients recipients barejids
@param message text to encrypt
@return encrypted message.
@throws CryptoFailedException When something crypto related fails
@throws UndecidedOmemoIdentityException When there are undecided devices.
@throws InterruptedException
@throws SmackException.NotConnectedException
@throws SmackException.NoResponseException
@throws SmackException.NotLoggedInException | [
"OMEMO",
"encrypt",
"a",
"cleartext",
"message",
"for",
"multiple",
"recipients",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L331-L343 |
26,610 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.encrypt | public OmemoMessage.Sent encrypt(MultiUserChat muc, String message)
throws UndecidedOmemoIdentityException, CryptoFailedException,
XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException, NoOmemoSupportException,
SmackException.NotLoggedInException {
synchronized (LOCK) {
if (!multiUserChatSupportsOmemo(muc)) {
throw new NoOmemoSupportException();
}
Set<BareJid> recipients = new HashSet<>();
for (EntityFullJid e : muc.getOccupants()) {
recipients.add(muc.getOccupant(e).getJid().asBareJid());
}
return encrypt(recipients, message);
}
} | java | public OmemoMessage.Sent encrypt(MultiUserChat muc, String message)
throws UndecidedOmemoIdentityException, CryptoFailedException,
XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException, NoOmemoSupportException,
SmackException.NotLoggedInException {
synchronized (LOCK) {
if (!multiUserChatSupportsOmemo(muc)) {
throw new NoOmemoSupportException();
}
Set<BareJid> recipients = new HashSet<>();
for (EntityFullJid e : muc.getOccupants()) {
recipients.add(muc.getOccupant(e).getJid().asBareJid());
}
return encrypt(recipients, message);
}
} | [
"public",
"OmemoMessage",
".",
"Sent",
"encrypt",
"(",
"MultiUserChat",
"muc",
",",
"String",
"message",
")",
"throws",
"UndecidedOmemoIdentityException",
",",
"CryptoFailedException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"NoOmemoSupportException",
",",
"SmackException",
".",
"NotLoggedInException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"!",
"multiUserChatSupportsOmemo",
"(",
"muc",
")",
")",
"{",
"throw",
"new",
"NoOmemoSupportException",
"(",
")",
";",
"}",
"Set",
"<",
"BareJid",
">",
"recipients",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"for",
"(",
"EntityFullJid",
"e",
":",
"muc",
".",
"getOccupants",
"(",
")",
")",
"{",
"recipients",
".",
"add",
"(",
"muc",
".",
"getOccupant",
"(",
"e",
")",
".",
"getJid",
"(",
")",
".",
"asBareJid",
"(",
")",
")",
";",
"}",
"return",
"encrypt",
"(",
"recipients",
",",
"message",
")",
";",
"}",
"}"
] | Encrypt a message for all recipients in the MultiUserChat.
@param muc multiUserChat
@param message message to send
@return encrypted message
@throws UndecidedOmemoIdentityException when there are undecided devices.
@throws CryptoFailedException
@throws XMPPException.XMPPErrorException
@throws SmackException.NotConnectedException
@throws InterruptedException
@throws SmackException.NoResponseException
@throws NoOmemoSupportException When the muc doesn't support OMEMO.
@throws SmackException.NotLoggedInException | [
"Encrypt",
"a",
"message",
"for",
"all",
"recipients",
"in",
"the",
"MultiUserChat",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L360-L377 |
26,611 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.decryptMamQueryResult | public List<MessageOrOmemoMessage> decryptMamQueryResult(MamManager.MamQuery mamQuery)
throws SmackException.NotLoggedInException {
return new ArrayList<>(getOmemoService().decryptMamQueryResult(new LoggedInOmemoManager(this), mamQuery));
} | java | public List<MessageOrOmemoMessage> decryptMamQueryResult(MamManager.MamQuery mamQuery)
throws SmackException.NotLoggedInException {
return new ArrayList<>(getOmemoService().decryptMamQueryResult(new LoggedInOmemoManager(this), mamQuery));
} | [
"public",
"List",
"<",
"MessageOrOmemoMessage",
">",
"decryptMamQueryResult",
"(",
"MamManager",
".",
"MamQuery",
"mamQuery",
")",
"throws",
"SmackException",
".",
"NotLoggedInException",
"{",
"return",
"new",
"ArrayList",
"<>",
"(",
"getOmemoService",
"(",
")",
".",
"decryptMamQueryResult",
"(",
"new",
"LoggedInOmemoManager",
"(",
"this",
")",
",",
"mamQuery",
")",
")",
";",
"}"
] | Decrypt messages from a MAM query.
@param mamQuery The MAM query
@return list of decrypted OmemoMessages
@throws SmackException.NotLoggedInException if the Manager is not authenticated. | [
"Decrypt",
"messages",
"from",
"a",
"MAM",
"query",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L407-L410 |
26,612 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.trustOmemoIdentity | public void trustOmemoIdentity(OmemoDevice device, OmemoFingerprint fingerprint) {
if (trustCallback == null) {
throw new IllegalStateException("No TrustCallback set.");
}
trustCallback.setTrust(device, fingerprint, TrustState.trusted);
} | java | public void trustOmemoIdentity(OmemoDevice device, OmemoFingerprint fingerprint) {
if (trustCallback == null) {
throw new IllegalStateException("No TrustCallback set.");
}
trustCallback.setTrust(device, fingerprint, TrustState.trusted);
} | [
"public",
"void",
"trustOmemoIdentity",
"(",
"OmemoDevice",
"device",
",",
"OmemoFingerprint",
"fingerprint",
")",
"{",
"if",
"(",
"trustCallback",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"No TrustCallback set.\"",
")",
";",
"}",
"trustCallback",
".",
"setTrust",
"(",
"device",
",",
"fingerprint",
",",
"TrustState",
".",
"trusted",
")",
";",
"}"
] | Trust that a fingerprint belongs to an OmemoDevice.
The fingerprint must be the lowercase, hexadecimal fingerprint of the identityKey of the device and must
be of length 64.
@param device device
@param fingerprint fingerprint | [
"Trust",
"that",
"a",
"fingerprint",
"belongs",
"to",
"an",
"OmemoDevice",
".",
"The",
"fingerprint",
"must",
"be",
"the",
"lowercase",
"hexadecimal",
"fingerprint",
"of",
"the",
"identityKey",
"of",
"the",
"device",
"and",
"must",
"be",
"of",
"length",
"64",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L420-L426 |
26,613 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.sendRatchetUpdateMessage | public void sendRatchetUpdateMessage(OmemoDevice recipient)
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException,
SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException,
CryptoFailedException, CannotEstablishOmemoSessionException {
synchronized (LOCK) {
Message message = new Message();
message.setFrom(getOwnJid());
message.setTo(recipient.getJid());
OmemoElement element = getOmemoService()
.createRatchetUpdateElement(new LoggedInOmemoManager(this), recipient);
message.addExtension(element);
// Set MAM Storage hint
StoreHint.set(message);
connection().sendStanza(message);
}
} | java | public void sendRatchetUpdateMessage(OmemoDevice recipient)
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException, InterruptedException,
SmackException.NoResponseException, NoSuchAlgorithmException, SmackException.NotConnectedException,
CryptoFailedException, CannotEstablishOmemoSessionException {
synchronized (LOCK) {
Message message = new Message();
message.setFrom(getOwnJid());
message.setTo(recipient.getJid());
OmemoElement element = getOmemoService()
.createRatchetUpdateElement(new LoggedInOmemoManager(this), recipient);
message.addExtension(element);
// Set MAM Storage hint
StoreHint.set(message);
connection().sendStanza(message);
}
} | [
"public",
"void",
"sendRatchetUpdateMessage",
"(",
"OmemoDevice",
"recipient",
")",
"throws",
"SmackException",
".",
"NotLoggedInException",
",",
"CorruptedOmemoKeyException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"NoSuchAlgorithmException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"CryptoFailedException",
",",
"CannotEstablishOmemoSessionException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"Message",
"message",
"=",
"new",
"Message",
"(",
")",
";",
"message",
".",
"setFrom",
"(",
"getOwnJid",
"(",
")",
")",
";",
"message",
".",
"setTo",
"(",
"recipient",
".",
"getJid",
"(",
")",
")",
";",
"OmemoElement",
"element",
"=",
"getOmemoService",
"(",
")",
".",
"createRatchetUpdateElement",
"(",
"new",
"LoggedInOmemoManager",
"(",
"this",
")",
",",
"recipient",
")",
";",
"message",
".",
"addExtension",
"(",
"element",
")",
";",
"// Set MAM Storage hint",
"StoreHint",
".",
"set",
"(",
"message",
")",
";",
"connection",
"(",
")",
".",
"sendStanza",
"(",
"message",
")",
";",
"}",
"}"
] | Send a ratchet update message. This can be used to advance the ratchet of a session in order to maintain forward
secrecy.
@param recipient recipient
@throws CorruptedOmemoKeyException When the used identityKeys are corrupted
@throws CryptoFailedException When something fails with the crypto
@throws CannotEstablishOmemoSessionException When we can't establish a session with the recipient
@throws SmackException.NotLoggedInException
@throws InterruptedException
@throws SmackException.NoResponseException
@throws NoSuchAlgorithmException
@throws SmackException.NotConnectedException | [
"Send",
"a",
"ratchet",
"update",
"message",
".",
"This",
"can",
"be",
"used",
"to",
"advance",
"the",
"ratchet",
"of",
"a",
"session",
"in",
"order",
"to",
"maintain",
"forward",
"secrecy",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L489-L506 |
26,614 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.contactSupportsOmemo | public boolean contactSupportsOmemo(BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
synchronized (LOCK) {
OmemoCachedDeviceList deviceList = getOmemoService().refreshDeviceList(connection(), getOwnDevice(), contact);
return !deviceList.getActiveDevices().isEmpty();
}
} | java | public boolean contactSupportsOmemo(BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
synchronized (LOCK) {
OmemoCachedDeviceList deviceList = getOmemoService().refreshDeviceList(connection(), getOwnDevice(), contact);
return !deviceList.getActiveDevices().isEmpty();
}
} | [
"public",
"boolean",
"contactSupportsOmemo",
"(",
"BareJid",
"contact",
")",
"throws",
"InterruptedException",
",",
"PubSubException",
".",
"NotALeafNodeException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NoResponseException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"OmemoCachedDeviceList",
"deviceList",
"=",
"getOmemoService",
"(",
")",
".",
"refreshDeviceList",
"(",
"connection",
"(",
")",
",",
"getOwnDevice",
"(",
")",
",",
"contact",
")",
";",
"return",
"!",
"deviceList",
".",
"getActiveDevices",
"(",
")",
".",
"isEmpty",
"(",
")",
";",
"}",
"}"
] | Returns true, if the contact has any active devices published in a deviceList.
@param contact contact
@return true if contact has at least one OMEMO capable device.
@throws SmackException.NotConnectedException
@throws InterruptedException
@throws SmackException.NoResponseException
@throws PubSubException.NotALeafNodeException
@throws XMPPException.XMPPErrorException | [
"Returns",
"true",
"if",
"the",
"contact",
"has",
"any",
"active",
"devices",
"published",
"in",
"a",
"deviceList",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L519-L526 |
26,615 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.serverSupportsOmemo | public static boolean serverSupportsOmemo(XMPPConnection connection, DomainBareJid server)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
return ServiceDiscoveryManager.getInstanceFor(connection)
.discoverInfo(server).containsFeature(PubSub.NAMESPACE);
} | java | public static boolean serverSupportsOmemo(XMPPConnection connection, DomainBareJid server)
throws XMPPException.XMPPErrorException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
return ServiceDiscoveryManager.getInstanceFor(connection)
.discoverInfo(server).containsFeature(PubSub.NAMESPACE);
} | [
"public",
"static",
"boolean",
"serverSupportsOmemo",
"(",
"XMPPConnection",
"connection",
",",
"DomainBareJid",
"server",
")",
"throws",
"XMPPException",
".",
"XMPPErrorException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
"{",
"return",
"ServiceDiscoveryManager",
".",
"getInstanceFor",
"(",
"connection",
")",
".",
"discoverInfo",
"(",
"server",
")",
".",
"containsFeature",
"(",
"PubSub",
".",
"NAMESPACE",
")",
";",
"}"
] | Returns true, if the Server supports PEP.
@param connection XMPPConnection
@param server domainBareJid of the server to test
@return true if server supports pep
@throws XMPPException.XMPPErrorException
@throws SmackException.NotConnectedException
@throws InterruptedException
@throws SmackException.NoResponseException | [
"Returns",
"true",
"if",
"the",
"Server",
"supports",
"PEP",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L558-L563 |
26,616 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getOwnFingerprint | public OmemoFingerprint getOwnFingerprint()
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException {
synchronized (LOCK) {
if (getOwnJid() == null) {
throw new SmackException.NotLoggedInException();
}
return getOmemoService().getOmemoStoreBackend().getFingerprint(getOwnDevice());
}
} | java | public OmemoFingerprint getOwnFingerprint()
throws SmackException.NotLoggedInException, CorruptedOmemoKeyException {
synchronized (LOCK) {
if (getOwnJid() == null) {
throw new SmackException.NotLoggedInException();
}
return getOmemoService().getOmemoStoreBackend().getFingerprint(getOwnDevice());
}
} | [
"public",
"OmemoFingerprint",
"getOwnFingerprint",
"(",
")",
"throws",
"SmackException",
".",
"NotLoggedInException",
",",
"CorruptedOmemoKeyException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"getOwnJid",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"SmackException",
".",
"NotLoggedInException",
"(",
")",
";",
"}",
"return",
"getOmemoService",
"(",
")",
".",
"getOmemoStoreBackend",
"(",
")",
".",
"getFingerprint",
"(",
"getOwnDevice",
"(",
")",
")",
";",
"}",
"}"
] | Return the fingerprint of our identity key.
@return fingerprint
@throws SmackException.NotLoggedInException if we don't know our bareJid yet.
@throws CorruptedOmemoKeyException if our identityKey is corrupted. | [
"Return",
"the",
"fingerprint",
"of",
"our",
"identity",
"key",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L572-L581 |
26,617 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getFingerprint | public OmemoFingerprint getFingerprint(OmemoDevice device)
throws CannotEstablishOmemoSessionException, SmackException.NotLoggedInException,
CorruptedOmemoKeyException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
synchronized (LOCK) {
if (getOwnJid() == null) {
throw new SmackException.NotLoggedInException();
}
if (device.equals(getOwnDevice())) {
return getOwnFingerprint();
}
return getOmemoService().getOmemoStoreBackend().getFingerprintAndMaybeBuildSession(new LoggedInOmemoManager(this), device);
}
} | java | public OmemoFingerprint getFingerprint(OmemoDevice device)
throws CannotEstablishOmemoSessionException, SmackException.NotLoggedInException,
CorruptedOmemoKeyException, SmackException.NotConnectedException, InterruptedException,
SmackException.NoResponseException {
synchronized (LOCK) {
if (getOwnJid() == null) {
throw new SmackException.NotLoggedInException();
}
if (device.equals(getOwnDevice())) {
return getOwnFingerprint();
}
return getOmemoService().getOmemoStoreBackend().getFingerprintAndMaybeBuildSession(new LoggedInOmemoManager(this), device);
}
} | [
"public",
"OmemoFingerprint",
"getFingerprint",
"(",
"OmemoDevice",
"device",
")",
"throws",
"CannotEstablishOmemoSessionException",
",",
"SmackException",
".",
"NotLoggedInException",
",",
"CorruptedOmemoKeyException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"getOwnJid",
"(",
")",
"==",
"null",
")",
"{",
"throw",
"new",
"SmackException",
".",
"NotLoggedInException",
"(",
")",
";",
"}",
"if",
"(",
"device",
".",
"equals",
"(",
"getOwnDevice",
"(",
")",
")",
")",
"{",
"return",
"getOwnFingerprint",
"(",
")",
";",
"}",
"return",
"getOmemoService",
"(",
")",
".",
"getOmemoStoreBackend",
"(",
")",
".",
"getFingerprintAndMaybeBuildSession",
"(",
"new",
"LoggedInOmemoManager",
"(",
"this",
")",
",",
"device",
")",
";",
"}",
"}"
] | Get the fingerprint of a contacts device.
@param device contacts OmemoDevice
@return fingerprint
@throws CannotEstablishOmemoSessionException if we have no session yet, and are unable to create one.
@throws SmackException.NotLoggedInException
@throws CorruptedOmemoKeyException if the copy of the fingerprint we have is corrupted.
@throws SmackException.NotConnectedException
@throws InterruptedException
@throws SmackException.NoResponseException | [
"Get",
"the",
"fingerprint",
"of",
"a",
"contacts",
"device",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L594-L609 |
26,618 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.requestDeviceListUpdateFor | public void requestDeviceListUpdateFor(BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
synchronized (LOCK) {
getOmemoService().refreshDeviceList(connection(), getOwnDevice(), contact);
}
} | java | public void requestDeviceListUpdateFor(BareJid contact)
throws InterruptedException, PubSubException.NotALeafNodeException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
synchronized (LOCK) {
getOmemoService().refreshDeviceList(connection(), getOwnDevice(), contact);
}
} | [
"public",
"void",
"requestDeviceListUpdateFor",
"(",
"BareJid",
"contact",
")",
"throws",
"InterruptedException",
",",
"PubSubException",
".",
"NotALeafNodeException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NoResponseException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"getOmemoService",
"(",
")",
".",
"refreshDeviceList",
"(",
"connection",
"(",
")",
",",
"getOwnDevice",
"(",
")",
",",
"contact",
")",
";",
"}",
"}"
] | Request a deviceList update from contact contact.
@param contact contact we want to obtain the deviceList from.
@throws InterruptedException
@throws PubSubException.NotALeafNodeException
@throws XMPPException.XMPPErrorException
@throws SmackException.NotConnectedException
@throws SmackException.NoResponseException | [
"Request",
"a",
"deviceList",
"update",
"from",
"contact",
"contact",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L695-L701 |
26,619 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.purgeDeviceList | public void purgeDeviceList()
throws SmackException.NotLoggedInException, InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
synchronized (LOCK) {
getOmemoService().purgeDeviceList(new LoggedInOmemoManager(this));
}
} | java | public void purgeDeviceList()
throws SmackException.NotLoggedInException, InterruptedException, XMPPException.XMPPErrorException,
SmackException.NotConnectedException, SmackException.NoResponseException {
synchronized (LOCK) {
getOmemoService().purgeDeviceList(new LoggedInOmemoManager(this));
}
} | [
"public",
"void",
"purgeDeviceList",
"(",
")",
"throws",
"SmackException",
".",
"NotLoggedInException",
",",
"InterruptedException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NoResponseException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"getOmemoService",
"(",
")",
".",
"purgeDeviceList",
"(",
"new",
"LoggedInOmemoManager",
"(",
"this",
")",
")",
";",
"}",
"}"
] | Publish a new device list with just our own deviceId in it.
@throws SmackException.NotLoggedInException
@throws InterruptedException
@throws XMPPException.XMPPErrorException
@throws SmackException.NotConnectedException
@throws SmackException.NoResponseException | [
"Publish",
"a",
"new",
"device",
"list",
"with",
"just",
"our",
"own",
"deviceId",
"in",
"it",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L712-L718 |
26,620 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getOwnJid | public BareJid getOwnJid() {
if (ownJid == null && connection().isAuthenticated()) {
ownJid = connection().getUser().asBareJid();
}
return ownJid;
} | java | public BareJid getOwnJid() {
if (ownJid == null && connection().isAuthenticated()) {
ownJid = connection().getUser().asBareJid();
}
return ownJid;
} | [
"public",
"BareJid",
"getOwnJid",
"(",
")",
"{",
"if",
"(",
"ownJid",
"==",
"null",
"&&",
"connection",
"(",
")",
".",
"isAuthenticated",
"(",
")",
")",
"{",
"ownJid",
"=",
"connection",
"(",
")",
".",
"getUser",
"(",
")",
".",
"asBareJid",
"(",
")",
";",
"}",
"return",
"ownJid",
";",
"}"
] | Return the BareJid of the user.
@return bareJid | [
"Return",
"the",
"BareJid",
"of",
"the",
"user",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L780-L786 |
26,621 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.getOwnDevice | public OmemoDevice getOwnDevice() {
synchronized (LOCK) {
BareJid jid = getOwnJid();
if (jid == null) {
return null;
}
return new OmemoDevice(jid, getDeviceId());
}
} | java | public OmemoDevice getOwnDevice() {
synchronized (LOCK) {
BareJid jid = getOwnJid();
if (jid == null) {
return null;
}
return new OmemoDevice(jid, getDeviceId());
}
} | [
"public",
"OmemoDevice",
"getOwnDevice",
"(",
")",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"BareJid",
"jid",
"=",
"getOwnJid",
"(",
")",
";",
"if",
"(",
"jid",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"return",
"new",
"OmemoDevice",
"(",
"jid",
",",
"getDeviceId",
"(",
")",
")",
";",
"}",
"}"
] | Return the OmemoDevice of the user.
@return omemoDevice | [
"Return",
"the",
"OmemoDevice",
"of",
"the",
"user",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L804-L812 |
26,622 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.setDeviceId | void setDeviceId(int nDeviceId) {
synchronized (LOCK) {
// Move this instance inside the HashMaps
INSTANCES.get(connection()).remove(getDeviceId());
INSTANCES.get(connection()).put(nDeviceId, this);
this.deviceId = nDeviceId;
}
} | java | void setDeviceId(int nDeviceId) {
synchronized (LOCK) {
// Move this instance inside the HashMaps
INSTANCES.get(connection()).remove(getDeviceId());
INSTANCES.get(connection()).put(nDeviceId, this);
this.deviceId = nDeviceId;
}
} | [
"void",
"setDeviceId",
"(",
"int",
"nDeviceId",
")",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"// Move this instance inside the HashMaps",
"INSTANCES",
".",
"get",
"(",
"connection",
"(",
")",
")",
".",
"remove",
"(",
"getDeviceId",
"(",
")",
")",
";",
"INSTANCES",
".",
"get",
"(",
"connection",
"(",
")",
")",
".",
"put",
"(",
"nDeviceId",
",",
"this",
")",
";",
"this",
".",
"deviceId",
"=",
"nDeviceId",
";",
"}",
"}"
] | Set the deviceId of the manager to nDeviceId.
@param nDeviceId new deviceId | [
"Set",
"the",
"deviceId",
"of",
"the",
"manager",
"to",
"nDeviceId",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L818-L826 |
26,623 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.notifyOmemoMessageReceived | void notifyOmemoMessageReceived(Stanza stanza, OmemoMessage.Received decryptedMessage) {
for (OmemoMessageListener l : omemoMessageListeners) {
l.onOmemoMessageReceived(stanza, decryptedMessage);
}
} | java | void notifyOmemoMessageReceived(Stanza stanza, OmemoMessage.Received decryptedMessage) {
for (OmemoMessageListener l : omemoMessageListeners) {
l.onOmemoMessageReceived(stanza, decryptedMessage);
}
} | [
"void",
"notifyOmemoMessageReceived",
"(",
"Stanza",
"stanza",
",",
"OmemoMessage",
".",
"Received",
"decryptedMessage",
")",
"{",
"for",
"(",
"OmemoMessageListener",
"l",
":",
"omemoMessageListeners",
")",
"{",
"l",
".",
"onOmemoMessageReceived",
"(",
"stanza",
",",
"decryptedMessage",
")",
";",
"}",
"}"
] | Notify all registered OmemoMessageListeners about a received OmemoMessage.
@param stanza original stanza
@param decryptedMessage decrypted OmemoMessage. | [
"Notify",
"all",
"registered",
"OmemoMessageListeners",
"about",
"a",
"received",
"OmemoMessage",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L834-L838 |
26,624 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.notifyOmemoMucMessageReceived | void notifyOmemoMucMessageReceived(MultiUserChat muc,
Stanza stanza,
OmemoMessage.Received decryptedMessage) {
for (OmemoMucMessageListener l : omemoMucMessageListeners) {
l.onOmemoMucMessageReceived(muc, stanza, decryptedMessage);
}
} | java | void notifyOmemoMucMessageReceived(MultiUserChat muc,
Stanza stanza,
OmemoMessage.Received decryptedMessage) {
for (OmemoMucMessageListener l : omemoMucMessageListeners) {
l.onOmemoMucMessageReceived(muc, stanza, decryptedMessage);
}
} | [
"void",
"notifyOmemoMucMessageReceived",
"(",
"MultiUserChat",
"muc",
",",
"Stanza",
"stanza",
",",
"OmemoMessage",
".",
"Received",
"decryptedMessage",
")",
"{",
"for",
"(",
"OmemoMucMessageListener",
"l",
":",
"omemoMucMessageListeners",
")",
"{",
"l",
".",
"onOmemoMucMessageReceived",
"(",
"muc",
",",
"stanza",
",",
"decryptedMessage",
")",
";",
"}",
"}"
] | Notify all registered OmemoMucMessageListeners of an incoming OmemoMessageElement in a MUC.
@param muc MultiUserChat the message was received in.
@param stanza Original Stanza.
@param decryptedMessage Decrypted OmemoMessage. | [
"Notify",
"all",
"registered",
"OmemoMucMessageListeners",
"of",
"an",
"incoming",
"OmemoMessageElement",
"in",
"a",
"MUC",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L847-L853 |
26,625 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.stopStanzaAndPEPListeners | public void stopStanzaAndPEPListeners() {
PepManager.getInstanceFor(connection()).removePepListener(deviceListUpdateListener);
connection().removeAsyncStanzaListener(internalOmemoMessageStanzaListener);
CarbonManager.getInstanceFor(connection()).removeCarbonCopyReceivedListener(internalOmemoCarbonCopyListener);
} | java | public void stopStanzaAndPEPListeners() {
PepManager.getInstanceFor(connection()).removePepListener(deviceListUpdateListener);
connection().removeAsyncStanzaListener(internalOmemoMessageStanzaListener);
CarbonManager.getInstanceFor(connection()).removeCarbonCopyReceivedListener(internalOmemoCarbonCopyListener);
} | [
"public",
"void",
"stopStanzaAndPEPListeners",
"(",
")",
"{",
"PepManager",
".",
"getInstanceFor",
"(",
"connection",
"(",
")",
")",
".",
"removePepListener",
"(",
"deviceListUpdateListener",
")",
";",
"connection",
"(",
")",
".",
"removeAsyncStanzaListener",
"(",
"internalOmemoMessageStanzaListener",
")",
";",
"CarbonManager",
".",
"getInstanceFor",
"(",
"connection",
"(",
")",
")",
".",
"removeCarbonCopyReceivedListener",
"(",
"internalOmemoCarbonCopyListener",
")",
";",
"}"
] | Remove active stanza listeners needed for OMEMO. | [
"Remove",
"active",
"stanza",
"listeners",
"needed",
"for",
"OMEMO",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L897-L901 |
26,626 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.rebuildSessionWith | public void rebuildSessionWith(OmemoDevice contactsDevice)
throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException,
SmackException.NotConnectedException, CannotEstablishOmemoSessionException,
SmackException.NotLoggedInException {
if (!connection().isAuthenticated()) {
throw new SmackException.NotLoggedInException();
}
getOmemoService().buildFreshSessionWithDevice(connection(), getOwnDevice(), contactsDevice);
} | java | public void rebuildSessionWith(OmemoDevice contactsDevice)
throws InterruptedException, SmackException.NoResponseException, CorruptedOmemoKeyException,
SmackException.NotConnectedException, CannotEstablishOmemoSessionException,
SmackException.NotLoggedInException {
if (!connection().isAuthenticated()) {
throw new SmackException.NotLoggedInException();
}
getOmemoService().buildFreshSessionWithDevice(connection(), getOwnDevice(), contactsDevice);
} | [
"public",
"void",
"rebuildSessionWith",
"(",
"OmemoDevice",
"contactsDevice",
")",
"throws",
"InterruptedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"CorruptedOmemoKeyException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"CannotEstablishOmemoSessionException",
",",
"SmackException",
".",
"NotLoggedInException",
"{",
"if",
"(",
"!",
"connection",
"(",
")",
".",
"isAuthenticated",
"(",
")",
")",
"{",
"throw",
"new",
"SmackException",
".",
"NotLoggedInException",
"(",
")",
";",
"}",
"getOmemoService",
"(",
")",
".",
"buildFreshSessionWithDevice",
"(",
"connection",
"(",
")",
",",
"getOwnDevice",
"(",
")",
",",
"contactsDevice",
")",
";",
"}"
] | Build a fresh session with a contacts device.
This might come in handy if a session is broken.
@param contactsDevice OmemoDevice of a contact.
@throws InterruptedException
@throws SmackException.NoResponseException
@throws CorruptedOmemoKeyException if our or their identityKey is corrupted.
@throws SmackException.NotConnectedException
@throws CannotEstablishOmemoSessionException if no new session can be established.
@throws SmackException.NotLoggedInException if the connection is not authenticated. | [
"Build",
"a",
"fresh",
"session",
"with",
"a",
"contacts",
"device",
".",
"This",
"might",
"come",
"in",
"handy",
"if",
"a",
"session",
"is",
"broken",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L916-L924 |
26,627 | igniterealtime/Smack | smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java | OmemoManager.initBareJidAndDeviceId | private static void initBareJidAndDeviceId(OmemoManager manager) {
if (!manager.getConnection().isAuthenticated()) {
throw new IllegalStateException("Connection MUST be authenticated.");
}
if (manager.ownJid == null) {
manager.ownJid = manager.getConnection().getUser().asBareJid();
}
if (UNKNOWN_DEVICE_ID.equals(manager.deviceId)) {
SortedSet<Integer> storedDeviceIds = manager.getOmemoService().getOmemoStoreBackend().localDeviceIdsOf(manager.ownJid);
if (storedDeviceIds.size() > 0) {
manager.setDeviceId(storedDeviceIds.first());
} else {
manager.setDeviceId(randomDeviceId());
}
}
} | java | private static void initBareJidAndDeviceId(OmemoManager manager) {
if (!manager.getConnection().isAuthenticated()) {
throw new IllegalStateException("Connection MUST be authenticated.");
}
if (manager.ownJid == null) {
manager.ownJid = manager.getConnection().getUser().asBareJid();
}
if (UNKNOWN_DEVICE_ID.equals(manager.deviceId)) {
SortedSet<Integer> storedDeviceIds = manager.getOmemoService().getOmemoStoreBackend().localDeviceIdsOf(manager.ownJid);
if (storedDeviceIds.size() > 0) {
manager.setDeviceId(storedDeviceIds.first());
} else {
manager.setDeviceId(randomDeviceId());
}
}
} | [
"private",
"static",
"void",
"initBareJidAndDeviceId",
"(",
"OmemoManager",
"manager",
")",
"{",
"if",
"(",
"!",
"manager",
".",
"getConnection",
"(",
")",
".",
"isAuthenticated",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Connection MUST be authenticated.\"",
")",
";",
"}",
"if",
"(",
"manager",
".",
"ownJid",
"==",
"null",
")",
"{",
"manager",
".",
"ownJid",
"=",
"manager",
".",
"getConnection",
"(",
")",
".",
"getUser",
"(",
")",
".",
"asBareJid",
"(",
")",
";",
"}",
"if",
"(",
"UNKNOWN_DEVICE_ID",
".",
"equals",
"(",
"manager",
".",
"deviceId",
")",
")",
"{",
"SortedSet",
"<",
"Integer",
">",
"storedDeviceIds",
"=",
"manager",
".",
"getOmemoService",
"(",
")",
".",
"getOmemoStoreBackend",
"(",
")",
".",
"localDeviceIdsOf",
"(",
"manager",
".",
"ownJid",
")",
";",
"if",
"(",
"storedDeviceIds",
".",
"size",
"(",
")",
">",
"0",
")",
"{",
"manager",
".",
"setDeviceId",
"(",
"storedDeviceIds",
".",
"first",
"(",
")",
")",
";",
"}",
"else",
"{",
"manager",
".",
"setDeviceId",
"(",
"randomDeviceId",
"(",
")",
")",
";",
"}",
"}",
"}"
] | Get the bareJid of the user from the authenticated XMPP connection.
If our deviceId is unknown, use the bareJid to look up deviceIds available in the omemoStore.
If there are ids available, choose the smallest one. Otherwise generate a random deviceId.
@param manager OmemoManager | [
"Get",
"the",
"bareJid",
"of",
"the",
"user",
"from",
"the",
"authenticated",
"XMPP",
"connection",
".",
"If",
"our",
"deviceId",
"is",
"unknown",
"use",
"the",
"bareJid",
"to",
"look",
"up",
"deviceIds",
"available",
"in",
"the",
"omemoStore",
".",
"If",
"there",
"are",
"ids",
"available",
"choose",
"the",
"smallest",
"one",
".",
"Otherwise",
"generate",
"a",
"random",
"deviceId",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-omemo/src/main/java/org/jivesoftware/smackx/omemo/OmemoManager.java#L1108-L1125 |
26,628 | igniterealtime/Smack | smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java | EnhancedDebuggerWindow.showNewDebugger | private void showNewDebugger(EnhancedDebugger debugger) {
if (frame == null) {
createDebug();
}
debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getComponentCount());
tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1);
tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
frame.setTitle(
"Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1));
// Keep the added debugger for later access
debuggers.add(debugger);
} | java | private void showNewDebugger(EnhancedDebugger debugger) {
if (frame == null) {
createDebug();
}
debugger.tabbedPane.setName("XMPPConnection_" + tabbedPane.getComponentCount());
tabbedPane.add(debugger.tabbedPane, tabbedPane.getComponentCount() - 1);
tabbedPane.setIconAt(tabbedPane.indexOfComponent(debugger.tabbedPane), connectionCreatedIcon);
frame.setTitle(
"Smack Debug Window -- Total connections: " + (tabbedPane.getComponentCount() - 1));
// Keep the added debugger for later access
debuggers.add(debugger);
} | [
"private",
"void",
"showNewDebugger",
"(",
"EnhancedDebugger",
"debugger",
")",
"{",
"if",
"(",
"frame",
"==",
"null",
")",
"{",
"createDebug",
"(",
")",
";",
"}",
"debugger",
".",
"tabbedPane",
".",
"setName",
"(",
"\"XMPPConnection_\"",
"+",
"tabbedPane",
".",
"getComponentCount",
"(",
")",
")",
";",
"tabbedPane",
".",
"add",
"(",
"debugger",
".",
"tabbedPane",
",",
"tabbedPane",
".",
"getComponentCount",
"(",
")",
"-",
"1",
")",
";",
"tabbedPane",
".",
"setIconAt",
"(",
"tabbedPane",
".",
"indexOfComponent",
"(",
"debugger",
".",
"tabbedPane",
")",
",",
"connectionCreatedIcon",
")",
";",
"frame",
".",
"setTitle",
"(",
"\"Smack Debug Window -- Total connections: \"",
"+",
"(",
"tabbedPane",
".",
"getComponentCount",
"(",
")",
"-",
"1",
")",
")",
";",
"// Keep the added debugger for later access",
"debuggers",
".",
"add",
"(",
"debugger",
")",
";",
"}"
] | Shows the new debugger in the debug window.
@param debugger the new debugger to show | [
"Shows",
"the",
"new",
"debugger",
"in",
"the",
"debug",
"window",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java#L139-L150 |
26,629 | igniterealtime/Smack | smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java | EnhancedDebuggerWindow.userHasLogged | static synchronized void userHasLogged(EnhancedDebugger debugger, String user) {
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
getInstance().tabbedPane.setTitleAt(
index,
user);
getInstance().tabbedPane.setIconAt(
index,
connectionActiveIcon);
} | java | static synchronized void userHasLogged(EnhancedDebugger debugger, String user) {
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
getInstance().tabbedPane.setTitleAt(
index,
user);
getInstance().tabbedPane.setIconAt(
index,
connectionActiveIcon);
} | [
"static",
"synchronized",
"void",
"userHasLogged",
"(",
"EnhancedDebugger",
"debugger",
",",
"String",
"user",
")",
"{",
"int",
"index",
"=",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"indexOfComponent",
"(",
"debugger",
".",
"tabbedPane",
")",
";",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"setTitleAt",
"(",
"index",
",",
"user",
")",
";",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"setIconAt",
"(",
"index",
",",
"connectionActiveIcon",
")",
";",
"}"
] | Notification that a user has logged in to the server. A new title will be set
to the tab of the given debugger.
@param debugger the debugger whose connection logged in to the server
@param user the user@host/resource that has just logged in | [
"Notification",
"that",
"a",
"user",
"has",
"logged",
"in",
"to",
"the",
"server",
".",
"A",
"new",
"title",
"will",
"be",
"set",
"to",
"the",
"tab",
"of",
"the",
"given",
"debugger",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java#L159-L167 |
26,630 | igniterealtime/Smack | smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java | EnhancedDebuggerWindow.connectionClosed | static synchronized void connectionClosed(EnhancedDebugger debugger) {
getInstance().tabbedPane.setIconAt(
getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane),
connectionClosedIcon);
} | java | static synchronized void connectionClosed(EnhancedDebugger debugger) {
getInstance().tabbedPane.setIconAt(
getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane),
connectionClosedIcon);
} | [
"static",
"synchronized",
"void",
"connectionClosed",
"(",
"EnhancedDebugger",
"debugger",
")",
"{",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"setIconAt",
"(",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"indexOfComponent",
"(",
"debugger",
".",
"tabbedPane",
")",
",",
"connectionClosedIcon",
")",
";",
"}"
] | Notification that the connection was properly closed.
@param debugger the debugger whose connection was properly closed. | [
"Notification",
"that",
"the",
"connection",
"was",
"properly",
"closed",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java#L174-L178 |
26,631 | igniterealtime/Smack | smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java | EnhancedDebuggerWindow.connectionClosedOnError | static synchronized void connectionClosedOnError(EnhancedDebugger debugger, Exception e) {
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
getInstance().tabbedPane.setToolTipTextAt(
index,
"XMPPConnection closed due to the exception: " + e.getMessage());
getInstance().tabbedPane.setIconAt(
index,
connectionClosedOnErrorIcon);
} | java | static synchronized void connectionClosedOnError(EnhancedDebugger debugger, Exception e) {
int index = getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane);
getInstance().tabbedPane.setToolTipTextAt(
index,
"XMPPConnection closed due to the exception: " + e.getMessage());
getInstance().tabbedPane.setIconAt(
index,
connectionClosedOnErrorIcon);
} | [
"static",
"synchronized",
"void",
"connectionClosedOnError",
"(",
"EnhancedDebugger",
"debugger",
",",
"Exception",
"e",
")",
"{",
"int",
"index",
"=",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"indexOfComponent",
"(",
"debugger",
".",
"tabbedPane",
")",
";",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"setToolTipTextAt",
"(",
"index",
",",
"\"XMPPConnection closed due to the exception: \"",
"+",
"e",
".",
"getMessage",
"(",
")",
")",
";",
"getInstance",
"(",
")",
".",
"tabbedPane",
".",
"setIconAt",
"(",
"index",
",",
"connectionClosedOnErrorIcon",
")",
";",
"}"
] | Notification that the connection was closed due to an exception.
@param debugger the debugger whose connection was closed due to an exception.
@param e the exception. | [
"Notification",
"that",
"the",
"connection",
"was",
"closed",
"due",
"to",
"an",
"exception",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java#L186-L194 |
26,632 | igniterealtime/Smack | smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java | EnhancedDebuggerWindow.rootWindowClosing | private synchronized void rootWindowClosing(WindowEvent evt) {
// Notify to all the debuggers to stop debugging
for (EnhancedDebugger debugger : debuggers) {
debugger.cancel();
}
// Release any reference to the debuggers
debuggers.clear();
// Release the default instance
instance = null;
frame = null;
notifyAll();
} | java | private synchronized void rootWindowClosing(WindowEvent evt) {
// Notify to all the debuggers to stop debugging
for (EnhancedDebugger debugger : debuggers) {
debugger.cancel();
}
// Release any reference to the debuggers
debuggers.clear();
// Release the default instance
instance = null;
frame = null;
notifyAll();
} | [
"private",
"synchronized",
"void",
"rootWindowClosing",
"(",
"WindowEvent",
"evt",
")",
"{",
"// Notify to all the debuggers to stop debugging",
"for",
"(",
"EnhancedDebugger",
"debugger",
":",
"debuggers",
")",
"{",
"debugger",
".",
"cancel",
"(",
")",
";",
"}",
"// Release any reference to the debuggers",
"debuggers",
".",
"clear",
"(",
")",
";",
"// Release the default instance",
"instance",
"=",
"null",
";",
"frame",
"=",
"null",
";",
"notifyAll",
"(",
")",
";",
"}"
] | Notification that the root window is closing. Stop listening for received and
transmitted packets in all the debugged connections.
@param evt the event that indicates that the root window is closing | [
"Notification",
"that",
"the",
"root",
"window",
"is",
"closing",
".",
"Stop",
"listening",
"for",
"received",
"and",
"transmitted",
"packets",
"in",
"all",
"the",
"debugged",
"connections",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java#L349-L360 |
26,633 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java | MucConfigFormManager.setRoomOwners | public MucConfigFormManager setRoomOwners(Collection<? extends Jid> newOwners) throws MucConfigurationNotSupportedException {
if (!supportsRoomOwners()) {
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_ROOMOWNERS);
}
owners.clear();
owners.addAll(newOwners);
return this;
} | java | public MucConfigFormManager setRoomOwners(Collection<? extends Jid> newOwners) throws MucConfigurationNotSupportedException {
if (!supportsRoomOwners()) {
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_ROOMOWNERS);
}
owners.clear();
owners.addAll(newOwners);
return this;
} | [
"public",
"MucConfigFormManager",
"setRoomOwners",
"(",
"Collection",
"<",
"?",
"extends",
"Jid",
">",
"newOwners",
")",
"throws",
"MucConfigurationNotSupportedException",
"{",
"if",
"(",
"!",
"supportsRoomOwners",
"(",
")",
")",
"{",
"throw",
"new",
"MucConfigurationNotSupportedException",
"(",
"MUC_ROOMCONFIG_ROOMOWNERS",
")",
";",
"}",
"owners",
".",
"clear",
"(",
")",
";",
"owners",
".",
"addAll",
"(",
"newOwners",
")",
";",
"return",
"this",
";",
"}"
] | Set the owners of the room.
@param newOwners a collection of JIDs to become the new owners of the room.
@return a reference to this object.
@throws MucConfigurationNotSupportedException if the MUC service does not support this option.
@see #MUC_ROOMCONFIG_ROOMOWNERS | [
"Set",
"the",
"owners",
"of",
"the",
"room",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java#L137-L144 |
26,634 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java | MucConfigFormManager.setMembersOnly | public MucConfigFormManager setMembersOnly(boolean isMembersOnly) throws MucConfigurationNotSupportedException {
if (!supportsMembersOnly()) {
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_MEMBERSONLY);
}
answerForm.setAnswer(MUC_ROOMCONFIG_MEMBERSONLY, isMembersOnly);
return this;
} | java | public MucConfigFormManager setMembersOnly(boolean isMembersOnly) throws MucConfigurationNotSupportedException {
if (!supportsMembersOnly()) {
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_MEMBERSONLY);
}
answerForm.setAnswer(MUC_ROOMCONFIG_MEMBERSONLY, isMembersOnly);
return this;
} | [
"public",
"MucConfigFormManager",
"setMembersOnly",
"(",
"boolean",
"isMembersOnly",
")",
"throws",
"MucConfigurationNotSupportedException",
"{",
"if",
"(",
"!",
"supportsMembersOnly",
"(",
")",
")",
"{",
"throw",
"new",
"MucConfigurationNotSupportedException",
"(",
"MUC_ROOMCONFIG_MEMBERSONLY",
")",
";",
"}",
"answerForm",
".",
"setAnswer",
"(",
"MUC_ROOMCONFIG_MEMBERSONLY",
",",
"isMembersOnly",
")",
";",
"return",
"this",
";",
"}"
] | Set if the room is members only. Rooms are not members only per default.
@param isMembersOnly if the room should be members only.
@return a reference to this object.
@throws MucConfigurationNotSupportedException | [
"Set",
"if",
"the",
"room",
"is",
"members",
"only",
".",
"Rooms",
"are",
"not",
"members",
"only",
"per",
"default",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java#L172-L178 |
26,635 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java | MucConfigFormManager.setIsPasswordProtected | public MucConfigFormManager setIsPasswordProtected(boolean isPasswordProtected)
throws MucConfigurationNotSupportedException {
if (!supportsMembersOnly()) {
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM);
}
answerForm.setAnswer(MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM, isPasswordProtected);
return this;
} | java | public MucConfigFormManager setIsPasswordProtected(boolean isPasswordProtected)
throws MucConfigurationNotSupportedException {
if (!supportsMembersOnly()) {
throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM);
}
answerForm.setAnswer(MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM, isPasswordProtected);
return this;
} | [
"public",
"MucConfigFormManager",
"setIsPasswordProtected",
"(",
"boolean",
"isPasswordProtected",
")",
"throws",
"MucConfigurationNotSupportedException",
"{",
"if",
"(",
"!",
"supportsMembersOnly",
"(",
")",
")",
"{",
"throw",
"new",
"MucConfigurationNotSupportedException",
"(",
"MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM",
")",
";",
"}",
"answerForm",
".",
"setAnswer",
"(",
"MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM",
",",
"isPasswordProtected",
")",
";",
"return",
"this",
";",
"}"
] | Set if this room is password protected. Rooms are by default not password protected.
@param isPasswordProtected
@return a reference to this object.
@throws MucConfigurationNotSupportedException | [
"Set",
"if",
"this",
"room",
"is",
"password",
"protected",
".",
"Rooms",
"are",
"by",
"default",
"not",
"password",
"protected",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/muc/MucConfigFormManager.java#L219-L226 |
26,636 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java | STUN.getSTUNServer | @SuppressWarnings("deprecation")
public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
return null;
}
STUN stunPacket = new STUN();
stunPacket.setTo(DOMAIN + "." + connection.getXMPPServiceDomain());
StanzaCollector collector = connection.createStanzaCollectorAndSend(stunPacket);
STUN response = collector.nextResult();
// Cancel the collector.
collector.cancel();
return response;
} | java | @SuppressWarnings("deprecation")
public static STUN getSTUNServer(XMPPConnection connection) throws NotConnectedException, InterruptedException {
if (!connection.isConnected()) {
return null;
}
STUN stunPacket = new STUN();
stunPacket.setTo(DOMAIN + "." + connection.getXMPPServiceDomain());
StanzaCollector collector = connection.createStanzaCollectorAndSend(stunPacket);
STUN response = collector.nextResult();
// Cancel the collector.
collector.cancel();
return response;
} | [
"@",
"SuppressWarnings",
"(",
"\"deprecation\"",
")",
"public",
"static",
"STUN",
"getSTUNServer",
"(",
"XMPPConnection",
"connection",
")",
"throws",
"NotConnectedException",
",",
"InterruptedException",
"{",
"if",
"(",
"!",
"connection",
".",
"isConnected",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"STUN",
"stunPacket",
"=",
"new",
"STUN",
"(",
")",
";",
"stunPacket",
".",
"setTo",
"(",
"DOMAIN",
"+",
"\".\"",
"+",
"connection",
".",
"getXMPPServiceDomain",
"(",
")",
")",
";",
"StanzaCollector",
"collector",
"=",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"stunPacket",
")",
";",
"STUN",
"response",
"=",
"collector",
".",
"nextResult",
"(",
")",
";",
"// Cancel the collector.",
"collector",
".",
"cancel",
"(",
")",
";",
"return",
"response",
";",
"}"
] | Get a new STUN Server Address and port from the server.
If a error occurs or the server don't support STUN Service, null is returned.
@param connection
@return the STUN server address
@throws NotConnectedException
@throws InterruptedException | [
"Get",
"a",
"new",
"STUN",
"Server",
"Address",
"and",
"port",
"from",
"the",
"server",
".",
"If",
"a",
"error",
"occurs",
"or",
"the",
"server",
"don",
"t",
"support",
"STUN",
"Service",
"null",
"is",
"returned",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java#L181-L199 |
26,637 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java | STUN.serviceAvailable | public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, InterruptedException {
if (!connection.isConnected()) {
return false;
}
LOGGER.fine("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain());
for (DiscoverItems.Item item : items.getItems()) {
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
for (DiscoverInfo.Identity identity : info.getIdentities()) {
if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
if (info.containsFeature(NAMESPACE))
return true;
}
LOGGER.fine(item.getName() + "-" + info.getType());
}
return false;
} | java | public static boolean serviceAvailable(XMPPConnection connection) throws XMPPException, SmackException, InterruptedException {
if (!connection.isConnected()) {
return false;
}
LOGGER.fine("Service listing");
ServiceDiscoveryManager disco = ServiceDiscoveryManager.getInstanceFor(connection);
DiscoverItems items = disco.discoverItems(connection.getXMPPServiceDomain());
for (DiscoverItems.Item item : items.getItems()) {
DiscoverInfo info = disco.discoverInfo(item.getEntityID());
for (DiscoverInfo.Identity identity : info.getIdentities()) {
if (identity.getCategory().equals("proxy") && identity.getType().equals("stun"))
if (info.containsFeature(NAMESPACE))
return true;
}
LOGGER.fine(item.getName() + "-" + info.getType());
}
return false;
} | [
"public",
"static",
"boolean",
"serviceAvailable",
"(",
"XMPPConnection",
"connection",
")",
"throws",
"XMPPException",
",",
"SmackException",
",",
"InterruptedException",
"{",
"if",
"(",
"!",
"connection",
".",
"isConnected",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"LOGGER",
".",
"fine",
"(",
"\"Service listing\"",
")",
";",
"ServiceDiscoveryManager",
"disco",
"=",
"ServiceDiscoveryManager",
".",
"getInstanceFor",
"(",
"connection",
")",
";",
"DiscoverItems",
"items",
"=",
"disco",
".",
"discoverItems",
"(",
"connection",
".",
"getXMPPServiceDomain",
"(",
")",
")",
";",
"for",
"(",
"DiscoverItems",
".",
"Item",
"item",
":",
"items",
".",
"getItems",
"(",
")",
")",
"{",
"DiscoverInfo",
"info",
"=",
"disco",
".",
"discoverInfo",
"(",
"item",
".",
"getEntityID",
"(",
")",
")",
";",
"for",
"(",
"DiscoverInfo",
".",
"Identity",
"identity",
":",
"info",
".",
"getIdentities",
"(",
")",
")",
"{",
"if",
"(",
"identity",
".",
"getCategory",
"(",
")",
".",
"equals",
"(",
"\"proxy\"",
")",
"&&",
"identity",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"\"stun\"",
")",
")",
"if",
"(",
"info",
".",
"containsFeature",
"(",
"NAMESPACE",
")",
")",
"return",
"true",
";",
"}",
"LOGGER",
".",
"fine",
"(",
"item",
".",
"getName",
"(",
")",
"+",
"\"-\"",
"+",
"info",
".",
"getType",
"(",
")",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Check if the server support STUN Service.
@param connection the connection
@return true if the server support STUN
@throws SmackException
@throws XMPPException
@throws InterruptedException | [
"Check",
"if",
"the",
"server",
"support",
"STUN",
"Service",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/STUN.java#L210-L235 |
26,638 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioMediaSession.java | AudioMediaSession.getFreePort | protected int getFreePort() {
ServerSocket ss;
int freePort = 0;
for (int i = 0; i < 10; i++) {
freePort = (int) (10000 + Math.round(Math.random() * 10000));
freePort = freePort % 2 == 0 ? freePort : freePort + 1;
try {
ss = new ServerSocket(freePort);
freePort = ss.getLocalPort();
ss.close();
return freePort;
}
catch (IOException e) {
LOGGER.log(Level.WARNING, "exception", e);
}
}
try {
ss = new ServerSocket(0);
freePort = ss.getLocalPort();
ss.close();
}
catch (IOException e) {
LOGGER.log(Level.WARNING, "exception", e);
}
return freePort;
} | java | protected int getFreePort() {
ServerSocket ss;
int freePort = 0;
for (int i = 0; i < 10; i++) {
freePort = (int) (10000 + Math.round(Math.random() * 10000));
freePort = freePort % 2 == 0 ? freePort : freePort + 1;
try {
ss = new ServerSocket(freePort);
freePort = ss.getLocalPort();
ss.close();
return freePort;
}
catch (IOException e) {
LOGGER.log(Level.WARNING, "exception", e);
}
}
try {
ss = new ServerSocket(0);
freePort = ss.getLocalPort();
ss.close();
}
catch (IOException e) {
LOGGER.log(Level.WARNING, "exception", e);
}
return freePort;
} | [
"protected",
"int",
"getFreePort",
"(",
")",
"{",
"ServerSocket",
"ss",
";",
"int",
"freePort",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"10",
";",
"i",
"++",
")",
"{",
"freePort",
"=",
"(",
"int",
")",
"(",
"10000",
"+",
"Math",
".",
"round",
"(",
"Math",
".",
"random",
"(",
")",
"*",
"10000",
")",
")",
";",
"freePort",
"=",
"freePort",
"%",
"2",
"==",
"0",
"?",
"freePort",
":",
"freePort",
"+",
"1",
";",
"try",
"{",
"ss",
"=",
"new",
"ServerSocket",
"(",
"freePort",
")",
";",
"freePort",
"=",
"ss",
".",
"getLocalPort",
"(",
")",
";",
"ss",
".",
"close",
"(",
")",
";",
"return",
"freePort",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"exception\"",
",",
"e",
")",
";",
"}",
"}",
"try",
"{",
"ss",
"=",
"new",
"ServerSocket",
"(",
"0",
")",
";",
"freePort",
"=",
"ss",
".",
"getLocalPort",
"(",
")",
";",
"ss",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"WARNING",
",",
"\"exception\"",
",",
"e",
")",
";",
"}",
"return",
"freePort",
";",
"}"
] | Obtain a free port we can use.
@return A free port number. | [
"Obtain",
"a",
"free",
"port",
"we",
"can",
"use",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/AudioMediaSession.java#L172-L198 |
26,639 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.setField | public void setField(String field, String value, boolean isUnescapable) {
if (!isUnescapable) {
otherSimpleFields.put(field, value);
}
else {
otherUnescapableFields.put(field, value);
}
} | java | public void setField(String field, String value, boolean isUnescapable) {
if (!isUnescapable) {
otherSimpleFields.put(field, value);
}
else {
otherUnescapableFields.put(field, value);
}
} | [
"public",
"void",
"setField",
"(",
"String",
"field",
",",
"String",
"value",
",",
"boolean",
"isUnescapable",
")",
"{",
"if",
"(",
"!",
"isUnescapable",
")",
"{",
"otherSimpleFields",
".",
"put",
"(",
"field",
",",
"value",
")",
";",
"}",
"else",
"{",
"otherUnescapableFields",
".",
"put",
"(",
"field",
",",
"value",
")",
";",
"}",
"}"
] | Set generic, unescapable VCard field. If unescapable is set to true, XML maybe a part of the
value.
@param value value of field
@param field field to set. See {@link #getField(String)}
@param isUnescapable True if the value should not be escaped, and false if it should. | [
"Set",
"generic",
"unescapable",
"VCard",
"field",
".",
"If",
"unescapable",
"is",
"set",
"to",
"true",
"XML",
"maybe",
"a",
"part",
"of",
"the",
"value",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L167-L174 |
26,640 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.setAvatar | public void setAvatar(URL avatarURL) {
byte[] bytes = new byte[0];
try {
bytes = getBytes(avatarURL);
}
catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error getting bytes from URL: " + avatarURL, e);
}
setAvatar(bytes);
} | java | public void setAvatar(URL avatarURL) {
byte[] bytes = new byte[0];
try {
bytes = getBytes(avatarURL);
}
catch (IOException e) {
LOGGER.log(Level.SEVERE, "Error getting bytes from URL: " + avatarURL, e);
}
setAvatar(bytes);
} | [
"public",
"void",
"setAvatar",
"(",
"URL",
"avatarURL",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"new",
"byte",
"[",
"0",
"]",
";",
"try",
"{",
"bytes",
"=",
"getBytes",
"(",
"avatarURL",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Error getting bytes from URL: \"",
"+",
"avatarURL",
",",
"e",
")",
";",
"}",
"setAvatar",
"(",
"bytes",
")",
";",
"}"
] | Set the avatar for the VCard by specifying the url to the image.
@param avatarURL the url to the image(png,jpeg,gif,bmp) | [
"Set",
"the",
"avatar",
"for",
"the",
"VCard",
"by",
"specifying",
"the",
"url",
"to",
"the",
"image",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L362-L372 |
26,641 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.setAvatar | public void setAvatar(byte[] bytes, String mimeType) {
// If bytes is null, remove the avatar
if (bytes == null) {
removeAvatar();
return;
}
// Otherwise, add to mappings.
String encodedImage = Base64.encodeToString(bytes);
setAvatar(encodedImage, mimeType);
} | java | public void setAvatar(byte[] bytes, String mimeType) {
// If bytes is null, remove the avatar
if (bytes == null) {
removeAvatar();
return;
}
// Otherwise, add to mappings.
String encodedImage = Base64.encodeToString(bytes);
setAvatar(encodedImage, mimeType);
} | [
"public",
"void",
"setAvatar",
"(",
"byte",
"[",
"]",
"bytes",
",",
"String",
"mimeType",
")",
"{",
"// If bytes is null, remove the avatar",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"removeAvatar",
"(",
")",
";",
"return",
";",
"}",
"// Otherwise, add to mappings.",
"String",
"encodedImage",
"=",
"Base64",
".",
"encodeToString",
"(",
"bytes",
")",
";",
"setAvatar",
"(",
"encodedImage",
",",
"mimeType",
")",
";",
"}"
] | Specify the bytes for the avatar to use as well as the mime type.
@param bytes the bytes of the avatar.
@param mimeType the mime type of the avatar. | [
"Specify",
"the",
"bytes",
"for",
"the",
"avatar",
"to",
"use",
"as",
"well",
"as",
"the",
"mime",
"type",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L402-L413 |
26,642 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.getBytes | public static byte[] getBytes(URL url) throws IOException {
final String path = url.getPath();
final File file = new File(path);
if (file.exists()) {
return getFileBytes(file);
}
return null;
} | java | public static byte[] getBytes(URL url) throws IOException {
final String path = url.getPath();
final File file = new File(path);
if (file.exists()) {
return getFileBytes(file);
}
return null;
} | [
"public",
"static",
"byte",
"[",
"]",
"getBytes",
"(",
"URL",
"url",
")",
"throws",
"IOException",
"{",
"final",
"String",
"path",
"=",
"url",
".",
"getPath",
"(",
")",
";",
"final",
"File",
"file",
"=",
"new",
"File",
"(",
"path",
")",
";",
"if",
"(",
"file",
".",
"exists",
"(",
")",
")",
"{",
"return",
"getFileBytes",
"(",
"file",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Common code for getting the bytes of a url.
@param url the url to read.
@return bytes of the file pointed to by URL.
@throws IOException if an IOException occurs while reading the file. | [
"Common",
"code",
"for",
"getting",
"the",
"bytes",
"of",
"a",
"url",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L483-L491 |
26,643 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.getAvatarHash | public String getAvatarHash() {
byte[] bytes = getAvatar();
if (bytes == null) {
return null;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-1");
}
catch (NoSuchAlgorithmException e) {
LOGGER.log(Level.SEVERE, "Failed to get message digest", e);
return null;
}
digest.update(bytes);
return StringUtils.encodeHex(digest.digest());
} | java | public String getAvatarHash() {
byte[] bytes = getAvatar();
if (bytes == null) {
return null;
}
MessageDigest digest;
try {
digest = MessageDigest.getInstance("SHA-1");
}
catch (NoSuchAlgorithmException e) {
LOGGER.log(Level.SEVERE, "Failed to get message digest", e);
return null;
}
digest.update(bytes);
return StringUtils.encodeHex(digest.digest());
} | [
"public",
"String",
"getAvatarHash",
"(",
")",
"{",
"byte",
"[",
"]",
"bytes",
"=",
"getAvatar",
"(",
")",
";",
"if",
"(",
"bytes",
"==",
"null",
")",
"{",
"return",
"null",
";",
"}",
"MessageDigest",
"digest",
";",
"try",
"{",
"digest",
"=",
"MessageDigest",
".",
"getInstance",
"(",
"\"SHA-1\"",
")",
";",
"}",
"catch",
"(",
"NoSuchAlgorithmException",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Failed to get message digest\"",
",",
"e",
")",
";",
"return",
"null",
";",
"}",
"digest",
".",
"update",
"(",
"bytes",
")",
";",
"return",
"StringUtils",
".",
"encodeHex",
"(",
"digest",
".",
"digest",
"(",
")",
")",
";",
"}"
] | Returns the SHA-1 Hash of the Avatar image.
@return the SHA-1 Hash of the Avatar image. | [
"Returns",
"the",
"SHA",
"-",
"1",
"Hash",
"of",
"the",
"Avatar",
"image",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L510-L527 |
26,644 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.load | @Deprecated
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
load(connection, null);
} | java | @Deprecated
public void load(XMPPConnection connection) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
load(connection, null);
} | [
"@",
"Deprecated",
"public",
"void",
"load",
"(",
"XMPPConnection",
"connection",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"load",
"(",
"connection",
",",
"null",
")",
";",
"}"
] | Load VCard information for a connected user. XMPPConnection should be authenticated
and not anonymous.
@param connection connection.
@throws XMPPErrorException
@throws NoResponseException
@throws NotConnectedException
@throws InterruptedException
@deprecated use {@link VCardManager#loadVCard()} instead. | [
"Load",
"VCard",
"information",
"for",
"a",
"connected",
"user",
".",
"XMPPConnection",
"should",
"be",
"authenticated",
"and",
"not",
"anonymous",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L570-L573 |
26,645 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java | VCard.load | @Deprecated
public void load(XMPPConnection connection, EntityBareJid user) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
VCard result = VCardManager.getInstanceFor(connection).loadVCard(user);
copyFieldsFrom(result);
} | java | @Deprecated
public void load(XMPPConnection connection, EntityBareJid user) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
VCard result = VCardManager.getInstanceFor(connection).loadVCard(user);
copyFieldsFrom(result);
} | [
"@",
"Deprecated",
"public",
"void",
"load",
"(",
"XMPPConnection",
"connection",
",",
"EntityBareJid",
"user",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"VCard",
"result",
"=",
"VCardManager",
".",
"getInstanceFor",
"(",
"connection",
")",
".",
"loadVCard",
"(",
"user",
")",
";",
"copyFieldsFrom",
"(",
"result",
")",
";",
"}"
] | Load VCard information for a given user. XMPPConnection should be authenticated and not anonymous.
@param connection connection.
@param user user whos information we want to load.
@throws XMPPErrorException
@throws NoResponseException if there was no response from the server.
@throws NotConnectedException
@throws InterruptedException
@deprecated use {@link VCardManager#loadVCard(EntityBareJid)} instead. | [
"Load",
"VCard",
"information",
"for",
"a",
"given",
"user",
".",
"XMPPConnection",
"should",
"be",
"authenticated",
"and",
"not",
"anonymous",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/vcardtemp/packet/VCard.java#L587-L591 |
26,646 | igniterealtime/Smack | smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/OpenPgpContact.java | OpenPgpContact.updateKeys | public void updateKeys(XMPPConnection connection) throws InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException,
PubSubException.NotAPubSubNodeException, IOException {
PublicKeysListElement metadata = OpenPgpPubSubUtil.fetchPubkeysList(connection, getJid());
if (metadata == null) {
return;
}
updateKeys(connection, metadata);
} | java | public void updateKeys(XMPPConnection connection) throws InterruptedException, SmackException.NotConnectedException,
SmackException.NoResponseException, XMPPException.XMPPErrorException, PubSubException.NotALeafNodeException,
PubSubException.NotAPubSubNodeException, IOException {
PublicKeysListElement metadata = OpenPgpPubSubUtil.fetchPubkeysList(connection, getJid());
if (metadata == null) {
return;
}
updateKeys(connection, metadata);
} | [
"public",
"void",
"updateKeys",
"(",
"XMPPConnection",
"connection",
")",
"throws",
"InterruptedException",
",",
"SmackException",
".",
"NotConnectedException",
",",
"SmackException",
".",
"NoResponseException",
",",
"XMPPException",
".",
"XMPPErrorException",
",",
"PubSubException",
".",
"NotALeafNodeException",
",",
"PubSubException",
".",
"NotAPubSubNodeException",
",",
"IOException",
"{",
"PublicKeysListElement",
"metadata",
"=",
"OpenPgpPubSubUtil",
".",
"fetchPubkeysList",
"(",
"connection",
",",
"getJid",
"(",
")",
")",
";",
"if",
"(",
"metadata",
"==",
"null",
")",
"{",
"return",
";",
"}",
"updateKeys",
"(",
"connection",
",",
"metadata",
")",
";",
"}"
] | Update the contacts keys by consulting the users PubSub nodes.
This method fetches the users metadata node and then tries to fetch any announced keys.
@param connection our {@link XMPPConnection}.
@throws InterruptedException In case the thread gets interrupted.
@throws SmackException.NotConnectedException in case the connection is not connected.
@throws SmackException.NoResponseException in case the server doesn't respond.
@throws XMPPException.XMPPErrorException in case of an XMPP protocol error.
@throws PubSubException.NotALeafNodeException in case the metadata node is not a {@link LeafNode}.
@throws PubSubException.NotAPubSubNodeException in case the metadata node is not a PubSub node.
@throws IOException IO is brittle. | [
"Update",
"the",
"contacts",
"keys",
"by",
"consulting",
"the",
"users",
"PubSub",
"nodes",
".",
"This",
"method",
"fetches",
"the",
"users",
"metadata",
"node",
"and",
"then",
"tries",
"to",
"fetch",
"any",
"announced",
"keys",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-openpgp/src/main/java/org/jivesoftware/smackx/ox/OpenPgpContact.java#L348-L357 |
26,647 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java | JmfMediaManager.setupPayloads | private void setupPayloads() {
payloads.add(new PayloadType.Audio(3, "gsm"));
payloads.add(new PayloadType.Audio(4, "g723"));
payloads.add(new PayloadType.Audio(0, "PCMU", 16000));
} | java | private void setupPayloads() {
payloads.add(new PayloadType.Audio(3, "gsm"));
payloads.add(new PayloadType.Audio(4, "g723"));
payloads.add(new PayloadType.Audio(0, "PCMU", 16000));
} | [
"private",
"void",
"setupPayloads",
"(",
")",
"{",
"payloads",
".",
"add",
"(",
"new",
"PayloadType",
".",
"Audio",
"(",
"3",
",",
"\"gsm\"",
")",
")",
";",
"payloads",
".",
"add",
"(",
"new",
"PayloadType",
".",
"Audio",
"(",
"4",
",",
"\"g723\"",
")",
")",
";",
"payloads",
".",
"add",
"(",
"new",
"PayloadType",
".",
"Audio",
"(",
"0",
",",
"\"PCMU\"",
",",
"16000",
")",
")",
";",
"}"
] | Setup API supported Payloads | [
"Setup",
"API",
"supported",
"Payloads"
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java#L86-L90 |
26,648 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java | JmfMediaManager.setupJMF | public static void setupJMF() {
// .jmf is the place where we store the jmf.properties file used
// by JMF. if the directory does not exist or it does not contain
// a jmf.properties file. or if the jmf.properties file has 0 length
// then this is the first time we're running and should continue to
// with JMFInit
String homeDir = System.getProperty("user.home");
File jmfDir = new File(homeDir, ".jmf");
String classpath = System.getProperty("java.class.path");
classpath += System.getProperty("path.separator")
+ jmfDir.getAbsolutePath();
System.setProperty("java.class.path", classpath);
if (!jmfDir.exists())
jmfDir.mkdir();
File jmfProperties = new File(jmfDir, "jmf.properties");
if (!jmfProperties.exists()) {
try {
jmfProperties.createNewFile();
}
catch (IOException ex) {
LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex);
}
}
// if we're running on linux checkout that libjmutil.so is where it
// should be and put it there.
runLinuxPreInstall();
// if (jmfProperties.length() == 0) {
new JMFInit(null, false);
// }
} | java | public static void setupJMF() {
// .jmf is the place where we store the jmf.properties file used
// by JMF. if the directory does not exist or it does not contain
// a jmf.properties file. or if the jmf.properties file has 0 length
// then this is the first time we're running and should continue to
// with JMFInit
String homeDir = System.getProperty("user.home");
File jmfDir = new File(homeDir, ".jmf");
String classpath = System.getProperty("java.class.path");
classpath += System.getProperty("path.separator")
+ jmfDir.getAbsolutePath();
System.setProperty("java.class.path", classpath);
if (!jmfDir.exists())
jmfDir.mkdir();
File jmfProperties = new File(jmfDir, "jmf.properties");
if (!jmfProperties.exists()) {
try {
jmfProperties.createNewFile();
}
catch (IOException ex) {
LOGGER.log(Level.FINE, "Failed to create jmf.properties", ex);
}
}
// if we're running on linux checkout that libjmutil.so is where it
// should be and put it there.
runLinuxPreInstall();
// if (jmfProperties.length() == 0) {
new JMFInit(null, false);
// }
} | [
"public",
"static",
"void",
"setupJMF",
"(",
")",
"{",
"// .jmf is the place where we store the jmf.properties file used",
"// by JMF. if the directory does not exist or it does not contain",
"// a jmf.properties file. or if the jmf.properties file has 0 length",
"// then this is the first time we're running and should continue to",
"// with JMFInit",
"String",
"homeDir",
"=",
"System",
".",
"getProperty",
"(",
"\"user.home\"",
")",
";",
"File",
"jmfDir",
"=",
"new",
"File",
"(",
"homeDir",
",",
"\".jmf\"",
")",
";",
"String",
"classpath",
"=",
"System",
".",
"getProperty",
"(",
"\"java.class.path\"",
")",
";",
"classpath",
"+=",
"System",
".",
"getProperty",
"(",
"\"path.separator\"",
")",
"+",
"jmfDir",
".",
"getAbsolutePath",
"(",
")",
";",
"System",
".",
"setProperty",
"(",
"\"java.class.path\"",
",",
"classpath",
")",
";",
"if",
"(",
"!",
"jmfDir",
".",
"exists",
"(",
")",
")",
"jmfDir",
".",
"mkdir",
"(",
")",
";",
"File",
"jmfProperties",
"=",
"new",
"File",
"(",
"jmfDir",
",",
"\"jmf.properties\"",
")",
";",
"if",
"(",
"!",
"jmfProperties",
".",
"exists",
"(",
")",
")",
"{",
"try",
"{",
"jmfProperties",
".",
"createNewFile",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"ex",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"FINE",
",",
"\"Failed to create jmf.properties\"",
",",
"ex",
")",
";",
"}",
"}",
"// if we're running on linux checkout that libjmutil.so is where it",
"// should be and put it there.",
"runLinuxPreInstall",
"(",
")",
";",
"// if (jmfProperties.length() == 0) {",
"new",
"JMFInit",
"(",
"null",
",",
"false",
")",
";",
"// }",
"}"
] | Runs JMFInit the first time the application is started so that capture
devices are properly detected and initialized by JMF. | [
"Runs",
"JMFInit",
"the",
"first",
"time",
"the",
"application",
"is",
"started",
"so",
"that",
"capture",
"devices",
"are",
"properly",
"detected",
"and",
"initialized",
"by",
"JMF",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jmf/JmfMediaManager.java#L124-L159 |
26,649 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java | SubscribeForm.setDeliverOn | public void setDeliverOn(boolean deliverNotifications) {
addField(SubscribeOptionFields.deliver, FormField.Type.bool);
setAnswer(SubscribeOptionFields.deliver.getFieldName(), deliverNotifications);
} | java | public void setDeliverOn(boolean deliverNotifications) {
addField(SubscribeOptionFields.deliver, FormField.Type.bool);
setAnswer(SubscribeOptionFields.deliver.getFieldName(), deliverNotifications);
} | [
"public",
"void",
"setDeliverOn",
"(",
"boolean",
"deliverNotifications",
")",
"{",
"addField",
"(",
"SubscribeOptionFields",
".",
"deliver",
",",
"FormField",
".",
"Type",
".",
"bool",
")",
";",
"setAnswer",
"(",
"SubscribeOptionFields",
".",
"deliver",
".",
"getFieldName",
"(",
")",
",",
"deliverNotifications",
")",
";",
"}"
] | Sets whether an entity wants to receive notifications.
@param deliverNotifications | [
"Sets",
"whether",
"an",
"entity",
"wants",
"to",
"receive",
"notifications",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java#L69-L72 |
26,650 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java | SubscribeForm.setDigestOn | public void setDigestOn(boolean digestOn) {
addField(SubscribeOptionFields.deliver, FormField.Type.bool);
setAnswer(SubscribeOptionFields.deliver.getFieldName(), digestOn);
} | java | public void setDigestOn(boolean digestOn) {
addField(SubscribeOptionFields.deliver, FormField.Type.bool);
setAnswer(SubscribeOptionFields.deliver.getFieldName(), digestOn);
} | [
"public",
"void",
"setDigestOn",
"(",
"boolean",
"digestOn",
")",
"{",
"addField",
"(",
"SubscribeOptionFields",
".",
"deliver",
",",
"FormField",
".",
"Type",
".",
"bool",
")",
";",
"setAnswer",
"(",
"SubscribeOptionFields",
".",
"deliver",
".",
"getFieldName",
"(",
")",
",",
"digestOn",
")",
";",
"}"
] | Sets whether notifications should be delivered as aggregations or not.
@param digestOn true to aggregate, false otherwise | [
"Sets",
"whether",
"notifications",
"should",
"be",
"delivered",
"as",
"aggregations",
"or",
"not",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java#L88-L91 |
26,651 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java | SubscribeForm.setDigestFrequency | public void setDigestFrequency(int frequency) {
addField(SubscribeOptionFields.digest_frequency, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.digest_frequency.getFieldName(), frequency);
} | java | public void setDigestFrequency(int frequency) {
addField(SubscribeOptionFields.digest_frequency, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.digest_frequency.getFieldName(), frequency);
} | [
"public",
"void",
"setDigestFrequency",
"(",
"int",
"frequency",
")",
"{",
"addField",
"(",
"SubscribeOptionFields",
".",
"digest_frequency",
",",
"FormField",
".",
"Type",
".",
"text_single",
")",
";",
"setAnswer",
"(",
"SubscribeOptionFields",
".",
"digest_frequency",
".",
"getFieldName",
"(",
")",
",",
"frequency",
")",
";",
"}"
] | Sets the minimum number of milliseconds between sending notification digests.
@param frequency The frequency in milliseconds | [
"Sets",
"the",
"minimum",
"number",
"of",
"milliseconds",
"between",
"sending",
"notification",
"digests",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java#L107-L110 |
26,652 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java | SubscribeForm.getExpiry | public Date getExpiry() {
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try {
return XmppDateTime.parseDate(dateTime);
}
catch (ParseException e) {
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e);
throw exc;
}
} | java | public Date getExpiry() {
String dateTime = getFieldValue(SubscribeOptionFields.expire);
try {
return XmppDateTime.parseDate(dateTime);
}
catch (ParseException e) {
UnknownFormatConversionException exc = new UnknownFormatConversionException(dateTime);
exc.initCause(e);
throw exc;
}
} | [
"public",
"Date",
"getExpiry",
"(",
")",
"{",
"String",
"dateTime",
"=",
"getFieldValue",
"(",
"SubscribeOptionFields",
".",
"expire",
")",
";",
"try",
"{",
"return",
"XmppDateTime",
".",
"parseDate",
"(",
"dateTime",
")",
";",
"}",
"catch",
"(",
"ParseException",
"e",
")",
"{",
"UnknownFormatConversionException",
"exc",
"=",
"new",
"UnknownFormatConversionException",
"(",
"dateTime",
")",
";",
"exc",
".",
"initCause",
"(",
"e",
")",
";",
"throw",
"exc",
";",
"}",
"}"
] | Get the time at which the leased subscription will expire, or has expired.
@return The expiry date | [
"Get",
"the",
"time",
"at",
"which",
"the",
"leased",
"subscription",
"will",
"expire",
"or",
"has",
"expired",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java#L117-L127 |
26,653 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java | SubscribeForm.setExpiry | public void setExpiry(Date expire) {
addField(SubscribeOptionFields.expire, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire));
} | java | public void setExpiry(Date expire) {
addField(SubscribeOptionFields.expire, FormField.Type.text_single);
setAnswer(SubscribeOptionFields.expire.getFieldName(), XmppDateTime.formatXEP0082Date(expire));
} | [
"public",
"void",
"setExpiry",
"(",
"Date",
"expire",
")",
"{",
"addField",
"(",
"SubscribeOptionFields",
".",
"expire",
",",
"FormField",
".",
"Type",
".",
"text_single",
")",
";",
"setAnswer",
"(",
"SubscribeOptionFields",
".",
"expire",
".",
"getFieldName",
"(",
")",
",",
"XmppDateTime",
".",
"formatXEP0082Date",
"(",
"expire",
")",
")",
";",
"}"
] | Sets the time at which the leased subscription will expire, or has expired.
@param expire The expiry date | [
"Sets",
"the",
"time",
"at",
"which",
"the",
"leased",
"subscription",
"will",
"expire",
"or",
"has",
"expired",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java#L134-L137 |
26,654 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java | SubscribeForm.setIncludeBody | public void setIncludeBody(boolean include) {
addField(SubscribeOptionFields.include_body, FormField.Type.bool);
setAnswer(SubscribeOptionFields.include_body.getFieldName(), include);
} | java | public void setIncludeBody(boolean include) {
addField(SubscribeOptionFields.include_body, FormField.Type.bool);
setAnswer(SubscribeOptionFields.include_body.getFieldName(), include);
} | [
"public",
"void",
"setIncludeBody",
"(",
"boolean",
"include",
")",
"{",
"addField",
"(",
"SubscribeOptionFields",
".",
"include_body",
",",
"FormField",
".",
"Type",
".",
"bool",
")",
";",
"setAnswer",
"(",
"SubscribeOptionFields",
".",
"include_body",
".",
"getFieldName",
"(",
")",
",",
"include",
")",
";",
"}"
] | Sets whether the entity wants to receive an XMPP message body in
addition to the payload format.
@param include true to receive the message body, false otherwise | [
"Sets",
"whether",
"the",
"entity",
"wants",
"to",
"receive",
"an",
"XMPP",
"message",
"body",
"in",
"addition",
"to",
"the",
"payload",
"format",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/SubscribeForm.java#L155-L158 |
26,655 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java | AgentRoster.addListener | public void addListener(AgentRosterListener listener) {
synchronized (listeners) {
if (!listeners.contains(listener)) {
listeners.add(listener);
// Fire events for the existing entries and presences in the roster
for (EntityBareJid jid : getAgents()) {
// Check again in case the agent is no longer in the roster (highly unlikely
// but possible)
if (entries.contains(jid)) {
// Fire the agent added event
listener.agentAdded(jid);
Jid j;
try {
j = JidCreate.from(jid);
}
catch (XmppStringprepException e) {
throw new IllegalStateException(e);
}
Map<Resourcepart, Presence> userPresences = presenceMap.get(j);
if (userPresences != null) {
Iterator<Presence> presences = userPresences.values().iterator();
while (presences.hasNext()) {
// Fire the presence changed event
listener.presenceChanged(presences.next());
}
}
}
}
}
}
} | java | public void addListener(AgentRosterListener listener) {
synchronized (listeners) {
if (!listeners.contains(listener)) {
listeners.add(listener);
// Fire events for the existing entries and presences in the roster
for (EntityBareJid jid : getAgents()) {
// Check again in case the agent is no longer in the roster (highly unlikely
// but possible)
if (entries.contains(jid)) {
// Fire the agent added event
listener.agentAdded(jid);
Jid j;
try {
j = JidCreate.from(jid);
}
catch (XmppStringprepException e) {
throw new IllegalStateException(e);
}
Map<Resourcepart, Presence> userPresences = presenceMap.get(j);
if (userPresences != null) {
Iterator<Presence> presences = userPresences.values().iterator();
while (presences.hasNext()) {
// Fire the presence changed event
listener.presenceChanged(presences.next());
}
}
}
}
}
}
} | [
"public",
"void",
"addListener",
"(",
"AgentRosterListener",
"listener",
")",
"{",
"synchronized",
"(",
"listeners",
")",
"{",
"if",
"(",
"!",
"listeners",
".",
"contains",
"(",
"listener",
")",
")",
"{",
"listeners",
".",
"add",
"(",
"listener",
")",
";",
"// Fire events for the existing entries and presences in the roster",
"for",
"(",
"EntityBareJid",
"jid",
":",
"getAgents",
"(",
")",
")",
"{",
"// Check again in case the agent is no longer in the roster (highly unlikely",
"// but possible)",
"if",
"(",
"entries",
".",
"contains",
"(",
"jid",
")",
")",
"{",
"// Fire the agent added event",
"listener",
".",
"agentAdded",
"(",
"jid",
")",
";",
"Jid",
"j",
";",
"try",
"{",
"j",
"=",
"JidCreate",
".",
"from",
"(",
"jid",
")",
";",
"}",
"catch",
"(",
"XmppStringprepException",
"e",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"e",
")",
";",
"}",
"Map",
"<",
"Resourcepart",
",",
"Presence",
">",
"userPresences",
"=",
"presenceMap",
".",
"get",
"(",
"j",
")",
";",
"if",
"(",
"userPresences",
"!=",
"null",
")",
"{",
"Iterator",
"<",
"Presence",
">",
"presences",
"=",
"userPresences",
".",
"values",
"(",
")",
".",
"iterator",
"(",
")",
";",
"while",
"(",
"presences",
".",
"hasNext",
"(",
")",
")",
"{",
"// Fire the presence changed event",
"listener",
".",
"presenceChanged",
"(",
"presences",
".",
"next",
"(",
")",
")",
";",
"}",
"}",
"}",
"}",
"}",
"}",
"}"
] | Adds a listener to this roster. The listener will be fired anytime one or more
changes to the roster are pushed from the server.
@param listener an agent roster listener. | [
"Adds",
"a",
"listener",
"to",
"this",
"roster",
".",
"The",
"listener",
"will",
"be",
"fired",
"anytime",
"one",
"or",
"more",
"changes",
"to",
"the",
"roster",
"are",
"pushed",
"from",
"the",
"server",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java#L111-L142 |
26,656 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java | AgentRoster.contains | public boolean contains(Jid jid) {
if (jid == null) {
return false;
}
synchronized (entries) {
for (Iterator<EntityBareJid> i = entries.iterator(); i.hasNext();) {
EntityBareJid entry = i.next();
if (entry.equals(jid)) {
return true;
}
}
}
return false;
} | java | public boolean contains(Jid jid) {
if (jid == null) {
return false;
}
synchronized (entries) {
for (Iterator<EntityBareJid> i = entries.iterator(); i.hasNext();) {
EntityBareJid entry = i.next();
if (entry.equals(jid)) {
return true;
}
}
}
return false;
} | [
"public",
"boolean",
"contains",
"(",
"Jid",
"jid",
")",
"{",
"if",
"(",
"jid",
"==",
"null",
")",
"{",
"return",
"false",
";",
"}",
"synchronized",
"(",
"entries",
")",
"{",
"for",
"(",
"Iterator",
"<",
"EntityBareJid",
">",
"i",
"=",
"entries",
".",
"iterator",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"EntityBareJid",
"entry",
"=",
"i",
".",
"next",
"(",
")",
";",
"if",
"(",
"entry",
".",
"equals",
"(",
"jid",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the specified XMPP address is an agent in the workgroup.
@param jid the XMPP address of the agent (eg "jsmith@example.com"). The
address can be in any valid format (e.g. "domain/resource", "user@domain"
or "user@domain/resource").
@return true if the XMPP address is an agent in the workgroup. | [
"Returns",
"true",
"if",
"the",
"specified",
"XMPP",
"address",
"is",
"an",
"agent",
"in",
"the",
"workgroup",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java#L188-L201 |
26,657 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java | AgentRoster.fireEvent | private void fireEvent(int eventType, Object eventObject) {
AgentRosterListener[] listeners;
synchronized (this.listeners) {
listeners = new AgentRosterListener[this.listeners.size()];
this.listeners.toArray(listeners);
}
for (int i = 0; i < listeners.length; i++) {
switch (eventType) {
case EVENT_AGENT_ADDED:
listeners[i].agentAdded((EntityBareJid) eventObject);
break;
case EVENT_AGENT_REMOVED:
listeners[i].agentRemoved((EntityBareJid) eventObject);
break;
case EVENT_PRESENCE_CHANGED:
listeners[i].presenceChanged((Presence) eventObject);
break;
}
}
} | java | private void fireEvent(int eventType, Object eventObject) {
AgentRosterListener[] listeners;
synchronized (this.listeners) {
listeners = new AgentRosterListener[this.listeners.size()];
this.listeners.toArray(listeners);
}
for (int i = 0; i < listeners.length; i++) {
switch (eventType) {
case EVENT_AGENT_ADDED:
listeners[i].agentAdded((EntityBareJid) eventObject);
break;
case EVENT_AGENT_REMOVED:
listeners[i].agentRemoved((EntityBareJid) eventObject);
break;
case EVENT_PRESENCE_CHANGED:
listeners[i].presenceChanged((Presence) eventObject);
break;
}
}
} | [
"private",
"void",
"fireEvent",
"(",
"int",
"eventType",
",",
"Object",
"eventObject",
")",
"{",
"AgentRosterListener",
"[",
"]",
"listeners",
";",
"synchronized",
"(",
"this",
".",
"listeners",
")",
"{",
"listeners",
"=",
"new",
"AgentRosterListener",
"[",
"this",
".",
"listeners",
".",
"size",
"(",
")",
"]",
";",
"this",
".",
"listeners",
".",
"toArray",
"(",
"listeners",
")",
";",
"}",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"listeners",
".",
"length",
";",
"i",
"++",
")",
"{",
"switch",
"(",
"eventType",
")",
"{",
"case",
"EVENT_AGENT_ADDED",
":",
"listeners",
"[",
"i",
"]",
".",
"agentAdded",
"(",
"(",
"EntityBareJid",
")",
"eventObject",
")",
";",
"break",
";",
"case",
"EVENT_AGENT_REMOVED",
":",
"listeners",
"[",
"i",
"]",
".",
"agentRemoved",
"(",
"(",
"EntityBareJid",
")",
"eventObject",
")",
";",
"break",
";",
"case",
"EVENT_PRESENCE_CHANGED",
":",
"listeners",
"[",
"i",
"]",
".",
"presenceChanged",
"(",
"(",
"Presence",
")",
"eventObject",
")",
";",
"break",
";",
"}",
"}",
"}"
] | Fires event to listeners. | [
"Fires",
"event",
"to",
"listeners",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/agent/AgentRoster.java#L271-L290 |
26,658 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java | JingleError.toXML | @Override
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
StringBuilder buf = new StringBuilder();
if (message != null) {
buf.append("<error type=\"cancel\">");
buf.append('<').append(message).append(" xmlns=\"").append(NAMESPACE).append(
"\"/>");
buf.append("</error>");
}
return buf.toString();
} | java | @Override
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
StringBuilder buf = new StringBuilder();
if (message != null) {
buf.append("<error type=\"cancel\">");
buf.append('<').append(message).append(" xmlns=\"").append(NAMESPACE).append(
"\"/>");
buf.append("</error>");
}
return buf.toString();
} | [
"@",
"Override",
"public",
"String",
"toXML",
"(",
"org",
".",
"jivesoftware",
".",
"smack",
".",
"packet",
".",
"XmlEnvironment",
"enclosingNamespace",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"message",
"!=",
"null",
")",
"{",
"buf",
".",
"append",
"(",
"\"<error type=\\\"cancel\\\">\"",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"message",
")",
".",
"append",
"(",
"\" xmlns=\\\"\"",
")",
".",
"append",
"(",
"NAMESPACE",
")",
".",
"append",
"(",
"\"\\\"/>\"",
")",
";",
"buf",
".",
"append",
"(",
"\"</error>\"",
")",
";",
"}",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the error as XML.
@return the error as XML. | [
"Returns",
"the",
"error",
"as",
"XML",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/packet/JingleError.java#L79-L89 |
26,659 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.isAvailable | public boolean isAvailable() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Presence directedPresence = new Presence(Presence.Type.available);
directedPresence.setTo(workgroupJID);
StanzaFilter typeFilter = new StanzaTypeFilter(Presence.class);
StanzaFilter fromFilter = FromMatchesFilter.create(workgroupJID);
StanzaCollector collector = connection.createStanzaCollectorAndSend(new AndFilter(fromFilter,
typeFilter), directedPresence);
Presence response = collector.nextResultOrThrow();
return Presence.Type.available == response.getType();
} | java | public boolean isAvailable() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
Presence directedPresence = new Presence(Presence.Type.available);
directedPresence.setTo(workgroupJID);
StanzaFilter typeFilter = new StanzaTypeFilter(Presence.class);
StanzaFilter fromFilter = FromMatchesFilter.create(workgroupJID);
StanzaCollector collector = connection.createStanzaCollectorAndSend(new AndFilter(fromFilter,
typeFilter), directedPresence);
Presence response = collector.nextResultOrThrow();
return Presence.Type.available == response.getType();
} | [
"public",
"boolean",
"isAvailable",
"(",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"Presence",
"directedPresence",
"=",
"new",
"Presence",
"(",
"Presence",
".",
"Type",
".",
"available",
")",
";",
"directedPresence",
".",
"setTo",
"(",
"workgroupJID",
")",
";",
"StanzaFilter",
"typeFilter",
"=",
"new",
"StanzaTypeFilter",
"(",
"Presence",
".",
"class",
")",
";",
"StanzaFilter",
"fromFilter",
"=",
"FromMatchesFilter",
".",
"create",
"(",
"workgroupJID",
")",
";",
"StanzaCollector",
"collector",
"=",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"new",
"AndFilter",
"(",
"fromFilter",
",",
"typeFilter",
")",
",",
"directedPresence",
")",
";",
"Presence",
"response",
"=",
"collector",
".",
"nextResultOrThrow",
"(",
")",
";",
"return",
"Presence",
".",
"Type",
".",
"available",
"==",
"response",
".",
"getType",
"(",
")",
";",
"}"
] | Returns true if the workgroup is available for receiving new requests. The workgroup will be
available only when agents are available for this workgroup.
@return true if the workgroup is available for receiving new requests.
@throws XMPPErrorException
@throws NoResponseException
@throws NotConnectedException
@throws InterruptedException | [
"Returns",
"true",
"if",
"the",
"workgroup",
"is",
"available",
"for",
"receiving",
"new",
"requests",
".",
"The",
"workgroup",
"will",
"be",
"available",
"only",
"when",
"agents",
"are",
"available",
"for",
"this",
"workgroup",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L190-L200 |
26,660 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.getChatSetting | public ChatSetting getChatSetting(String key) throws XMPPException, SmackException, InterruptedException {
ChatSettings chatSettings = getChatSettings(key, -1);
return chatSettings.getFirstEntry();
} | java | public ChatSetting getChatSetting(String key) throws XMPPException, SmackException, InterruptedException {
ChatSettings chatSettings = getChatSettings(key, -1);
return chatSettings.getFirstEntry();
} | [
"public",
"ChatSetting",
"getChatSetting",
"(",
"String",
"key",
")",
"throws",
"XMPPException",
",",
"SmackException",
",",
"InterruptedException",
"{",
"ChatSettings",
"chatSettings",
"=",
"getChatSettings",
"(",
"key",
",",
"-",
"1",
")",
";",
"return",
"chatSettings",
".",
"getFirstEntry",
"(",
")",
";",
"}"
] | Returns a single chat setting based on it's identified key.
@param key the key to find.
@return the ChatSetting if found, otherwise false.
@throws XMPPException if an error occurs while getting information from the server.
@throws SmackException
@throws InterruptedException | [
"Returns",
"a",
"single",
"chat",
"setting",
"based",
"on",
"it",
"s",
"identified",
"key",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L609-L612 |
26,661 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.getChatSettings | private ChatSettings getChatSettings(String key, int type) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ChatSettings request = new ChatSettings();
if (key != null) {
request.setKey(key);
}
if (type != -1) {
request.setType(type);
}
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
ChatSettings response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
return response;
} | java | private ChatSettings getChatSettings(String key, int type) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
ChatSettings request = new ChatSettings();
if (key != null) {
request.setKey(key);
}
if (type != -1) {
request.setType(type);
}
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
ChatSettings response = connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
return response;
} | [
"private",
"ChatSettings",
"getChatSettings",
"(",
"String",
"key",
",",
"int",
"type",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"ChatSettings",
"request",
"=",
"new",
"ChatSettings",
"(",
")",
";",
"if",
"(",
"key",
"!=",
"null",
")",
"{",
"request",
".",
"setKey",
"(",
"key",
")",
";",
"}",
"if",
"(",
"type",
"!=",
"-",
"1",
")",
"{",
"request",
".",
"setType",
"(",
"type",
")",
";",
"}",
"request",
".",
"setType",
"(",
"IQ",
".",
"Type",
".",
"get",
")",
";",
"request",
".",
"setTo",
"(",
"workgroupJID",
")",
";",
"ChatSettings",
"response",
"=",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"request",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"return",
"response",
";",
"}"
] | Asks the workgroup for it's Chat Settings.
@return key specify a key to retrieve only that settings. Otherwise for all settings, key should be null.
@throws NoResponseException
@throws XMPPErrorException if an error occurs while getting information from the server.
@throws NotConnectedException
@throws InterruptedException | [
"Asks",
"the",
"workgroup",
"for",
"it",
"s",
"Chat",
"Settings",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L649-L663 |
26,662 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.isEmailAvailable | public boolean isEmailAvailable() throws SmackException, InterruptedException {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
try {
DomainBareJid workgroupService = workgroupJID.asDomainBareJid();
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
}
catch (XMPPException e) {
return false;
}
} | java | public boolean isEmailAvailable() throws SmackException, InterruptedException {
ServiceDiscoveryManager discoManager = ServiceDiscoveryManager.getInstanceFor(connection);
try {
DomainBareJid workgroupService = workgroupJID.asDomainBareJid();
DiscoverInfo infoResult = discoManager.discoverInfo(workgroupService);
return infoResult.containsFeature("jive:email:provider");
}
catch (XMPPException e) {
return false;
}
} | [
"public",
"boolean",
"isEmailAvailable",
"(",
")",
"throws",
"SmackException",
",",
"InterruptedException",
"{",
"ServiceDiscoveryManager",
"discoManager",
"=",
"ServiceDiscoveryManager",
".",
"getInstanceFor",
"(",
"connection",
")",
";",
"try",
"{",
"DomainBareJid",
"workgroupService",
"=",
"workgroupJID",
".",
"asDomainBareJid",
"(",
")",
";",
"DiscoverInfo",
"infoResult",
"=",
"discoManager",
".",
"discoverInfo",
"(",
"workgroupService",
")",
";",
"return",
"infoResult",
".",
"containsFeature",
"(",
"\"jive:email:provider\"",
")",
";",
"}",
"catch",
"(",
"XMPPException",
"e",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | The workgroup service may be configured to send email. This queries the Workgroup Service
to see if the email service has been configured and is available.
@return true if the email service is available, otherwise return false.
@throws SmackException
@throws InterruptedException | [
"The",
"workgroup",
"service",
"may",
"be",
"configured",
"to",
"send",
"email",
".",
"This",
"queries",
"the",
"Workgroup",
"Service",
"to",
"see",
"if",
"the",
"email",
"service",
"has",
"been",
"configured",
"and",
"is",
"available",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L673-L684 |
26,663 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.getOfflineSettings | public OfflineSettings getOfflineSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
OfflineSettings request = new OfflineSettings();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
} | java | public OfflineSettings getOfflineSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
OfflineSettings request = new OfflineSettings();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
} | [
"public",
"OfflineSettings",
"getOfflineSettings",
"(",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"OfflineSettings",
"request",
"=",
"new",
"OfflineSettings",
"(",
")",
";",
"request",
".",
"setType",
"(",
"IQ",
".",
"Type",
".",
"get",
")",
";",
"request",
".",
"setTo",
"(",
"workgroupJID",
")",
";",
"return",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"request",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"}"
] | Asks the workgroup for it's Offline Settings.
@return offlineSettings the offline settings for this workgroup.
@throws XMPPErrorException
@throws NoResponseException
@throws NotConnectedException
@throws InterruptedException | [
"Asks",
"the",
"workgroup",
"for",
"it",
"s",
"Offline",
"Settings",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L695-L701 |
26,664 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.getSoundSettings | public SoundSettings getSoundSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
SoundSettings request = new SoundSettings();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
} | java | public SoundSettings getSoundSettings() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
SoundSettings request = new SoundSettings();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
} | [
"public",
"SoundSettings",
"getSoundSettings",
"(",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"SoundSettings",
"request",
"=",
"new",
"SoundSettings",
"(",
")",
";",
"request",
".",
"setType",
"(",
"IQ",
".",
"Type",
".",
"get",
")",
";",
"request",
".",
"setTo",
"(",
"workgroupJID",
")",
";",
"return",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"request",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"}"
] | Asks the workgroup for it's Sound Settings.
@return soundSettings the sound settings for the specified workgroup.
@throws XMPPErrorException
@throws NoResponseException
@throws NotConnectedException
@throws InterruptedException | [
"Asks",
"the",
"workgroup",
"for",
"it",
"s",
"Sound",
"Settings",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L712-L718 |
26,665 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java | Workgroup.getWorkgroupProperties | public WorkgroupProperties getWorkgroupProperties() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
WorkgroupProperties request = new WorkgroupProperties();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
} | java | public WorkgroupProperties getWorkgroupProperties() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
WorkgroupProperties request = new WorkgroupProperties();
request.setType(IQ.Type.get);
request.setTo(workgroupJID);
return connection.createStanzaCollectorAndSend(request).nextResultOrThrow();
} | [
"public",
"WorkgroupProperties",
"getWorkgroupProperties",
"(",
")",
"throws",
"NoResponseException",
",",
"XMPPErrorException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"WorkgroupProperties",
"request",
"=",
"new",
"WorkgroupProperties",
"(",
")",
";",
"request",
".",
"setType",
"(",
"IQ",
".",
"Type",
".",
"get",
")",
";",
"request",
".",
"setTo",
"(",
"workgroupJID",
")",
";",
"return",
"connection",
".",
"createStanzaCollectorAndSend",
"(",
"request",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"}"
] | Asks the workgroup for it's Properties.
@return the WorkgroupProperties for the specified workgroup.
@throws XMPPErrorException
@throws NoResponseException
@throws NotConnectedException
@throws InterruptedException | [
"Asks",
"the",
"workgroup",
"for",
"it",
"s",
"Properties",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/workgroup/user/Workgroup.java#L729-L735 |
26,666 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java | RosterExchange.addRosterEntry | public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name
List<String> groupNamesList = new ArrayList<>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);
// Create a new Entry based on the rosterEntry and add it to the packet
RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getJid(),
rosterEntry.getName(), groupNames);
addRosterEntry(remoteRosterEntry);
} | java | public void addRosterEntry(RosterEntry rosterEntry) {
// Obtain a String[] from the roster entry groups name
List<String> groupNamesList = new ArrayList<>();
String[] groupNames;
for (RosterGroup group : rosterEntry.getGroups()) {
groupNamesList.add(group.getName());
}
groupNames = groupNamesList.toArray(new String[groupNamesList.size()]);
// Create a new Entry based on the rosterEntry and add it to the packet
RemoteRosterEntry remoteRosterEntry = new RemoteRosterEntry(rosterEntry.getJid(),
rosterEntry.getName(), groupNames);
addRosterEntry(remoteRosterEntry);
} | [
"public",
"void",
"addRosterEntry",
"(",
"RosterEntry",
"rosterEntry",
")",
"{",
"// Obtain a String[] from the roster entry groups name",
"List",
"<",
"String",
">",
"groupNamesList",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"String",
"[",
"]",
"groupNames",
";",
"for",
"(",
"RosterGroup",
"group",
":",
"rosterEntry",
".",
"getGroups",
"(",
")",
")",
"{",
"groupNamesList",
".",
"add",
"(",
"group",
".",
"getName",
"(",
")",
")",
";",
"}",
"groupNames",
"=",
"groupNamesList",
".",
"toArray",
"(",
"new",
"String",
"[",
"groupNamesList",
".",
"size",
"(",
")",
"]",
")",
";",
"// Create a new Entry based on the rosterEntry and add it to the packet",
"RemoteRosterEntry",
"remoteRosterEntry",
"=",
"new",
"RemoteRosterEntry",
"(",
"rosterEntry",
".",
"getJid",
"(",
")",
",",
"rosterEntry",
".",
"getName",
"(",
")",
",",
"groupNames",
")",
";",
"addRosterEntry",
"(",
"remoteRosterEntry",
")",
";",
"}"
] | Adds a roster entry to the packet.
@param rosterEntry a roster entry to add. | [
"Adds",
"a",
"roster",
"entry",
"to",
"the",
"packet",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java#L81-L95 |
26,667 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java | RosterExchange.getRosterEntries | public Iterator<RemoteRosterEntry> getRosterEntries() {
synchronized (remoteRosterEntries) {
List<RemoteRosterEntry> entries = Collections.unmodifiableList(new ArrayList<>(remoteRosterEntries));
return entries.iterator();
}
} | java | public Iterator<RemoteRosterEntry> getRosterEntries() {
synchronized (remoteRosterEntries) {
List<RemoteRosterEntry> entries = Collections.unmodifiableList(new ArrayList<>(remoteRosterEntries));
return entries.iterator();
}
} | [
"public",
"Iterator",
"<",
"RemoteRosterEntry",
">",
"getRosterEntries",
"(",
")",
"{",
"synchronized",
"(",
"remoteRosterEntries",
")",
"{",
"List",
"<",
"RemoteRosterEntry",
">",
"entries",
"=",
"Collections",
".",
"unmodifiableList",
"(",
"new",
"ArrayList",
"<>",
"(",
"remoteRosterEntries",
")",
")",
";",
"return",
"entries",
".",
"iterator",
"(",
")",
";",
"}",
"}"
] | Returns an Iterator for the roster entries in the packet.
@return an Iterator for the roster entries in the packet. | [
"Returns",
"an",
"Iterator",
"for",
"the",
"roster",
"entries",
"in",
"the",
"packet",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java#L136-L141 |
26,668 | igniterealtime/Smack | smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java | RosterExchange.toXML | @Override
public String toXML(org.jivesoftware.smack.packet.XmlEnvironment enclosingNamespace) {
StringBuilder buf = new StringBuilder();
buf.append('<').append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
"\">");
// Loop through all roster entries and append them to the string buffer
for (Iterator<RemoteRosterEntry> i = getRosterEntries(); i.hasNext();) {
RemoteRosterEntry remoteRosterEntry = i.next();
buf.append(remoteRosterEntry.toXML());
}
buf.append("</").append(getElementName()).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=\"").append(getNamespace()).append(
"\">");
// Loop through all roster entries and append them to the string buffer
for (Iterator<RemoteRosterEntry> i = getRosterEntries(); i.hasNext();) {
RemoteRosterEntry remoteRosterEntry = i.next();
buf.append(remoteRosterEntry.toXML());
}
buf.append("</").append(getElementName()).append('>');
return buf.toString();
} | [
"@",
"Override",
"public",
"String",
"toXML",
"(",
"org",
".",
"jivesoftware",
".",
"smack",
".",
"packet",
".",
"XmlEnvironment",
"enclosingNamespace",
")",
"{",
"StringBuilder",
"buf",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"buf",
".",
"append",
"(",
"'",
"'",
")",
".",
"append",
"(",
"getElementName",
"(",
")",
")",
".",
"append",
"(",
"\" xmlns=\\\"\"",
")",
".",
"append",
"(",
"getNamespace",
"(",
")",
")",
".",
"append",
"(",
"\"\\\">\"",
")",
";",
"// Loop through all roster entries and append them to the string buffer",
"for",
"(",
"Iterator",
"<",
"RemoteRosterEntry",
">",
"i",
"=",
"getRosterEntries",
"(",
")",
";",
"i",
".",
"hasNext",
"(",
")",
";",
")",
"{",
"RemoteRosterEntry",
"remoteRosterEntry",
"=",
"i",
".",
"next",
"(",
")",
";",
"buf",
".",
"append",
"(",
"remoteRosterEntry",
".",
"toXML",
"(",
")",
")",
";",
"}",
"buf",
".",
"append",
"(",
"\"</\"",
")",
".",
"append",
"(",
"getElementName",
"(",
")",
")",
".",
"append",
"(",
"'",
"'",
")",
";",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"}"
] | Returns the XML representation of a Roster Item Exchange according the specification.
Usually the XML representation will be inside of a Message XML representation like
in the following example:
<pre>
<message id="MlIpV-4" to="gato1@gato.home" from="gato3@gato.home/Smack">
<subject>Any subject you want</subject>
<body>This message contains roster items.</body>
<x xmlns="jabber:x:roster">
<item jid="gato1@gato.home"/>
<item jid="gato2@gato.home"/>
</x>
</message>
</pre> | [
"Returns",
"the",
"XML",
"representation",
"of",
"a",
"Roster",
"Item",
"Exchange",
"according",
"the",
"specification",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-legacy/src/main/java/org/jivesoftware/smackx/xroster/packet/RosterExchange.java#L169-L181 |
26,669 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/SpeexMediaManager.java | SpeexMediaManager.createMediaSession | @Override
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
return new AudioMediaSession(payloadType, remote, local, null,null);
} | java | @Override
public JingleMediaSession createMediaSession(PayloadType payloadType, final TransportCandidate remote, final TransportCandidate local, final JingleSession jingleSession) {
return new AudioMediaSession(payloadType, remote, local, null,null);
} | [
"@",
"Override",
"public",
"JingleMediaSession",
"createMediaSession",
"(",
"PayloadType",
"payloadType",
",",
"final",
"TransportCandidate",
"remote",
",",
"final",
"TransportCandidate",
"local",
",",
"final",
"JingleSession",
"jingleSession",
")",
"{",
"return",
"new",
"AudioMediaSession",
"(",
"payloadType",
",",
"remote",
",",
"local",
",",
"null",
",",
"null",
")",
";",
"}"
] | Returns a new jingleMediaSession.
@param payloadType payloadType
@param remote remote Candidate
@param local local Candidate
@return JingleMediaSession | [
"Returns",
"a",
"new",
"jingleMediaSession",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/mediaimpl/jspeex/SpeexMediaManager.java#L63-L66 |
26,670 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/util/Objects.java | Objects.requireNonNullNorEmpty | public static <T extends Collection<?>> T requireNonNullNorEmpty(T collection, String message) {
if (requireNonNull(collection).isEmpty()) {
throw new IllegalArgumentException(message);
}
return collection;
} | java | public static <T extends Collection<?>> T requireNonNullNorEmpty(T collection, String message) {
if (requireNonNull(collection).isEmpty()) {
throw new IllegalArgumentException(message);
}
return collection;
} | [
"public",
"static",
"<",
"T",
"extends",
"Collection",
"<",
"?",
">",
">",
"T",
"requireNonNullNorEmpty",
"(",
"T",
"collection",
",",
"String",
"message",
")",
"{",
"if",
"(",
"requireNonNull",
"(",
"collection",
")",
".",
"isEmpty",
"(",
")",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"message",
")",
";",
"}",
"return",
"collection",
";",
"}"
] | Require a collection to be neither null, nor empty.
@param collection collection
@param message error message
@param <T> Collection type
@return collection | [
"Require",
"a",
"collection",
"to",
"be",
"neither",
"null",
"nor",
"empty",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/util/Objects.java#L42-L47 |
26,671 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java | BridgedResolver.resolve | @Override
public synchronized void resolve(JingleSession session) throws XMPPException, NotConnectedException, InterruptedException {
setResolveInit();
clearCandidates();
sid = random.nextInt(Integer.MAX_VALUE);
RTPBridge rtpBridge = RTPBridge.getRTPBridge(connection, String.valueOf(sid));
String localIp = getLocalHost();
TransportCandidate localCandidate = new TransportCandidate.Fixed(
rtpBridge.getIp(), rtpBridge.getPortA());
localCandidate.setLocalIp(localIp);
TransportCandidate remoteCandidate = new TransportCandidate.Fixed(
rtpBridge.getIp(), rtpBridge.getPortB());
remoteCandidate.setLocalIp(localIp);
localCandidate.setSymmetric(remoteCandidate);
remoteCandidate.setSymmetric(localCandidate);
localCandidate.setPassword(rtpBridge.getPass());
remoteCandidate.setPassword(rtpBridge.getPass());
localCandidate.setSessionId(rtpBridge.getSid());
remoteCandidate.setSessionId(rtpBridge.getSid());
localCandidate.setConnection(this.connection);
remoteCandidate.setConnection(this.connection);
addCandidate(localCandidate);
setResolveEnd();
} | java | @Override
public synchronized void resolve(JingleSession session) throws XMPPException, NotConnectedException, InterruptedException {
setResolveInit();
clearCandidates();
sid = random.nextInt(Integer.MAX_VALUE);
RTPBridge rtpBridge = RTPBridge.getRTPBridge(connection, String.valueOf(sid));
String localIp = getLocalHost();
TransportCandidate localCandidate = new TransportCandidate.Fixed(
rtpBridge.getIp(), rtpBridge.getPortA());
localCandidate.setLocalIp(localIp);
TransportCandidate remoteCandidate = new TransportCandidate.Fixed(
rtpBridge.getIp(), rtpBridge.getPortB());
remoteCandidate.setLocalIp(localIp);
localCandidate.setSymmetric(remoteCandidate);
remoteCandidate.setSymmetric(localCandidate);
localCandidate.setPassword(rtpBridge.getPass());
remoteCandidate.setPassword(rtpBridge.getPass());
localCandidate.setSessionId(rtpBridge.getSid());
remoteCandidate.setSessionId(rtpBridge.getSid());
localCandidate.setConnection(this.connection);
remoteCandidate.setConnection(this.connection);
addCandidate(localCandidate);
setResolveEnd();
} | [
"@",
"Override",
"public",
"synchronized",
"void",
"resolve",
"(",
"JingleSession",
"session",
")",
"throws",
"XMPPException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"setResolveInit",
"(",
")",
";",
"clearCandidates",
"(",
")",
";",
"sid",
"=",
"random",
".",
"nextInt",
"(",
"Integer",
".",
"MAX_VALUE",
")",
";",
"RTPBridge",
"rtpBridge",
"=",
"RTPBridge",
".",
"getRTPBridge",
"(",
"connection",
",",
"String",
".",
"valueOf",
"(",
"sid",
")",
")",
";",
"String",
"localIp",
"=",
"getLocalHost",
"(",
")",
";",
"TransportCandidate",
"localCandidate",
"=",
"new",
"TransportCandidate",
".",
"Fixed",
"(",
"rtpBridge",
".",
"getIp",
"(",
")",
",",
"rtpBridge",
".",
"getPortA",
"(",
")",
")",
";",
"localCandidate",
".",
"setLocalIp",
"(",
"localIp",
")",
";",
"TransportCandidate",
"remoteCandidate",
"=",
"new",
"TransportCandidate",
".",
"Fixed",
"(",
"rtpBridge",
".",
"getIp",
"(",
")",
",",
"rtpBridge",
".",
"getPortB",
"(",
")",
")",
";",
"remoteCandidate",
".",
"setLocalIp",
"(",
"localIp",
")",
";",
"localCandidate",
".",
"setSymmetric",
"(",
"remoteCandidate",
")",
";",
"remoteCandidate",
".",
"setSymmetric",
"(",
"localCandidate",
")",
";",
"localCandidate",
".",
"setPassword",
"(",
"rtpBridge",
".",
"getPass",
"(",
")",
")",
";",
"remoteCandidate",
".",
"setPassword",
"(",
"rtpBridge",
".",
"getPass",
"(",
")",
")",
";",
"localCandidate",
".",
"setSessionId",
"(",
"rtpBridge",
".",
"getSid",
"(",
")",
")",
";",
"remoteCandidate",
".",
"setSessionId",
"(",
"rtpBridge",
".",
"getSid",
"(",
")",
")",
";",
"localCandidate",
".",
"setConnection",
"(",
"this",
".",
"connection",
")",
";",
"remoteCandidate",
".",
"setConnection",
"(",
"this",
".",
"connection",
")",
";",
"addCandidate",
"(",
"localCandidate",
")",
";",
"setResolveEnd",
"(",
")",
";",
"}"
] | 1
Resolve Bridged Candidate.
The BridgedResolver takes the IP address and ports of a jmf proxy service.
@throws NotConnectedException
@throws InterruptedException | [
"1",
"Resolve",
"Bridged",
"Candidate",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/nat/BridgedResolver.java#L70-L106 |
26,672 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.addSubject | public Subject addSubject(String language, String subject) {
language = determineLanguage(language);
Subject messageSubject = new Subject(language, subject);
subjects.add(messageSubject);
return messageSubject;
} | java | public Subject addSubject(String language, String subject) {
language = determineLanguage(language);
Subject messageSubject = new Subject(language, subject);
subjects.add(messageSubject);
return messageSubject;
} | [
"public",
"Subject",
"addSubject",
"(",
"String",
"language",
",",
"String",
"subject",
")",
"{",
"language",
"=",
"determineLanguage",
"(",
"language",
")",
";",
"Subject",
"messageSubject",
"=",
"new",
"Subject",
"(",
"language",
",",
"subject",
")",
";",
"subjects",
".",
"add",
"(",
"messageSubject",
")",
";",
"return",
"messageSubject",
";",
"}"
] | Adds a subject with a corresponding language.
@param language the language of the subject being added.
@param subject the subject being added to the message.
@return the new {@link org.jivesoftware.smack.packet.Message.Subject}
@throws NullPointerException if the subject is null, a null pointer exception is thrown | [
"Adds",
"a",
"subject",
"with",
"a",
"corresponding",
"language",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L237-L242 |
26,673 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.removeSubject | public boolean removeSubject(String language) {
language = determineLanguage(language);
for (Subject subject : subjects) {
if (language.equals(subject.language)) {
return subjects.remove(subject);
}
}
return false;
} | java | public boolean removeSubject(String language) {
language = determineLanguage(language);
for (Subject subject : subjects) {
if (language.equals(subject.language)) {
return subjects.remove(subject);
}
}
return false;
} | [
"public",
"boolean",
"removeSubject",
"(",
"String",
"language",
")",
"{",
"language",
"=",
"determineLanguage",
"(",
"language",
")",
";",
"for",
"(",
"Subject",
"subject",
":",
"subjects",
")",
"{",
"if",
"(",
"language",
".",
"equals",
"(",
"subject",
".",
"language",
")",
")",
"{",
"return",
"subjects",
".",
"remove",
"(",
"subject",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Removes the subject with the given language from the message.
@param language the language of the subject which is to be removed
@return true if a subject was removed and false if it was not. | [
"Removes",
"the",
"subject",
"with",
"the",
"given",
"language",
"from",
"the",
"message",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L250-L258 |
26,674 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.getSubjectLanguages | public List<String> getSubjectLanguages() {
Subject defaultSubject = getMessageSubject(null);
List<String> languages = new ArrayList<String>();
for (Subject subject : subjects) {
if (!subject.equals(defaultSubject)) {
languages.add(subject.language);
}
}
return Collections.unmodifiableList(languages);
} | java | public List<String> getSubjectLanguages() {
Subject defaultSubject = getMessageSubject(null);
List<String> languages = new ArrayList<String>();
for (Subject subject : subjects) {
if (!subject.equals(defaultSubject)) {
languages.add(subject.language);
}
}
return Collections.unmodifiableList(languages);
} | [
"public",
"List",
"<",
"String",
">",
"getSubjectLanguages",
"(",
")",
"{",
"Subject",
"defaultSubject",
"=",
"getMessageSubject",
"(",
"null",
")",
";",
"List",
"<",
"String",
">",
"languages",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Subject",
"subject",
":",
"subjects",
")",
"{",
"if",
"(",
"!",
"subject",
".",
"equals",
"(",
"defaultSubject",
")",
")",
"{",
"languages",
".",
"add",
"(",
"subject",
".",
"language",
")",
";",
"}",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"languages",
")",
";",
"}"
] | Returns all the languages being used for the subjects, not including the default subject.
@return the languages being used for the subjects. | [
"Returns",
"all",
"the",
"languages",
"being",
"used",
"for",
"the",
"subjects",
"not",
"including",
"the",
"default",
"subject",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L275-L284 |
26,675 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.setBody | public void setBody(CharSequence body) {
String bodyString;
if (body != null) {
bodyString = body.toString();
} else {
bodyString = null;
}
setBody(bodyString);
} | java | public void setBody(CharSequence body) {
String bodyString;
if (body != null) {
bodyString = body.toString();
} else {
bodyString = null;
}
setBody(bodyString);
} | [
"public",
"void",
"setBody",
"(",
"CharSequence",
"body",
")",
"{",
"String",
"bodyString",
";",
"if",
"(",
"body",
"!=",
"null",
")",
"{",
"bodyString",
"=",
"body",
".",
"toString",
"(",
")",
";",
"}",
"else",
"{",
"bodyString",
"=",
"null",
";",
"}",
"setBody",
"(",
"bodyString",
")",
";",
"}"
] | Sets the body of the message.
@param body the body of the message.
@see #setBody(String)
@since 4.2 | [
"Sets",
"the",
"body",
"of",
"the",
"message",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L348-L356 |
26,676 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.addBody | public Body addBody(String language, String body) {
language = determineLanguage(language);
removeBody(language);
Body messageBody = new Body(language, body);
addExtension(messageBody);
return messageBody;
} | java | public Body addBody(String language, String body) {
language = determineLanguage(language);
removeBody(language);
Body messageBody = new Body(language, body);
addExtension(messageBody);
return messageBody;
} | [
"public",
"Body",
"addBody",
"(",
"String",
"language",
",",
"String",
"body",
")",
"{",
"language",
"=",
"determineLanguage",
"(",
"language",
")",
";",
"removeBody",
"(",
"language",
")",
";",
"Body",
"messageBody",
"=",
"new",
"Body",
"(",
"language",
",",
"body",
")",
";",
"addExtension",
"(",
"messageBody",
")",
";",
"return",
"messageBody",
";",
"}"
] | Adds a body with a corresponding language.
@param language the language of the body being added.
@param body the body being added to the message.
@return the new {@link org.jivesoftware.smack.packet.Message.Body}
@throws NullPointerException if the body is null, a null pointer exception is thrown
@since 3.0.2 | [
"Adds",
"a",
"body",
"with",
"a",
"corresponding",
"language",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L380-L388 |
26,677 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.removeBody | public boolean removeBody(String language) {
language = determineLanguage(language);
for (Body body : getBodies()) {
String bodyLanguage = body.getLanguage();
if (Objects.equals(bodyLanguage, language)) {
removeExtension(body);
return true;
}
}
return false;
} | java | public boolean removeBody(String language) {
language = determineLanguage(language);
for (Body body : getBodies()) {
String bodyLanguage = body.getLanguage();
if (Objects.equals(bodyLanguage, language)) {
removeExtension(body);
return true;
}
}
return false;
} | [
"public",
"boolean",
"removeBody",
"(",
"String",
"language",
")",
"{",
"language",
"=",
"determineLanguage",
"(",
"language",
")",
";",
"for",
"(",
"Body",
"body",
":",
"getBodies",
"(",
")",
")",
"{",
"String",
"bodyLanguage",
"=",
"body",
".",
"getLanguage",
"(",
")",
";",
"if",
"(",
"Objects",
".",
"equals",
"(",
"bodyLanguage",
",",
"language",
")",
")",
"{",
"removeExtension",
"(",
"body",
")",
";",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Removes the body with the given language from the message.
@param language the language of the body which is to be removed
@return true if a body was removed and false if it was not. | [
"Removes",
"the",
"body",
"with",
"the",
"given",
"language",
"from",
"the",
"message",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L396-L406 |
26,678 | igniterealtime/Smack | smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java | Message.getBodyLanguages | public List<String> getBodyLanguages() {
Body defaultBody = getMessageBody(null);
List<String> languages = new ArrayList<String>();
for (Body body : getBodies()) {
if (!body.equals(defaultBody)) {
languages.add(body.language);
}
}
return Collections.unmodifiableList(languages);
} | java | public List<String> getBodyLanguages() {
Body defaultBody = getMessageBody(null);
List<String> languages = new ArrayList<String>();
for (Body body : getBodies()) {
if (!body.equals(defaultBody)) {
languages.add(body.language);
}
}
return Collections.unmodifiableList(languages);
} | [
"public",
"List",
"<",
"String",
">",
"getBodyLanguages",
"(",
")",
"{",
"Body",
"defaultBody",
"=",
"getMessageBody",
"(",
"null",
")",
";",
"List",
"<",
"String",
">",
"languages",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"for",
"(",
"Body",
"body",
":",
"getBodies",
"(",
")",
")",
"{",
"if",
"(",
"!",
"body",
".",
"equals",
"(",
"defaultBody",
")",
")",
"{",
"languages",
".",
"add",
"(",
"body",
".",
"language",
")",
";",
"}",
"}",
"return",
"Collections",
".",
"unmodifiableList",
"(",
"languages",
")",
";",
"}"
] | Returns all the languages being used for the bodies, not including the default body.
@return the languages being used for the bodies.
@since 3.0.2 | [
"Returns",
"all",
"the",
"languages",
"being",
"used",
"for",
"the",
"bodies",
"not",
"including",
"the",
"default",
"body",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java#L426-L435 |
26,679 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java | JingleContentProvider.parse | @Override
public JingleContent parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
String elementName = parser.getName();
String creator = parser.getAttributeValue("", JingleContent.CREATOR);
String name = parser.getAttributeValue("", JingleContent.NAME);
// Try to get an Audio content info
return new JingleContent(creator, name);
} | java | @Override
public JingleContent parse(XmlPullParser parser, int initialDepth, XmlEnvironment xmlEnvironment) {
String elementName = parser.getName();
String creator = parser.getAttributeValue("", JingleContent.CREATOR);
String name = parser.getAttributeValue("", JingleContent.NAME);
// Try to get an Audio content info
return new JingleContent(creator, name);
} | [
"@",
"Override",
"public",
"JingleContent",
"parse",
"(",
"XmlPullParser",
"parser",
",",
"int",
"initialDepth",
",",
"XmlEnvironment",
"xmlEnvironment",
")",
"{",
"String",
"elementName",
"=",
"parser",
".",
"getName",
"(",
")",
";",
"String",
"creator",
"=",
"parser",
".",
"getAttributeValue",
"(",
"\"\"",
",",
"JingleContent",
".",
"CREATOR",
")",
";",
"String",
"name",
"=",
"parser",
".",
"getAttributeValue",
"(",
"\"\"",
",",
"JingleContent",
".",
"NAME",
")",
";",
"// Try to get an Audio content info",
"return",
"new",
"JingleContent",
"(",
"creator",
",",
"name",
")",
";",
"}"
] | Parse a JingleContent extension. | [
"Parse",
"a",
"JingleContent",
"extension",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/provider/JingleContentProvider.java#L36-L44 |
26,680 | igniterealtime/Smack | smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java | SMUtils.calculateDelta | public static long calculateDelta(long reportedHandledCount, long lastKnownHandledCount) {
if (lastKnownHandledCount > reportedHandledCount) {
throw new IllegalStateException("Illegal Stream Management State: Last known handled count (" + lastKnownHandledCount + ") is greater than reported handled count (" + reportedHandledCount + ')');
}
return (reportedHandledCount - lastKnownHandledCount) & MASK_32_BIT;
} | java | public static long calculateDelta(long reportedHandledCount, long lastKnownHandledCount) {
if (lastKnownHandledCount > reportedHandledCount) {
throw new IllegalStateException("Illegal Stream Management State: Last known handled count (" + lastKnownHandledCount + ") is greater than reported handled count (" + reportedHandledCount + ')');
}
return (reportedHandledCount - lastKnownHandledCount) & MASK_32_BIT;
} | [
"public",
"static",
"long",
"calculateDelta",
"(",
"long",
"reportedHandledCount",
",",
"long",
"lastKnownHandledCount",
")",
"{",
"if",
"(",
"lastKnownHandledCount",
">",
"reportedHandledCount",
")",
"{",
"throw",
"new",
"IllegalStateException",
"(",
"\"Illegal Stream Management State: Last known handled count (\"",
"+",
"lastKnownHandledCount",
"+",
"\") is greater than reported handled count (\"",
"+",
"reportedHandledCount",
"+",
"'",
"'",
")",
";",
"}",
"return",
"(",
"reportedHandledCount",
"-",
"lastKnownHandledCount",
")",
"&",
"MASK_32_BIT",
";",
"}"
] | Calculates the delta of the last known stanza handled count and the new
reported stanza handled count while considering that the new value may be
wrapped after 2^32-1.
@param reportedHandledCount
@param lastKnownHandledCount
@return the delta | [
"Calculates",
"the",
"delta",
"of",
"the",
"last",
"known",
"stanza",
"handled",
"count",
"and",
"the",
"new",
"reported",
"stanza",
"handled",
"count",
"while",
"considering",
"that",
"the",
"new",
"value",
"may",
"be",
"wrapped",
"after",
"2^32",
"-",
"1",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-tcp/src/main/java/org/jivesoftware/smack/sm/SMUtils.java#L49-L54 |
26,681 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionRequest.java | JingleSessionRequest.accept | public synchronized JingleSession accept() throws XMPPException, SmackException, InterruptedException {
JingleSession session;
synchronized (manager) {
session = manager.createIncomingJingleSession(this);
// Acknowledge the IQ reception
session.setSid(this.getSessionID());
// session.sendAck(this.getJingle());
session.updatePacketListener();
session.receivePacketAndRespond(this.getJingle());
}
return session;
} | java | public synchronized JingleSession accept() throws XMPPException, SmackException, InterruptedException {
JingleSession session;
synchronized (manager) {
session = manager.createIncomingJingleSession(this);
// Acknowledge the IQ reception
session.setSid(this.getSessionID());
// session.sendAck(this.getJingle());
session.updatePacketListener();
session.receivePacketAndRespond(this.getJingle());
}
return session;
} | [
"public",
"synchronized",
"JingleSession",
"accept",
"(",
")",
"throws",
"XMPPException",
",",
"SmackException",
",",
"InterruptedException",
"{",
"JingleSession",
"session",
";",
"synchronized",
"(",
"manager",
")",
"{",
"session",
"=",
"manager",
".",
"createIncomingJingleSession",
"(",
"this",
")",
";",
"// Acknowledge the IQ reception",
"session",
".",
"setSid",
"(",
"this",
".",
"getSessionID",
"(",
")",
")",
";",
"// session.sendAck(this.getJingle());",
"session",
".",
"updatePacketListener",
"(",
")",
";",
"session",
".",
"receivePacketAndRespond",
"(",
"this",
".",
"getJingle",
"(",
")",
")",
";",
"}",
"return",
"session",
";",
"}"
] | Accepts this request and creates the incoming Jingle session.
@return Returns the IncomingJingleSession on which the
negotiation can be carried out.
@throws SmackException
@throws InterruptedException | [
"Accepts",
"this",
"request",
"and",
"creates",
"the",
"incoming",
"Jingle",
"session",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionRequest.java#L115-L126 |
26,682 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionRequest.java | JingleSessionRequest.reject | public synchronized void reject() {
JingleSession session;
synchronized (manager) {
try {
session = manager.createIncomingJingleSession(this);
// Acknowledge the IQ reception
session.setSid(this.getSessionID());
// session.sendAck(this.getJingle());
session.updatePacketListener();
session.terminate("Declined");
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exception in reject", e);
}
}
} | java | public synchronized void reject() {
JingleSession session;
synchronized (manager) {
try {
session = manager.createIncomingJingleSession(this);
// Acknowledge the IQ reception
session.setSid(this.getSessionID());
// session.sendAck(this.getJingle());
session.updatePacketListener();
session.terminate("Declined");
} catch (Exception e) {
LOGGER.log(Level.SEVERE, "Exception in reject", e);
}
}
} | [
"public",
"synchronized",
"void",
"reject",
"(",
")",
"{",
"JingleSession",
"session",
";",
"synchronized",
"(",
"manager",
")",
"{",
"try",
"{",
"session",
"=",
"manager",
".",
"createIncomingJingleSession",
"(",
"this",
")",
";",
"// Acknowledge the IQ reception",
"session",
".",
"setSid",
"(",
"this",
".",
"getSessionID",
"(",
")",
")",
";",
"// session.sendAck(this.getJingle());",
"session",
".",
"updatePacketListener",
"(",
")",
";",
"session",
".",
"terminate",
"(",
"\"Declined\"",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"LOGGER",
".",
"log",
"(",
"Level",
".",
"SEVERE",
",",
"\"Exception in reject\"",
",",
"e",
")",
";",
"}",
"}",
"}"
] | Rejects the session request. | [
"Rejects",
"the",
"session",
"request",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/JingleSessionRequest.java#L131-L145 |
26,683 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java | DiscoverInfo.addFeatures | public void addFeatures(Collection<String> featuresToAdd) {
if (featuresToAdd == null) return;
for (String feature : featuresToAdd) {
addFeature(feature);
}
} | java | public void addFeatures(Collection<String> featuresToAdd) {
if (featuresToAdd == null) return;
for (String feature : featuresToAdd) {
addFeature(feature);
}
} | [
"public",
"void",
"addFeatures",
"(",
"Collection",
"<",
"String",
">",
"featuresToAdd",
")",
"{",
"if",
"(",
"featuresToAdd",
"==",
"null",
")",
"return",
";",
"for",
"(",
"String",
"feature",
":",
"featuresToAdd",
")",
"{",
"addFeature",
"(",
"feature",
")",
";",
"}",
"}"
] | Adds a collection of features to the packet. Does noting if featuresToAdd is null.
@param featuresToAdd | [
"Adds",
"a",
"collection",
"of",
"features",
"to",
"the",
"packet",
".",
"Does",
"noting",
"if",
"featuresToAdd",
"is",
"null",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java#L96-L101 |
26,684 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java | DiscoverInfo.addIdentity | public void addIdentity(Identity identity) {
identities.add(identity);
identitiesSet.add(identity.getKey());
} | java | public void addIdentity(Identity identity) {
identities.add(identity);
identitiesSet.add(identity.getKey());
} | [
"public",
"void",
"addIdentity",
"(",
"Identity",
"identity",
")",
"{",
"identities",
".",
"add",
"(",
"identity",
")",
";",
"identitiesSet",
".",
"add",
"(",
"identity",
".",
"getKey",
"(",
")",
")",
";",
"}"
] | Adds a new identity of the requested entity to the discovered information.
@param identity the discovered entity's identity | [
"Adds",
"a",
"new",
"identity",
"of",
"the",
"requested",
"entity",
"to",
"the",
"discovered",
"information",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java#L126-L129 |
26,685 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java | DiscoverInfo.addIdentities | public void addIdentities(Collection<Identity> identitiesToAdd) {
if (identitiesToAdd == null) return;
for (Identity identity : identitiesToAdd) {
addIdentity(identity);
}
} | java | public void addIdentities(Collection<Identity> identitiesToAdd) {
if (identitiesToAdd == null) return;
for (Identity identity : identitiesToAdd) {
addIdentity(identity);
}
} | [
"public",
"void",
"addIdentities",
"(",
"Collection",
"<",
"Identity",
">",
"identitiesToAdd",
")",
"{",
"if",
"(",
"identitiesToAdd",
"==",
"null",
")",
"return",
";",
"for",
"(",
"Identity",
"identity",
":",
"identitiesToAdd",
")",
"{",
"addIdentity",
"(",
"identity",
")",
";",
"}",
"}"
] | Adds identities to the DiscoverInfo stanza.
@param identitiesToAdd | [
"Adds",
"identities",
"to",
"the",
"DiscoverInfo",
"stanza",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java#L136-L141 |
26,686 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java | DiscoverInfo.hasIdentity | public boolean hasIdentity(String category, String type) {
String key = XmppStringUtils.generateKey(category, type);
return identitiesSet.contains(key);
} | java | public boolean hasIdentity(String category, String type) {
String key = XmppStringUtils.generateKey(category, type);
return identitiesSet.contains(key);
} | [
"public",
"boolean",
"hasIdentity",
"(",
"String",
"category",
",",
"String",
"type",
")",
"{",
"String",
"key",
"=",
"XmppStringUtils",
".",
"generateKey",
"(",
"category",
",",
"type",
")",
";",
"return",
"identitiesSet",
".",
"contains",
"(",
"key",
")",
";",
"}"
] | Returns true if this DiscoverInfo contains at least one Identity of the given category and type.
@param category the category to look for.
@param type the type to look for.
@return true if this DiscoverInfo contains a Identity of the given category and type. | [
"Returns",
"true",
"if",
"this",
"DiscoverInfo",
"contains",
"at",
"least",
"one",
"Identity",
"of",
"the",
"given",
"category",
"and",
"type",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java#L159-L162 |
26,687 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java | DiscoverInfo.getIdentities | public List<Identity> getIdentities(String category, String type) {
List<Identity> res = new ArrayList<>(identities.size());
for (Identity identity : identities) {
if (identity.getCategory().equals(category) && identity.getType().equals(type)) {
res.add(identity);
}
}
return res;
} | java | public List<Identity> getIdentities(String category, String type) {
List<Identity> res = new ArrayList<>(identities.size());
for (Identity identity : identities) {
if (identity.getCategory().equals(category) && identity.getType().equals(type)) {
res.add(identity);
}
}
return res;
} | [
"public",
"List",
"<",
"Identity",
">",
"getIdentities",
"(",
"String",
"category",
",",
"String",
"type",
")",
"{",
"List",
"<",
"Identity",
">",
"res",
"=",
"new",
"ArrayList",
"<>",
"(",
"identities",
".",
"size",
"(",
")",
")",
";",
"for",
"(",
"Identity",
"identity",
":",
"identities",
")",
"{",
"if",
"(",
"identity",
".",
"getCategory",
"(",
")",
".",
"equals",
"(",
"category",
")",
"&&",
"identity",
".",
"getType",
"(",
")",
".",
"equals",
"(",
"type",
")",
")",
"{",
"res",
".",
"add",
"(",
"identity",
")",
";",
"}",
"}",
"return",
"res",
";",
"}"
] | Returns all Identities of the given category and type of this DiscoverInfo.
@param category category the category to look for.
@param type type the type to look for.
@return a list of Identites with the given category and type. | [
"Returns",
"all",
"Identities",
"of",
"the",
"given",
"category",
"and",
"type",
"of",
"this",
"DiscoverInfo",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java#L171-L179 |
26,688 | igniterealtime/Smack | smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java | DiscoverInfo.containsDuplicateIdentities | public boolean containsDuplicateIdentities() {
List<Identity> checkedIdentities = new LinkedList<>();
for (Identity i : identities) {
for (Identity i2 : checkedIdentities) {
if (i.equals(i2))
return true;
}
checkedIdentities.add(i);
}
return false;
} | java | public boolean containsDuplicateIdentities() {
List<Identity> checkedIdentities = new LinkedList<>();
for (Identity i : identities) {
for (Identity i2 : checkedIdentities) {
if (i.equals(i2))
return true;
}
checkedIdentities.add(i);
}
return false;
} | [
"public",
"boolean",
"containsDuplicateIdentities",
"(",
")",
"{",
"List",
"<",
"Identity",
">",
"checkedIdentities",
"=",
"new",
"LinkedList",
"<>",
"(",
")",
";",
"for",
"(",
"Identity",
"i",
":",
"identities",
")",
"{",
"for",
"(",
"Identity",
"i2",
":",
"checkedIdentities",
")",
"{",
"if",
"(",
"i",
".",
"equals",
"(",
"i2",
")",
")",
"return",
"true",
";",
"}",
"checkedIdentities",
".",
"add",
"(",
"i",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Test if a DiscoverInfo response contains duplicate identities.
@return true if duplicate identities where found, otherwise false | [
"Test",
"if",
"a",
"DiscoverInfo",
"response",
"contains",
"duplicate",
"identities",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java#L236-L246 |
26,689 | igniterealtime/Smack | smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java | RosterEntry.setName | public synchronized void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
// Do nothing if the name hasn't changed.
if (name != null && name.equals(getName())) {
return;
}
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.set);
// Create a new roster item with the current RosterEntry and the *new* name. Note that we can't set the name of
// RosterEntry right away, as otherwise the updated event wont get fired, because equalsDeep would return true.
packet.addRosterItem(toRosterItem(this, name));
connection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
// We have received a result response to the IQ set, the name was successfully changed
item.setName(name);
} | java | public synchronized void setName(String name) throws NotConnectedException, NoResponseException, XMPPErrorException, InterruptedException {
// Do nothing if the name hasn't changed.
if (name != null && name.equals(getName())) {
return;
}
RosterPacket packet = new RosterPacket();
packet.setType(IQ.Type.set);
// Create a new roster item with the current RosterEntry and the *new* name. Note that we can't set the name of
// RosterEntry right away, as otherwise the updated event wont get fired, because equalsDeep would return true.
packet.addRosterItem(toRosterItem(this, name));
connection().createStanzaCollectorAndSend(packet).nextResultOrThrow();
// We have received a result response to the IQ set, the name was successfully changed
item.setName(name);
} | [
"public",
"synchronized",
"void",
"setName",
"(",
"String",
"name",
")",
"throws",
"NotConnectedException",
",",
"NoResponseException",
",",
"XMPPErrorException",
",",
"InterruptedException",
"{",
"// Do nothing if the name hasn't changed.",
"if",
"(",
"name",
"!=",
"null",
"&&",
"name",
".",
"equals",
"(",
"getName",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"RosterPacket",
"packet",
"=",
"new",
"RosterPacket",
"(",
")",
";",
"packet",
".",
"setType",
"(",
"IQ",
".",
"Type",
".",
"set",
")",
";",
"// Create a new roster item with the current RosterEntry and the *new* name. Note that we can't set the name of",
"// RosterEntry right away, as otherwise the updated event wont get fired, because equalsDeep would return true.",
"packet",
".",
"addRosterItem",
"(",
"toRosterItem",
"(",
"this",
",",
"name",
")",
")",
";",
"connection",
"(",
")",
".",
"createStanzaCollectorAndSend",
"(",
"packet",
")",
".",
"nextResultOrThrow",
"(",
")",
";",
"// We have received a result response to the IQ set, the name was successfully changed",
"item",
".",
"setName",
"(",
"name",
")",
";",
"}"
] | Sets the name associated with this entry.
@param name the name.
@throws NotConnectedException
@throws XMPPErrorException
@throws NoResponseException
@throws InterruptedException | [
"Sets",
"the",
"name",
"associated",
"with",
"this",
"entry",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java#L101-L117 |
26,690 | igniterealtime/Smack | smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java | RosterEntry.getGroups | public List<RosterGroup> getGroups() {
List<RosterGroup> results = new ArrayList<>();
// Loop through all roster groups and find the ones that contain this
// entry. This algorithm should be fine
for (RosterGroup group : roster.getGroups()) {
if (group.contains(this)) {
results.add(group);
}
}
return results;
} | java | public List<RosterGroup> getGroups() {
List<RosterGroup> results = new ArrayList<>();
// Loop through all roster groups and find the ones that contain this
// entry. This algorithm should be fine
for (RosterGroup group : roster.getGroups()) {
if (group.contains(this)) {
results.add(group);
}
}
return results;
} | [
"public",
"List",
"<",
"RosterGroup",
">",
"getGroups",
"(",
")",
"{",
"List",
"<",
"RosterGroup",
">",
"results",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"// Loop through all roster groups and find the ones that contain this",
"// entry. This algorithm should be fine",
"for",
"(",
"RosterGroup",
"group",
":",
"roster",
".",
"getGroups",
"(",
")",
")",
"{",
"if",
"(",
"group",
".",
"contains",
"(",
"this",
")",
")",
"{",
"results",
".",
"add",
"(",
"group",
")",
";",
"}",
"}",
"return",
"results",
";",
"}"
] | Returns an copied list of the roster groups that this entry belongs to.
@return an iterator for the groups this entry belongs to. | [
"Returns",
"an",
"copied",
"list",
"of",
"the",
"roster",
"groups",
"that",
"this",
"entry",
"belongs",
"to",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java#L143-L153 |
26,691 | igniterealtime/Smack | smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java | RosterEntry.cancelSubscription | public void cancelSubscription() throws NotConnectedException, InterruptedException {
Presence unsubscribed = new Presence(item.getJid(), Type.unsubscribed);
connection().sendStanza(unsubscribed);
} | java | public void cancelSubscription() throws NotConnectedException, InterruptedException {
Presence unsubscribed = new Presence(item.getJid(), Type.unsubscribed);
connection().sendStanza(unsubscribed);
} | [
"public",
"void",
"cancelSubscription",
"(",
")",
"throws",
"NotConnectedException",
",",
"InterruptedException",
"{",
"Presence",
"unsubscribed",
"=",
"new",
"Presence",
"(",
"item",
".",
"getJid",
"(",
")",
",",
"Type",
".",
"unsubscribed",
")",
";",
"connection",
"(",
")",
".",
"sendStanza",
"(",
"unsubscribed",
")",
";",
"}"
] | Cancel the presence subscription the XMPP entity representing this roster entry has with us.
@throws NotConnectedException
@throws InterruptedException
@since 4.2 | [
"Cancel",
"the",
"presence",
"subscription",
"the",
"XMPP",
"entity",
"representing",
"this",
"roster",
"entry",
"has",
"with",
"us",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/roster/RosterEntry.java#L219-L222 |
26,692 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.receiveContentAcceptAction | private IQ receiveContentAcceptAction(Jingle jingle, JingleDescription description) throws XMPPException, NotConnectedException, InterruptedException {
IQ response;
List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
bestCommonAudioPt = calculateBestCommonAudioPt(offeredPayloads);
if (bestCommonAudioPt == null) {
setNegotiatorState(JingleNegotiatorState.FAILED);
response = session.createJingleError(jingle, JingleError.NEGOTIATION_ERROR);
} else {
setNegotiatorState(JingleNegotiatorState.SUCCEEDED);
triggerMediaEstablished(getBestCommonAudioPt());
LOGGER.severe("Media choice:" + getBestCommonAudioPt().getName());
response = session.createAck(jingle);
}
return response;
} | java | private IQ receiveContentAcceptAction(Jingle jingle, JingleDescription description) throws XMPPException, NotConnectedException, InterruptedException {
IQ response;
List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
bestCommonAudioPt = calculateBestCommonAudioPt(offeredPayloads);
if (bestCommonAudioPt == null) {
setNegotiatorState(JingleNegotiatorState.FAILED);
response = session.createJingleError(jingle, JingleError.NEGOTIATION_ERROR);
} else {
setNegotiatorState(JingleNegotiatorState.SUCCEEDED);
triggerMediaEstablished(getBestCommonAudioPt());
LOGGER.severe("Media choice:" + getBestCommonAudioPt().getName());
response = session.createAck(jingle);
}
return response;
} | [
"private",
"IQ",
"receiveContentAcceptAction",
"(",
"Jingle",
"jingle",
",",
"JingleDescription",
"description",
")",
"throws",
"XMPPException",
",",
"NotConnectedException",
",",
"InterruptedException",
"{",
"IQ",
"response",
";",
"List",
"<",
"PayloadType",
">",
"offeredPayloads",
"=",
"description",
".",
"getAudioPayloadTypesList",
"(",
")",
";",
"bestCommonAudioPt",
"=",
"calculateBestCommonAudioPt",
"(",
"offeredPayloads",
")",
";",
"if",
"(",
"bestCommonAudioPt",
"==",
"null",
")",
"{",
"setNegotiatorState",
"(",
"JingleNegotiatorState",
".",
"FAILED",
")",
";",
"response",
"=",
"session",
".",
"createJingleError",
"(",
"jingle",
",",
"JingleError",
".",
"NEGOTIATION_ERROR",
")",
";",
"}",
"else",
"{",
"setNegotiatorState",
"(",
"JingleNegotiatorState",
".",
"SUCCEEDED",
")",
";",
"triggerMediaEstablished",
"(",
"getBestCommonAudioPt",
"(",
")",
")",
";",
"LOGGER",
".",
"severe",
"(",
"\"Media choice:\"",
"+",
"getBestCommonAudioPt",
"(",
")",
".",
"getName",
"(",
")",
")",
";",
"response",
"=",
"session",
".",
"createAck",
"(",
"jingle",
")",
";",
"}",
"return",
"response",
";",
"}"
] | The other side has sent us a content-accept. The payload types in that message may not match with what
we sent, but XEP-167 says that the other side should retain the order of the payload types we first sent.
This means we can walk through our list, in order, until we find one from their list that matches. This
will be the best payload type to use.
@param jingle
@return the iq
@throws NotConnectedException
@throws InterruptedException | [
"The",
"other",
"side",
"has",
"sent",
"us",
"a",
"content",
"-",
"accept",
".",
"The",
"payload",
"types",
"in",
"that",
"message",
"may",
"not",
"match",
"with",
"what",
"we",
"sent",
"but",
"XEP",
"-",
"167",
"says",
"that",
"the",
"other",
"side",
"should",
"retain",
"the",
"order",
"of",
"the",
"payload",
"types",
"we",
"first",
"sent",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L210-L231 |
26,693 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.receiveSessionInitiateAction | private IQ receiveSessionInitiateAction(Jingle jingle, JingleDescription description) {
IQ response = null;
List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
bestCommonAudioPt = calculateBestCommonAudioPt(offeredPayloads);
synchronized (remoteAudioPts) {
remoteAudioPts.addAll(offeredPayloads);
}
// If there are suitable/matching payload types then accept this content.
if (bestCommonAudioPt != null) {
// Let the transport negotiators sort-out connectivity and content-accept instead.
// response = createAudioPayloadTypesOffer();
setNegotiatorState(JingleNegotiatorState.PENDING);
} else {
// Don't really know what to send here. XEP-166 is not clear.
setNegotiatorState(JingleNegotiatorState.FAILED);
}
return response;
} | java | private IQ receiveSessionInitiateAction(Jingle jingle, JingleDescription description) {
IQ response = null;
List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
bestCommonAudioPt = calculateBestCommonAudioPt(offeredPayloads);
synchronized (remoteAudioPts) {
remoteAudioPts.addAll(offeredPayloads);
}
// If there are suitable/matching payload types then accept this content.
if (bestCommonAudioPt != null) {
// Let the transport negotiators sort-out connectivity and content-accept instead.
// response = createAudioPayloadTypesOffer();
setNegotiatorState(JingleNegotiatorState.PENDING);
} else {
// Don't really know what to send here. XEP-166 is not clear.
setNegotiatorState(JingleNegotiatorState.FAILED);
}
return response;
} | [
"private",
"IQ",
"receiveSessionInitiateAction",
"(",
"Jingle",
"jingle",
",",
"JingleDescription",
"description",
")",
"{",
"IQ",
"response",
"=",
"null",
";",
"List",
"<",
"PayloadType",
">",
"offeredPayloads",
"=",
"description",
".",
"getAudioPayloadTypesList",
"(",
")",
";",
"bestCommonAudioPt",
"=",
"calculateBestCommonAudioPt",
"(",
"offeredPayloads",
")",
";",
"synchronized",
"(",
"remoteAudioPts",
")",
"{",
"remoteAudioPts",
".",
"addAll",
"(",
"offeredPayloads",
")",
";",
"}",
"// If there are suitable/matching payload types then accept this content.",
"if",
"(",
"bestCommonAudioPt",
"!=",
"null",
")",
"{",
"// Let the transport negotiators sort-out connectivity and content-accept instead.",
"// response = createAudioPayloadTypesOffer();",
"setNegotiatorState",
"(",
"JingleNegotiatorState",
".",
"PENDING",
")",
";",
"}",
"else",
"{",
"// Don't really know what to send here. XEP-166 is not clear.",
"setNegotiatorState",
"(",
"JingleNegotiatorState",
".",
"FAILED",
")",
";",
"}",
"return",
"response",
";",
"}"
] | Receive a session-initiate packet.
@param jingle
@param description
@return the iq | [
"Receive",
"a",
"session",
"-",
"initiate",
"packet",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L239-L260 |
26,694 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.receiveSessionInfoAction | private IQ receiveSessionInfoAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null;
PayloadType oldBestCommonAudioPt = bestCommonAudioPt;
List<PayloadType> offeredPayloads;
boolean ptChange = false;
offeredPayloads = description.getAudioPayloadTypesList();
if (!offeredPayloads.isEmpty()) {
synchronized (remoteAudioPts) {
remoteAudioPts.clear();
remoteAudioPts.addAll(offeredPayloads);
}
// Calculate the best common codec
bestCommonAudioPt = calculateBestCommonAudioPt(remoteAudioPts);
if (bestCommonAudioPt != null) {
// and send an accept if we have an agreement...
ptChange = !bestCommonAudioPt.equals(oldBestCommonAudioPt);
if (oldBestCommonAudioPt == null || ptChange) {
// response = createAcceptMessage();
}
} else {
throw new JingleException(JingleError.NO_COMMON_PAYLOAD);
}
}
// Parse the Jingle and get the payload accepted
return response;
} | java | private IQ receiveSessionInfoAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null;
PayloadType oldBestCommonAudioPt = bestCommonAudioPt;
List<PayloadType> offeredPayloads;
boolean ptChange = false;
offeredPayloads = description.getAudioPayloadTypesList();
if (!offeredPayloads.isEmpty()) {
synchronized (remoteAudioPts) {
remoteAudioPts.clear();
remoteAudioPts.addAll(offeredPayloads);
}
// Calculate the best common codec
bestCommonAudioPt = calculateBestCommonAudioPt(remoteAudioPts);
if (bestCommonAudioPt != null) {
// and send an accept if we have an agreement...
ptChange = !bestCommonAudioPt.equals(oldBestCommonAudioPt);
if (oldBestCommonAudioPt == null || ptChange) {
// response = createAcceptMessage();
}
} else {
throw new JingleException(JingleError.NO_COMMON_PAYLOAD);
}
}
// Parse the Jingle and get the payload accepted
return response;
} | [
"private",
"IQ",
"receiveSessionInfoAction",
"(",
"Jingle",
"jingle",
",",
"JingleDescription",
"description",
")",
"throws",
"JingleException",
"{",
"IQ",
"response",
"=",
"null",
";",
"PayloadType",
"oldBestCommonAudioPt",
"=",
"bestCommonAudioPt",
";",
"List",
"<",
"PayloadType",
">",
"offeredPayloads",
";",
"boolean",
"ptChange",
"=",
"false",
";",
"offeredPayloads",
"=",
"description",
".",
"getAudioPayloadTypesList",
"(",
")",
";",
"if",
"(",
"!",
"offeredPayloads",
".",
"isEmpty",
"(",
")",
")",
"{",
"synchronized",
"(",
"remoteAudioPts",
")",
"{",
"remoteAudioPts",
".",
"clear",
"(",
")",
";",
"remoteAudioPts",
".",
"addAll",
"(",
"offeredPayloads",
")",
";",
"}",
"// Calculate the best common codec",
"bestCommonAudioPt",
"=",
"calculateBestCommonAudioPt",
"(",
"remoteAudioPts",
")",
";",
"if",
"(",
"bestCommonAudioPt",
"!=",
"null",
")",
"{",
"// and send an accept if we have an agreement...",
"ptChange",
"=",
"!",
"bestCommonAudioPt",
".",
"equals",
"(",
"oldBestCommonAudioPt",
")",
";",
"if",
"(",
"oldBestCommonAudioPt",
"==",
"null",
"||",
"ptChange",
")",
"{",
"// response = createAcceptMessage();",
"}",
"}",
"else",
"{",
"throw",
"new",
"JingleException",
"(",
"JingleError",
".",
"NO_COMMON_PAYLOAD",
")",
";",
"}",
"}",
"// Parse the Jingle and get the payload accepted",
"return",
"response",
";",
"}"
] | A content info has been received. This is done for publishing the
list of payload types...
@param jingle
The input packet
@return a Jingle packet
@throws JingleException | [
"A",
"content",
"info",
"has",
"been",
"received",
".",
"This",
"is",
"done",
"for",
"publishing",
"the",
"list",
"of",
"payload",
"types",
"..."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L271-L300 |
26,695 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.receiveSessionAcceptAction | private IQ receiveSessionAcceptAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null;
PayloadType.Audio agreedCommonAudioPt;
if (bestCommonAudioPt == null) {
// Update the best common audio PT
bestCommonAudioPt = calculateBestCommonAudioPt(remoteAudioPts);
// response = createAcceptMessage();
}
List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
if (!offeredPayloads.isEmpty()) {
if (offeredPayloads.size() == 1) {
agreedCommonAudioPt = (PayloadType.Audio) offeredPayloads.get(0);
if (bestCommonAudioPt != null) {
// If the accepted PT matches the best payload
// everything is fine
if (!agreedCommonAudioPt.equals(bestCommonAudioPt)) {
throw new JingleException(JingleError.NEGOTIATION_ERROR);
}
}
} else if (offeredPayloads.size() > 1) {
throw new JingleException(JingleError.MALFORMED_STANZA);
}
}
return response;
} | java | private IQ receiveSessionAcceptAction(Jingle jingle, JingleDescription description) throws JingleException {
IQ response = null;
PayloadType.Audio agreedCommonAudioPt;
if (bestCommonAudioPt == null) {
// Update the best common audio PT
bestCommonAudioPt = calculateBestCommonAudioPt(remoteAudioPts);
// response = createAcceptMessage();
}
List<PayloadType> offeredPayloads = description.getAudioPayloadTypesList();
if (!offeredPayloads.isEmpty()) {
if (offeredPayloads.size() == 1) {
agreedCommonAudioPt = (PayloadType.Audio) offeredPayloads.get(0);
if (bestCommonAudioPt != null) {
// If the accepted PT matches the best payload
// everything is fine
if (!agreedCommonAudioPt.equals(bestCommonAudioPt)) {
throw new JingleException(JingleError.NEGOTIATION_ERROR);
}
}
} else if (offeredPayloads.size() > 1) {
throw new JingleException(JingleError.MALFORMED_STANZA);
}
}
return response;
} | [
"private",
"IQ",
"receiveSessionAcceptAction",
"(",
"Jingle",
"jingle",
",",
"JingleDescription",
"description",
")",
"throws",
"JingleException",
"{",
"IQ",
"response",
"=",
"null",
";",
"PayloadType",
".",
"Audio",
"agreedCommonAudioPt",
";",
"if",
"(",
"bestCommonAudioPt",
"==",
"null",
")",
"{",
"// Update the best common audio PT",
"bestCommonAudioPt",
"=",
"calculateBestCommonAudioPt",
"(",
"remoteAudioPts",
")",
";",
"// response = createAcceptMessage();",
"}",
"List",
"<",
"PayloadType",
">",
"offeredPayloads",
"=",
"description",
".",
"getAudioPayloadTypesList",
"(",
")",
";",
"if",
"(",
"!",
"offeredPayloads",
".",
"isEmpty",
"(",
")",
")",
"{",
"if",
"(",
"offeredPayloads",
".",
"size",
"(",
")",
"==",
"1",
")",
"{",
"agreedCommonAudioPt",
"=",
"(",
"PayloadType",
".",
"Audio",
")",
"offeredPayloads",
".",
"get",
"(",
"0",
")",
";",
"if",
"(",
"bestCommonAudioPt",
"!=",
"null",
")",
"{",
"// If the accepted PT matches the best payload",
"// everything is fine",
"if",
"(",
"!",
"agreedCommonAudioPt",
".",
"equals",
"(",
"bestCommonAudioPt",
")",
")",
"{",
"throw",
"new",
"JingleException",
"(",
"JingleError",
".",
"NEGOTIATION_ERROR",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"offeredPayloads",
".",
"size",
"(",
")",
">",
"1",
")",
"{",
"throw",
"new",
"JingleException",
"(",
"JingleError",
".",
"MALFORMED_STANZA",
")",
";",
"}",
"}",
"return",
"response",
";",
"}"
] | A jmf description has been accepted. In this case, we must save the
accepted payload type and notify any listener...
@param jin
The input packet
@return a Jingle packet
@throws JingleException | [
"A",
"jmf",
"description",
"has",
"been",
"accepted",
".",
"In",
"this",
"case",
"we",
"must",
"save",
"the",
"accepted",
"payload",
"type",
"and",
"notify",
"any",
"listener",
"..."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L311-L339 |
26,696 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.addRemoteAudioPayloadType | public void addRemoteAudioPayloadType(PayloadType.Audio pt) {
if (pt != null) {
synchronized (remoteAudioPts) {
remoteAudioPts.add(pt);
}
}
} | java | public void addRemoteAudioPayloadType(PayloadType.Audio pt) {
if (pt != null) {
synchronized (remoteAudioPts) {
remoteAudioPts.add(pt);
}
}
} | [
"public",
"void",
"addRemoteAudioPayloadType",
"(",
"PayloadType",
".",
"Audio",
"pt",
")",
"{",
"if",
"(",
"pt",
"!=",
"null",
")",
"{",
"synchronized",
"(",
"remoteAudioPts",
")",
"{",
"remoteAudioPts",
".",
"add",
"(",
"pt",
")",
";",
"}",
"}",
"}"
] | Adds a payload type to the list of remote payloads.
@param pt
the remote payload type | [
"Adds",
"a",
"payload",
"type",
"to",
"the",
"list",
"of",
"remote",
"payloads",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L414-L420 |
26,697 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.triggerMediaClosed | protected void triggerMediaClosed(PayloadType currPt) {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleMediaListener) {
JingleMediaListener mli = (JingleMediaListener) li;
mli.mediaClosed(currPt);
}
}
} | java | protected void triggerMediaClosed(PayloadType currPt) {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleMediaListener) {
JingleMediaListener mli = (JingleMediaListener) li;
mli.mediaClosed(currPt);
}
}
} | [
"protected",
"void",
"triggerMediaClosed",
"(",
"PayloadType",
"currPt",
")",
"{",
"List",
"<",
"JingleListener",
">",
"listeners",
"=",
"getListenersList",
"(",
")",
";",
"for",
"(",
"JingleListener",
"li",
":",
"listeners",
")",
"{",
"if",
"(",
"li",
"instanceof",
"JingleMediaListener",
")",
"{",
"JingleMediaListener",
"mli",
"=",
"(",
"JingleMediaListener",
")",
"li",
";",
"mli",
".",
"mediaClosed",
"(",
"currPt",
")",
";",
"}",
"}",
"}"
] | Trigger a jmf closed event.
@param currPt
current payload type that is cancelled. | [
"Trigger",
"a",
"jmf",
"closed",
"event",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L498-L506 |
26,698 | igniterealtime/Smack | smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java | MediaNegotiator.getJingleDescription | public JingleDescription getJingleDescription() {
JingleDescription result = null;
PayloadType payloadType = getBestCommonAudioPt();
if (payloadType != null) {
result = new JingleDescription.Audio(payloadType);
} else {
// If we haven't settled on a best payload type yet then just use the first one in our local list.
result = new JingleDescription.Audio();
result.addAudioPayloadTypes(localAudioPts);
}
return result;
} | java | public JingleDescription getJingleDescription() {
JingleDescription result = null;
PayloadType payloadType = getBestCommonAudioPt();
if (payloadType != null) {
result = new JingleDescription.Audio(payloadType);
} else {
// If we haven't settled on a best payload type yet then just use the first one in our local list.
result = new JingleDescription.Audio();
result.addAudioPayloadTypes(localAudioPts);
}
return result;
} | [
"public",
"JingleDescription",
"getJingleDescription",
"(",
")",
"{",
"JingleDescription",
"result",
"=",
"null",
";",
"PayloadType",
"payloadType",
"=",
"getBestCommonAudioPt",
"(",
")",
";",
"if",
"(",
"payloadType",
"!=",
"null",
")",
"{",
"result",
"=",
"new",
"JingleDescription",
".",
"Audio",
"(",
"payloadType",
")",
";",
"}",
"else",
"{",
"// If we haven't settled on a best payload type yet then just use the first one in our local list.",
"result",
"=",
"new",
"JingleDescription",
".",
"Audio",
"(",
")",
";",
"result",
".",
"addAudioPayloadTypes",
"(",
"localAudioPts",
")",
";",
"}",
"return",
"result",
";",
"}"
] | Create a JingleDescription that matches this negotiator. | [
"Create",
"a",
"JingleDescription",
"that",
"matches",
"this",
"negotiator",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-jingle-old/src/main/java/org/jivesoftware/smackx/jingleold/media/MediaNegotiator.java#L528-L539 |
26,699 | igniterealtime/Smack | smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java | ChatManager.getInstanceFor | public static synchronized ChatManager getInstanceFor(XMPPConnection connection) {
ChatManager manager = INSTANCES.get(connection);
if (manager == null)
manager = new ChatManager(connection);
return manager;
} | java | public static synchronized ChatManager getInstanceFor(XMPPConnection connection) {
ChatManager manager = INSTANCES.get(connection);
if (manager == null)
manager = new ChatManager(connection);
return manager;
} | [
"public",
"static",
"synchronized",
"ChatManager",
"getInstanceFor",
"(",
"XMPPConnection",
"connection",
")",
"{",
"ChatManager",
"manager",
"=",
"INSTANCES",
".",
"get",
"(",
"connection",
")",
";",
"if",
"(",
"manager",
"==",
"null",
")",
"manager",
"=",
"new",
"ChatManager",
"(",
"connection",
")",
";",
"return",
"manager",
";",
"}"
] | Returns the ChatManager instance associated with a given XMPPConnection.
@param connection the connection used to look for the proper ServiceDiscoveryManager.
@return the ChatManager associated with a given XMPPConnection. | [
"Returns",
"the",
"ChatManager",
"instance",
"associated",
"with",
"a",
"given",
"XMPPConnection",
"."
] | 870756997faec1e1bfabfac0cd6c2395b04da873 | https://github.com/igniterealtime/Smack/blob/870756997faec1e1bfabfac0cd6c2395b04da873/smack-im/src/main/java/org/jivesoftware/smack/chat/ChatManager.java#L82-L87 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.