Package rocks.xmpp.extensions.privacy.model

Examples of rocks.xmpp.extensions.privacy.model.Privacy$Active


        Assert.assertEquals(xml, "<iq from=\"romeo@example.net/orchard\" id=\"getlist1\" type=\"get\"><query xmlns=\"jabber:iq:privacy\"><default name=\"special\"></default></query></iq>");
    }

    @Test
    public void marshalDeclineDefaultListRequest() throws XMLStreamException, JAXBException {
        Privacy privacy = new Privacy();
        privacy.setDefaultName("");
        IQ iq = new IQ(IQ.Type.GET, privacy);
        iq.setFrom(Jid.valueOf("romeo@example.net/orchard"));
        iq.setId("getlist1");
        String xml = marshal(iq);
        Assert.assertEquals(xml, "<iq from=\"romeo@example.net/orchard\" id=\"getlist1\" type=\"get\"><query xmlns=\"jabber:iq:privacy\"><default></default></query></iq>");
View Full Code Here


    }

    @Test
    public void marshalPrivacyRule() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = new PrivacyList("test", Arrays.asList(new PrivacyRule(PrivacyRule.Action.ALLOW, 0, Contact.Subscription.BOTH)));
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"test\"><item type=\"subscription\" value=\"both\" action=\"allow\" order=\"0\"></item></list></query>");
    }
View Full Code Here

    }

    @Test
    public void marshalInvisibilityList() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityList();
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible\"><item action=\"deny\" order=\"1\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

    }

    @Test
    public void marshalInvisibilityListForUsers() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListForUsers("invisible-to-Gandalf", Jid.valueOf("gandalf@tolkien.lit"));
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible-to-Gandalf\"><item type=\"jid\" value=\"gandalf@tolkien.lit\" action=\"deny\" order=\"1\"><presence-out></presence-out></item><item action=\"allow\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

    }

    @Test
    public void marshalInvisibilityListForGroups() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListForGroups("invisible-to-Wizards", "Wizards");
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"invisible-to-Wizards\"><item type=\"group\" value=\"Wizards\" action=\"deny\" order=\"1\"><presence-out></presence-out></item><item action=\"allow\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

    }

    @Test
    public void marshalInvisibilityListExceptForUsers() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListExceptForUsers("visible-to-Frodo", Jid.valueOf("frodo@tolkien.lit"));
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"visible-to-Frodo\"><item type=\"jid\" value=\"frodo@tolkien.lit\" action=\"allow\" order=\"1\"><presence-out></presence-out></item><item action=\"deny\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

    }

    @Test
    public void marshalInvisibilityListExceptForGroups() throws XMLStreamException, JAXBException {
        PrivacyList privacyList = PrivacyList.createInvisibilityListExceptForGroups("visible-to-Bagginses", "Bagginses");
        String xml = marshal(new Privacy(privacyList));
        Assert.assertEquals(xml, "<query xmlns=\"jabber:iq:privacy\"><list name=\"visible-to-Bagginses\"><item type=\"group\" value=\"Bagginses\" action=\"allow\" order=\"1\"><presence-out></presence-out></item><item action=\"deny\" order=\"2\"><presence-out></presence-out></item></list></query>");
    }
View Full Code Here

                if (e.isIncoming() && !e.isConsumed() && iq.getType() == IQ.Type.SET && (iq.getFrom() == null || iq.getFrom().equals(xmppSession.getConnectedResource().asBareJid()))) {
                    // In accordance with the semantics of IQ stanzas defined in XMPP Core [7], each connected resource MUST return an IQ result to the server as well.
                    xmppSession.send(iq.createResult());
                    e.consume();

                    Privacy privacy = iq.getExtension(Privacy.class);
                    if (privacy != null) {
                        List<PrivacyList> privacyLists = privacy.getPrivacyLists();
                        if (privacyLists.size() == 1) {
                            // Notify the listeners about the reception.
                            for (PrivacyListListener privacyListListener : privacyListListeners) {
                                privacyListListener.privacyListUpdated(new PrivacyListEvent(PrivacyListManager.this, privacyLists.get(0).getName()));
                            }
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0016.html#protocol-retrieve">2.3 Retrieving One's Privacy Lists</a>
     */
    public Collection<PrivacyList> getPrivacyLists() throws XmppException {
        IQ result = xmppSession.query(new IQ(IQ.Type.GET, new Privacy()));
        Privacy privacy = result.getExtension(Privacy.class);

        List<PrivacyList> privacyLists = new ArrayList<>();
        for (PrivacyList privacyList : privacy.getPrivacyLists()) {
            if (privacyList.getName() != null && privacyList.getName().equals(privacy.getDefaultName())) {
                privacyLists.add(privacyList.asDefault());
            }
            if (privacyList.getName() != null && privacyList.getName().equals(privacy.getActiveName())) {
                privacyLists.add(privacyList.asActive());
            }
        }
        return privacyLists;
    }
View Full Code Here

     * @throws rocks.xmpp.core.stanza.model.StanzaException If the entity returned a stanza error.
     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0016.html#protocol-retrieve">2.3 Retrieving One's Privacy Lists</a>
     */
    public PrivacyList getPrivacyList(String name) throws XmppException {
        IQ result = xmppSession.query(new IQ(IQ.Type.GET, new Privacy(new PrivacyList(name))));
        Privacy privacy = result.getExtension(Privacy.class);
        if (privacy != null) {
            return privacy.getPrivacyLists().get(0);
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.privacy.model.Privacy$Active

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.