1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2025-12-16 10:01:08 +01:00

Add MucBookmarkAutojoinManager

Also add MucConfigFormManager and improve the MUC API (SMACK-648). Bump
to jxmpp 0.5.0-alpha3.

Improve and extend PrivateDataManager and BookmarkManager.
This commit is contained in:
Florian Schmaus 2015-04-21 19:05:22 +02:00
parent 265e5c69d5
commit f274581c27
15 changed files with 690 additions and 102 deletions

View file

@ -24,6 +24,7 @@ import org.jivesoftware.smack.SmackException.NotConnectedException;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.XMPPError.Condition;
import org.jivesoftware.smack.provider.IQProvider;
import org.jivesoftware.smackx.iqprivate.packet.DefaultPrivateData;
import org.jivesoftware.smackx.iqprivate.packet.PrivateData;
@ -184,6 +185,51 @@ public final class PrivateDataManager extends Manager {
connection().createPacketCollectorAndSend(privateDataSet).nextResultOrThrow();
}
private static final PrivateData DUMMY_PRIVATE_DATA = new PrivateData() {
@Override
public String getElementName() {
return "smackDummyPrivateData";
}
@Override
public String getNamespace() {
return "https://igniterealtime.org/projects/smack/";
}
@Override
public CharSequence toXML() {
return '<' + getElementName() + " xmlns='" + getNamespace() + "'/>";
}
};
/**
* Check if the service supports private data.
*
* @return true if the service supports private data, false otherwise.
* @throws NoResponseException
* @throws NotConnectedException
* @throws InterruptedException
* @throws XMPPErrorException
* @since 4.2
*/
public boolean isSupported() throws NoResponseException, NotConnectedException,
InterruptedException, XMPPErrorException {
// This is just a primitive hack, since XEP-49 does not specify a way to determine if the
// service supports it
try {
setPrivateData(DUMMY_PRIVATE_DATA);
return true;
}
catch (XMPPErrorException e) {
if (e.getXMPPError().getCondition() == Condition.service_unavailable) {
return false;
}
else {
throw e;
}
}
}
/**
* An IQ provider to parse IQ results containing private data.
*/