Java 类org.jivesoftware.smack.packet.XMPPError.Condition 实例源码

项目:Smack    文件:EntityTimeManager.java   
private EntityTimeManager(XMPPConnection connection) {
    super(connection);
    if (autoEnable)
        enable();

    connection.registerIQRequestHandler(new AbstractIqRequestHandler(Time.ELEMENT, Time.NAMESPACE, Type.get,
                    Mode.async) {
        @Override
        public IQ handleIQRequest(IQ iqRequest) {
            if (enabled) {
                return Time.createResponse(iqRequest);
            }
            else {
                return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable));
            }
        }
    });
}
项目:Smack    文件:VersionManager.java   
private VersionManager(final XMPPConnection connection) {
    super(connection);

    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(connection);
    sdm.addFeature(Version.NAMESPACE);

    connection.registerIQRequestHandler(new AbstractIqRequestHandler(Version.ELEMENT, Version.NAMESPACE, IQ.Type.get,
                    Mode.async) {
        @Override
        public IQ handleIQRequest(IQ iqRequest) {
            if (ourVersion == null) {
                return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.not_acceptable));
            }

            return Version.createResultFor(iqRequest, ourVersion);
        }
    });
}
项目:Smack    文件:ConfigureFormTest.java   
@Test
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException, IOException
{
    ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
    PubSubManager mgr = new PubSubManager(con);
    DiscoverInfo info = new DiscoverInfo();
    Identity ident = new Identity("pubsub", null, "leaf");
    info.addIdentity(ident);
    con.addIQReply(info);

    Node node = mgr.getNode("princely_musings");

    PubSub errorIq = new PubSub();
    XMPPError error = new XMPPError(Condition.forbidden);
    errorIq.setError(error);
    con.addIQReply(errorIq);

    try
    {
        node.getNodeConfiguration();
    }
    catch (XMPPErrorException e)
    {
        Assert.assertEquals(XMPPError.Type.AUTH, e.getXMPPError().getType());
    }
}
项目:Smack    文件:Roster.java   
@Override
public IQ handleIQRequest(IQ iqRequest) {
    final XMPPConnection connection = connection();
    RosterPacket rosterPacket = (RosterPacket) iqRequest;

    // Roster push (RFC 6121, 2.1.6)
    // A roster push with a non-empty from not matching our address MUST be ignored
    String jid = XmppStringUtils.parseBareJid(connection.getUser());
    String from = rosterPacket.getFrom();
    if (from != null && !from.equals(jid)) {
        LOGGER.warning("Ignoring roster push with a non matching 'from' ourJid='" + jid + "' from='" + from
                        + "'");
        return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.service_unavailable));
    }

    // A roster push must contain exactly one entry
    Collection<Item> items = rosterPacket.getRosterItems();
    if (items.size() != 1) {
        LOGGER.warning("Ignoring roster push with not exaclty one entry. size=" + items.size());
        return IQ.createErrorResponse(iqRequest, new XMPPError(Condition.bad_request));
    }

    Collection<String> addedEntries = new ArrayList<String>();
    Collection<String> updatedEntries = new ArrayList<String>();
    Collection<String> deletedEntries = new ArrayList<String>();
    Collection<String> unchangedEntries = new ArrayList<String>();

    // We assured above that the size of items is exaclty 1, therefore we are able to
    // safely retrieve this single item here.
    Item item = items.iterator().next();
    RosterEntry entry = new RosterEntry(item.getUser(), item.getName(),
                    item.getItemType(), item.getItemStatus(), Roster.this, connection);
    String version = rosterPacket.getVersion();

    if (item.getItemType().equals(RosterPacket.ItemType.remove)) {
        deleteEntry(deletedEntries, entry);
        if (rosterStore != null) {
            rosterStore.removeEntry(entry.getUser(), version);
        }
    }
    else if (hasValidSubscriptionType(item)) {
        addUpdateEntry(addedEntries, updatedEntries, unchangedEntries, item, entry);
        if (rosterStore != null) {
            rosterStore.addEntry(item, version);
        }
    }

    removeEmptyGroups();

    // Fire event for roster listeners.
    fireRosterChangedEvent(addedEntries, updatedEntries, deletedEntries);

    return IQ.createResultIQ(rosterPacket);
}
项目:desktopclient-java    文件:Control.java   
public void onMessageError(MessageIDs ids, Condition condition, String errorText) {
    OutMessage message = this.findMessage(ids).orElse(null);
    if (message == null)
        return ;
    message.setServerError(condition.toString(), errorText);
}