Package rocks.xmpp.extensions.data.model

Examples of rocks.xmpp.extensions.data.model.DataForm


        features.add(new Feature("http://jabber.org/protocol/disco#info"));
        features.add(new Feature("http://jabber.org/protocol/disco#items"));
        features.add(new Feature("http://jabber.org/protocol/muc"));
        features.add(new Feature("http://jabber.org/protocol/caps"));

        DataForm dataForm1 = new DataForm(DataForm.Type.FORM);
        dataForm1.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "ccc"));
        dataForm1.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE"));

        DataForm dataForm2 = new DataForm(DataForm.Type.FORM);
        dataForm2.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "bbb"));

        DataForm dataForm3 = new DataForm(DataForm.Type.FORM);
        dataForm3.getFields().add(new DataForm.Field(DataForm.Field.Type.HIDDEN, "FORM_TYPE"));
        dataForm3.getFields().add(new DataForm.Field(DataForm.Field.Type.BOOLEAN, "aaa"));

        InfoDiscovery infoDiscovery = new InfoDiscovery();
        infoDiscovery.getFeatures().addAll(features);
        infoDiscovery.getIdentities().addAll(identities);
        infoDiscovery.getExtensions().add(dataForm1);
View Full Code Here


                "             label='Associated pubsub node'>\n" +
                "        <value>xmpp:pubsub.shakespeare.lit?;node=the-coven-node</value>\n" +
                "      </field>\n" +
                "    </x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        RoomInfoForm roomInfoForm = new RoomInfoForm(dataForm);

        Assert.assertEquals(roomInfoForm.getDescription(), "The place for all good witches!");
        Assert.assertTrue(roomInfoForm.isChangeSubjectAllowed());
View Full Code Here

        Assert.assertEquals(roomInfoForm.getMaxHistoryMessages(), 50);
    }

    @Test
    public void testEmptyDataForm() throws MalformedURLException {
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
        RoomInfoForm roomInfoForm = new RoomInfoForm(dataForm);
        roomInfoForm.setMaxHistoryMessages(50);
        DataForm.Field fieldHistoryFetch = dataForm.findField("muc#maxhistoryfetch");
        Assert.assertNotNull(fieldHistoryFetch);
        Assert.assertEquals(fieldHistoryFetch.getValues().size(), 1);
        Assert.assertEquals(fieldHistoryFetch.getValues().get(0), "50");
        Assert.assertEquals(roomInfoForm.getMaxHistoryMessages(), 50);

        roomInfoForm.setContacts(Arrays.asList(Jid.valueOf("test1@domain"), Jid.valueOf("test2@domain")));
        DataForm.Field fieldAdministrators = dataForm.findField("muc#roominfo_contactjid");
        Assert.assertNotNull(fieldAdministrators);
        Assert.assertEquals(fieldAdministrators.getValues().size(), 2);
        Assert.assertEquals(fieldAdministrators.getValues().get(0), "test1@domain");
        Assert.assertEquals(fieldAdministrators.getValues().get(1), "test2@domain");
        Assert.assertEquals(roomInfoForm.getContacts(), Arrays.asList(Jid.valueOf("test1@domain"), Jid.valueOf("test2@domain")));

        roomInfoForm.setDescription("Description");
        DataForm.Field fieldDescription = dataForm.findField("muc#roominfo_description");
        Assert.assertNotNull(fieldDescription);
        Assert.assertEquals(fieldDescription.getValues().size(), 1);
        Assert.assertEquals(fieldDescription.getValues().get(0), "Description");
        Assert.assertEquals(roomInfoForm.getDescription(), "Description");

        roomInfoForm.setLanguage("en");
        DataForm.Field fieldLanguage = dataForm.findField("muc#roominfo_lang");
        Assert.assertNotNull(fieldLanguage);
        Assert.assertEquals(fieldLanguage.getValues().size(), 1);
        Assert.assertEquals(fieldLanguage.getValues().get(0), "en");
        Assert.assertEquals(roomInfoForm.getLanguage(), "en");

        roomInfoForm.setLdapGroup("ldap");
        DataForm.Field fieldLdap = dataForm.findField("muc#roominfo_ldapgroup");
        Assert.assertNotNull(fieldLdap);
        Assert.assertEquals(fieldLdap.getValues().size(), 1);
        Assert.assertEquals(fieldLdap.getValues().get(0), "ldap");
        Assert.assertEquals(roomInfoForm.getLdapGroup(), "ldap");

        roomInfoForm.setLogs(new URL("http://www.example.net"));
        DataForm.Field fieldLogs = dataForm.findField("muc#roominfo_logs");
        Assert.assertNotNull(fieldLogs);
        Assert.assertEquals(fieldLogs.getValues().size(), 1);
        Assert.assertEquals(fieldLogs.getValues().get(0), "http://www.example.net");
        Assert.assertEquals(roomInfoForm.getLogs(), new URL("http://www.example.net"));

        roomInfoForm.setCurrentNumberOfOccupants(4);
        DataForm.Field fieldOccupants = dataForm.findField("muc#roominfo_occupants");
        Assert.assertNotNull(fieldOccupants);
        Assert.assertEquals(fieldOccupants.getValues().size(), 1);
        Assert.assertEquals(fieldOccupants.getValues().get(0), "4");
        Assert.assertEquals(roomInfoForm.getCurrentNumberOfOccupants(), 4);

        roomInfoForm.setSubject("test");
        DataForm.Field fieldSubject = dataForm.findField("muc#roominfo_subject");
        Assert.assertNotNull(fieldSubject);
        Assert.assertEquals(fieldSubject.getValues().size(), 1);
        Assert.assertEquals(fieldSubject.getValues().get(0), "test");
        Assert.assertEquals(roomInfoForm.getSubject(), "test");

        roomInfoForm.setChangeSubjectAllowed(true);
        DataForm.Field fieldMembersOnly = dataForm.findField("muc#roominfo_subjectmod");
        Assert.assertNotNull(fieldMembersOnly);
        Assert.assertEquals(fieldMembersOnly.getValues().size(), 1);
        Assert.assertEquals(fieldMembersOnly.getValues().get(0), "1");
        Assert.assertTrue(roomInfoForm.isChangeSubjectAllowed());
    }
View Full Code Here

        Assert.assertEquals(mucAdmin.getItems().get(0).getReason(), "Treason");
    }

    @Test
    public void marshalCreateInstantRoom() throws JAXBException, XMLStreamException {
        MucOwner mucOwner = new MucOwner(new DataForm(DataForm.Type.SUBMIT));
        String xml = marshal(mucOwner);
        Assert.assertEquals(xml, "<query xmlns=\"http://jabber.org/protocol/muc#owner\"><x xmlns=\"jabber:x:data\" type=\"submit\"></x></query>");
    }
View Full Code Here

                    if (streamInitiation != null) {
                        FeatureNegotiation featureNegotiation = streamInitiation.getFeatureNegotiation();
                        // Assume no valid streams by default, unless valid streams are found.
                        boolean noValidStreams = true;
                        if (featureNegotiation != null) {
                            DataForm dataForm = featureNegotiation.getDataForm();
                            if (dataForm != null) {
                                DataForm.Field field = dataForm.findField(STREAM_METHOD);
                                if (field != null) {
                                    List<String> streamMethods = new ArrayList<>();
                                    for (DataForm.Option option : field.getOptions()) {
                                        streamMethods.add(option.getValue());
                                    }
View Full Code Here

        // Create a random id for the stream session.
        String sessionId = UUID.randomUUID().toString();

        // Offer stream methods.
        DataForm dataForm = new DataForm(DataForm.Type.FORM);
        DataForm.Field field = new DataForm.Field(DataForm.Field.Type.LIST_SINGLE, STREAM_METHOD);
        for (String streamMethod : supportedStreamMethod) {
            field.getOptions().add(new DataForm.Option(streamMethod));
        }
        dataForm.getFields().add(field);

        // Offer the file to the recipient and wait until it's accepted.
        IQ result = xmppSession.query(new IQ(receiver, IQ.Type.SET, new StreamInitiation(sessionId, SIFileTransferOffer.NAMESPACE, mimeType, profile, new FeatureNegotiation(dataForm))), timeout);

        // The recipient must response with a stream initiation.
View Full Code Here

        DataForm.Field field = streamInitiation.getFeatureNegotiation().getDataForm().findField(STREAM_METHOD);
        final List<String> offeredStreamMethods = new ArrayList<>();
        for (DataForm.Option option : field.getOptions()) {
            offeredStreamMethods.add(option.getValue());
        }
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
        DataForm.Field fieldReply = new DataForm.Field(DataForm.Field.Type.LIST_SINGLE, STREAM_METHOD);
        offeredStreamMethods.retainAll(supportedStreamMethod);
        fieldReply.getValues().addAll(offeredStreamMethods);
        dataForm.getFields().add(fieldReply);
        StreamInitiation siResponse = new StreamInitiation(new FeatureNegotiation(dataForm));

        final Lock lock = new ReentrantLock();
        final Condition byteStreamOpened = lock.newCondition();
        final ByteStreamSession[] byteStreamSessions = new ByteStreamSession[1];
View Full Code Here

                "    <field var='muc#request_allow'>\n" +
                "      <value>true</value>\n" +
                "    </field>\n" +
                "  </x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        RequestVoiceForm requestVoiceForm = new RequestVoiceForm(dataForm);

        Assert.assertEquals(requestVoiceForm.getRoomNick(), "thirdwitch");
        Assert.assertEquals(requestVoiceForm.getRole(), Role.PARTICIPANT);
View Full Code Here

        Assert.assertTrue(requestVoiceForm.isRequestAllowed());
    }

    @Test
    public void testEmptyDataForm() throws MalformedURLException {
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);

        RequestVoiceForm requestVoiceForm = new RequestVoiceForm(dataForm);
        requestVoiceForm.setJid(Jid.valueOf("hag66@shakespeare.lit/pda"));
        DataForm.Field fieldJid = dataForm.findField("muc#jid");
        Assert.assertNotNull(fieldJid);
        Assert.assertEquals(fieldJid.getValues().size(), 1);
        Assert.assertEquals(fieldJid.getValues().get(0), "hag66@shakespeare.lit/pda");
        Assert.assertEquals(requestVoiceForm.getJid(), Jid.valueOf("hag66@shakespeare.lit/pda"));

        requestVoiceForm.setRoomNick("thirdwitch");
        DataForm.Field fieldRoomNick = dataForm.findField("muc#roomnick");
        Assert.assertNotNull(fieldRoomNick);
        Assert.assertEquals(fieldRoomNick.getValues().size(), 1);
        Assert.assertEquals(fieldRoomNick.getValues().get(0), "thirdwitch");
        Assert.assertEquals(requestVoiceForm.getRoomNick(), "thirdwitch");

        requestVoiceForm.setRole(Role.PARTICIPANT);
        DataForm.Field fieldRole = dataForm.findField("muc#role");
        Assert.assertNotNull(fieldRole);
        Assert.assertEquals(fieldRole.getValues().size(), 1);
        Assert.assertEquals(fieldRole.getValues().get(0), "participant");
        Assert.assertEquals(requestVoiceForm.getRole(), Role.PARTICIPANT);

        requestVoiceForm.setRequestAllowed(true);
        DataForm.Field fieldAllow = dataForm.findField("muc#request_allow");
        Assert.assertNotNull(fieldAllow);
        Assert.assertEquals(fieldAllow.getValues().size(), 1);
        Assert.assertEquals(fieldAllow.getValues().get(0), "1");
        Assert.assertTrue(requestVoiceForm.isRequestAllowed());
    }
View Full Code Here

                "          label='Room Owners'\n" +
                "          type='jid-multi'\n" +
                "          var='muc#roomconfig_roomowners'/>\n" +
                "    </x>\n";

        DataForm dataForm = unmarshal(xml, DataForm.class);

        RoomConfigurationForm roomConfigurationForm = new RoomConfigurationForm(dataForm);

        Assert.assertEquals(roomConfigurationForm.getRoomName(), "A Dark Cave");
        Assert.assertEquals(roomConfigurationForm.getRoomDescription(), "The place for all good witches!");
View Full Code Here

TOP

Related Classes of rocks.xmpp.extensions.data.model.DataForm

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.