use of eu.siacs.conversations.entities.ServiceDiscoveryResult in project Conversations by siacs.
the class JingleFileTransferConnection method getRemoteFeatures.
private List<String> getRemoteFeatures() {
final String resource = Strings.nullToEmpty(this.id.with.getResource());
final Presence presence = this.id.account.getRoster().getContact(id.with).getPresences().get(resource);
final ServiceDiscoveryResult result = presence != null ? presence.getServiceDiscoveryResult() : null;
return result == null ? Collections.emptyList() : result.getFeatures();
}
use of eu.siacs.conversations.entities.ServiceDiscoveryResult in project Conversations by siacs.
the class RtpCapability method check.
public static Capability check(final Presence presence) {
final ServiceDiscoveryResult disco = presence.getServiceDiscoveryResult();
final List<String> features = disco == null ? Collections.emptyList() : disco.getFeatures();
if (features.containsAll(BASIC_RTP_REQUIREMENTS)) {
if (features.containsAll(VIDEO_REQUIREMENTS)) {
return Capability.VIDEO;
}
if (features.contains(Namespace.JINGLE_FEATURE_AUDIO)) {
return Capability.AUDIO;
}
}
return Capability.NONE;
}
use of eu.siacs.conversations.entities.ServiceDiscoveryResult in project Conversations by siacs.
the class XmppConnection method sendServiceDiscoveryInfo.
private void sendServiceDiscoveryInfo(final Jid jid) {
mPendingServiceDiscoveries.incrementAndGet();
final IqPacket iq = new IqPacket(IqPacket.TYPE.GET);
iq.setTo(jid);
iq.query("http://jabber.org/protocol/disco#info");
this.sendIqPacket(iq, (account, packet) -> {
if (packet.getType() == IqPacket.TYPE.RESULT) {
boolean advancedStreamFeaturesLoaded;
synchronized (XmppConnection.this.disco) {
ServiceDiscoveryResult result = new ServiceDiscoveryResult(packet);
if (jid.equals(account.getDomain())) {
mXmppConnectionService.databaseBackend.insertDiscoveryResult(result);
}
disco.put(jid, result);
advancedStreamFeaturesLoaded = disco.containsKey(account.getDomain()) && disco.containsKey(account.getJid().asBareJid());
}
if (advancedStreamFeaturesLoaded && (jid.equals(account.getDomain()) || jid.equals(account.getJid().asBareJid()))) {
enableAdvancedStreamFeatures();
}
} else if (packet.getType() == IqPacket.TYPE.ERROR) {
Log.d(Config.LOGTAG, account.getJid().asBareJid() + ": could not query disco info for " + jid.toString());
final boolean serverOrAccount = jid.equals(account.getDomain()) || jid.equals(account.getJid().asBareJid());
final boolean advancedStreamFeaturesLoaded;
if (serverOrAccount) {
synchronized (XmppConnection.this.disco) {
disco.put(jid, ServiceDiscoveryResult.empty());
advancedStreamFeaturesLoaded = disco.containsKey(account.getDomain()) && disco.containsKey(account.getJid().asBareJid());
}
} else {
advancedStreamFeaturesLoaded = false;
}
if (advancedStreamFeaturesLoaded) {
enableAdvancedStreamFeatures();
}
}
if (packet.getType() != IqPacket.TYPE.TIMEOUT) {
if (mPendingServiceDiscoveries.decrementAndGet() == 0 && mWaitForDisco.compareAndSet(true, false)) {
finalizeBind();
}
}
});
}
use of eu.siacs.conversations.entities.ServiceDiscoveryResult in project Conversations by siacs.
the class DatabaseBackend method findDiscoveryResult.
public ServiceDiscoveryResult findDiscoveryResult(final String hash, final String ver) {
SQLiteDatabase db = this.getReadableDatabase();
String[] selectionArgs = { hash, ver };
Cursor cursor = db.query(ServiceDiscoveryResult.TABLENAME, null, ServiceDiscoveryResult.HASH + "=? AND " + ServiceDiscoveryResult.VER + "=?", selectionArgs, null, null, null);
if (cursor.getCount() == 0) {
cursor.close();
return null;
}
cursor.moveToFirst();
ServiceDiscoveryResult result = null;
try {
result = new ServiceDiscoveryResult(cursor);
} catch (JSONException e) {
/* result is still null */
}
cursor.close();
return result;
}
Aggregations