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:
parent
265e5c69d5
commit
f274581c27
15 changed files with 690 additions and 102 deletions
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue