use of com.xabber.xmpp.smack.XMPPTCPConnection in project xabber-android by redsolution.
the class ServerInfoActivity method getServerInfo.
@NonNull
List<String> getServerInfo(ServiceDiscoveryManager serviceDiscoveryManager) {
final List<String> serverInfoList = new ArrayList<>();
XMPPTCPConnection connection = accountItem.getConnection();
if (!connection.isAuthenticated()) {
serverInfoList.add(getString(R.string.NOT_CONNECTED));
return serverInfoList;
}
try {
boolean muc = !MultiUserChatManager.getInstanceFor(connection).getXMPPServiceDomains().isEmpty();
boolean pep = PEPManager.getInstanceFor(connection).isSupported();
boolean blockingCommand = BlockingCommandManager.getInstanceFor(connection).isSupportedByServer();
boolean sm = connection.isSmAvailable();
boolean rosterVersioning = Roster.getInstanceFor(connection).isRosterVersioningSupported();
boolean carbons = org.jivesoftware.smackx.carbons.CarbonManager.getInstanceFor(connection).isSupportedByServer();
boolean mam = MamManager.getInstanceFor(connection).isSupportedByServer();
boolean csi = ClientStateIndicationManager.isSupported(connection);
boolean push = PushManager.getInstance().isSupport(connection);
boolean fileUpload = HttpFileUploadManager.getInstance().isFileUploadSupported(accountItem.getAccount());
boolean mucLight = !MultiUserChatLightManager.getInstanceFor(connection).getLocalServices().isEmpty();
boolean bookmarks = BookmarksManager.getInstance().isSupported(accountItem.getAccount());
serverInfoList.add(getString(R.string.xep_0045_muc) + " " + getCheckOrCross(muc));
serverInfoList.add(getString(R.string.xep_0163_pep) + " " + getCheckOrCross(pep));
serverInfoList.add(getString(R.string.xep_0191_blocking) + " " + getCheckOrCross(blockingCommand));
serverInfoList.add(getString(R.string.xep_0198_sm) + " " + getCheckOrCross(sm));
serverInfoList.add(getString(R.string.xep_0237_roster_ver) + " " + getCheckOrCross(rosterVersioning));
serverInfoList.add(getString(R.string.xep_0280_carbons) + " " + getCheckOrCross(carbons));
serverInfoList.add(getString(R.string.xep_0313_mam) + " " + getCheckOrCross(mam));
serverInfoList.add(getString(R.string.xep_0352_csi) + " " + getCheckOrCross(csi));
serverInfoList.add(getString(R.string.xep_0357_push) + " " + getCheckOrCross(push));
serverInfoList.add(getString(R.string.xep_0363_file_upload) + " " + getCheckOrCross(fileUpload));
serverInfoList.add(getString(R.string.xep_xxxx_muc_light) + " " + getCheckOrCross(mucLight));
serverInfoList.add(getString(R.string.xep_0048_bookmarks) + " " + getCheckOrCross(bookmarks));
serverInfoList.add("");
} catch (InterruptedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {
LogManager.exception(LOG_TAG, e);
}
DomainBareJid xmppServiceDomain = connection.getXMPPServiceDomain();
try {
DiscoverInfo discoverInfo = serviceDiscoveryManager.discoverInfo(xmppServiceDomain);
List<DiscoverInfo.Identity> identities = discoverInfo.getIdentities();
if (!identities.isEmpty()) {
serverInfoList.add(getString(R.string.identities));
for (DiscoverInfo.Identity identity : identities) {
serverInfoList.add(identity.getCategory() + " " + identity.getType() + " " + identity.getName());
}
serverInfoList.add("");
}
if (!discoverInfo.getFeatures().isEmpty()) {
serverInfoList.add(getString(R.string.features));
for (DiscoverInfo.Feature feature : discoverInfo.getFeatures()) {
serverInfoList.add(feature.getVar());
}
serverInfoList.add("");
}
DiscoverItems items = serviceDiscoveryManager.discoverItems(xmppServiceDomain);
if (!items.getItems().isEmpty()) {
serverInfoList.add(getString(R.string.items));
for (DiscoverItems.Item item : items.getItems()) {
serverInfoList.add(item.getEntityID().toString());
}
}
} catch (InterruptedException | SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException e) {
LogManager.exception(LOG_TAG, e);
}
if (serverInfoList.isEmpty()) {
serverInfoList.add(getString(R.string.SERVER_INFO_ERROR));
}
return serverInfoList;
}
use of com.xabber.xmpp.smack.XMPPTCPConnection in project xabber-android by redsolution.
the class PrivateStorageManager method setPrivateData.
private void setPrivateData(AccountJid accountJid, PrivateData privateData) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem == null || !accountItem.isEnabled())
return;
XMPPTCPConnection connection = accountItem.getConnection();
PrivateDataManager privateDataManager = PrivateDataManager.getInstanceFor(connection);
try {
if (!privateDataManager.isSupported())
return;
privateDataManager.setPrivateData(privateData);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException | IllegalArgumentException e) {
e.printStackTrace();
}
}
use of com.xabber.xmpp.smack.XMPPTCPConnection in project xabber-android by redsolution.
the class BlockingManager method getBlockingCommandManager.
@SuppressWarnings("WeakerAccess")
@Nullable
BlockingCommandManager getBlockingCommandManager(AccountJid account) {
AccountItem accountItem = AccountManager.getInstance().getAccount(account);
if (accountItem == null) {
return null;
}
XMPPTCPConnection connection = accountItem.getConnection();
// "Must have a local (user) JID set. Either you didn't configure one or you where not connected at least once"
if (connection.getUser() == null) {
return null;
}
return BlockingCommandManager.getInstanceFor(connection);
}
use of com.xabber.xmpp.smack.XMPPTCPConnection in project xabber-android by redsolution.
the class NextMamManager method requestToMessageArchive.
/**
* T extends MamManager.MamQueryResult or T extends MamManager.MamPrefsResult
*/
private <T> T requestToMessageArchive(AccountItem accountItem, MamRequest<T> request) {
T result = null;
XMPPTCPConnection connection = accountItem.getConnection();
if (connection.isAuthenticated()) {
MamManager mamManager = MamManager.getInstanceFor(connection);
try {
result = request.execute(mamManager);
} catch (Exception e) {
LogManager.exception(this, e);
}
}
return result;
}
use of com.xabber.xmpp.smack.XMPPTCPConnection in project xabber-android by redsolution.
the class PrivateStorageManager method getPrivateData.
@Nullable
private PrivateData getPrivateData(AccountJid accountJid, String namespace, String elementName) {
AccountItem accountItem = AccountManager.getInstance().getAccount(accountJid);
if (accountItem == null || !accountItem.isEnabled())
return null;
XMPPTCPConnection connection = accountItem.getConnection();
PrivateDataManager privateDataManager = PrivateDataManager.getInstanceFor(connection);
try {
if (!privateDataManager.isSupported())
return null;
return privateDataManager.getPrivateData(elementName, namespace);
} catch (SmackException.NoResponseException | XMPPException.XMPPErrorException | SmackException.NotConnectedException | InterruptedException | IllegalArgumentException e) {
e.printStackTrace();
return null;
}
}
Aggregations