Package rocks.xmpp.extensions.data.model

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


                "  </uri>\n" +
                "   </media>" +
                "  </field>\n" +
                "</x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getType(), DataForm.Type.FORM);
        Media media = dataForm.getFields().get(0).getMedia();
        Assert.assertNotNull(media);
        Assert.assertEquals(media.getHeight(), 0);
        Assert.assertEquals(media.getWidth(), 0);
    }
View Full Code Here


                "      <uri type='image/jpeg'>cid:sha1+f24030b8d91d233bac14777be5ab531ca3b9f102@bob.xmpp.org</uri>\n" +
                "    </media>\n" +
                "  </field>\n" +
                "</x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getType(), DataForm.Type.FORM);
        Media media = dataForm.getFields().get(0).getMedia();
        Assert.assertNotNull(media);
        Assert.assertEquals(media.getHeight(), 80);
        Assert.assertEquals(media.getWidth(), 290);
        Assert.assertEquals(media.getLocations().size(), 2);
        Assert.assertEquals(media.getLocations().get(0).getType(), "image/jpeg");
View Full Code Here

                "  </field>\n" +
                "  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>\n" +
                "  </field>\n" +
                "</x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 3);
        Assert.assertEquals(dataForm.getPages().get(0).getText().size(), 2);
        Assert.assertEquals(dataForm.getPages().get(0).getText().get(0), "This is page one of three.");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().size(), 5);
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(0).getVar(), "name.first");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(1).getVar(), "name.last");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(2).getVar(), "email");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(3).getVar(), "jid");
        Assert.assertEquals(dataForm.getPages().get(0).getFieldReferences().get(4).getVar(), "background");
    }
View Full Code Here

                "  </field>\n" +
                "  <field var='activity.xeps' type='text-multi' label='XEPs Authored or Co-Authored'>\n" +
                "  </field>\n" +
                "</x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().size(), 3);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getLabel(), "Personal Information");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getText().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(0).getVar(), "name.first");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(1).getVar(), "name.last");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(2).getVar(), "email");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(3).getVar(), "jid");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(4).getVar(), "background");
    }
View Full Code Here

                "      <fieldref var='reasoning'/>\n" +
                "    </section>\n" +
                "  </page>\n" +
                "</x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().size(), 3);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getLabel(), "Personal Information");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().size(), 2);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(0).getFieldReferences().get(0).getVar(), "name.first");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(0).getFieldReferences().get(1).getVar(), "name.last");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(1).getFieldReferences().get(0).getVar(), "email");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getSections().get(1).getFieldReferences().get(1).getVar(), "jid");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getFieldReferences().get(0).getVar(), "background");
    }
View Full Code Here

                "    </section>\n" +
                "    <reportedref var='background'/>\n" +
                "  </page>\n" +
                "</x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getPages().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getSections().size(), 1);
        Assert.assertEquals(dataForm.getPages().get(0).getReportedReference().getVar(), "background");
        Assert.assertEquals(dataForm.getPages().get(0).getSections().get(0).getReportedReference().getVar(), "name.first");
    }
View Full Code Here

     *
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#requestvoice">7.13 Requesting Voice</a>
     */
    public void requestVoice() {
        Message message = new Message(roomJid);
        DataForm dataForm = new DataForm(DataForm.Type.SUBMIT);
        RequestVoiceForm requestVoiceForm = new RequestVoiceForm(dataForm);
        requestVoiceForm.setRole(Role.PARTICIPANT);
        message.getExtensions().add(dataForm);
        xmppSession.send(message);
    }
View Full Code Here

     * @throws rocks.xmpp.core.session.NoResponseException  If the entity did not respond.
     * @see <a href="http://xmpp.org/extensions/xep-0045.html#createroom-instant">10.1.2 Creating an Instant Room</a>
     */
    public void createRoom() throws XmppException {
        enter(nick);
        xmppSession.query(new IQ(roomJid, IQ.Type.SET, new MucOwner(new DataForm(DataForm.Type.SUBMIT))));
    }
View Full Code Here

                "             var='invitelist'>\n" +
                "        <desc>Tell all your friends about your new bot!</desc>\n" +
                "      </field>\n" +
                "    </x>\n";

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

        Assert.assertNotNull(dataForm);
        Assert.assertEquals(dataForm.getType(), DataForm.Type.FORM);
        Assert.assertEquals(dataForm.getTitle(), "Bot Configuration");
        Assert.assertEquals(dataForm.getInstructions().get(0), "Fill out this form to configure your new bot!");

        Assert.assertEquals(dataForm.getFields().size(), 12);
        Assert.assertEquals(dataForm.getFields().get(0).getValues().get(0), "jabber:bot");
        Assert.assertEquals(dataForm.getFields().get(0).getType(), DataForm.Field.Type.HIDDEN);
        Assert.assertEquals(dataForm.getFields().get(0).getVar(), "FORM_TYPE");

        Assert.assertEquals(dataForm.getFields().get(1).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(1).getValues().get(0), "Section 1: Bot Info");

        Assert.assertEquals(dataForm.getFields().get(2).getType(), DataForm.Field.Type.TEXT_SINGLE);
        Assert.assertEquals(dataForm.getFields().get(2).getVar(), "botname");
        Assert.assertEquals(dataForm.getFields().get(2).getLabel(), "The name of your bot");

        Assert.assertEquals(dataForm.getFields().get(3).getType(), DataForm.Field.Type.TEXT_MULTI);
        Assert.assertEquals(dataForm.getFields().get(3).getVar(), "description");
        Assert.assertEquals(dataForm.getFields().get(3).getLabel(), "Helpful description of your bot");

        Assert.assertEquals(dataForm.getFields().get(4).getType(), DataForm.Field.Type.BOOLEAN);
        Assert.assertEquals(dataForm.getFields().get(4).getVar(), "public");
        Assert.assertEquals(dataForm.getFields().get(4).getLabel(), "Public bot?");

        Assert.assertEquals(dataForm.getFields().get(5).getType(), DataForm.Field.Type.TEXT_PRIVATE);
        Assert.assertEquals(dataForm.getFields().get(5).getVar(), "password");
        Assert.assertEquals(dataForm.getFields().get(5).getLabel(), "Password for special access");

        Assert.assertEquals(dataForm.getFields().get(6).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(6).getValues().get(0), "Section 2: Features");

        Assert.assertEquals(dataForm.getFields().get(7).getType(), DataForm.Field.Type.LIST_MULTI);
        Assert.assertEquals(dataForm.getFields().get(7).getVar(), "features");
        Assert.assertEquals(dataForm.getFields().get(7).getLabel(), "What features will the bot support?");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().size(), 5);
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(0).getLabel(), "Contests");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(0).getValue(), "contests");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(1).getLabel(), "News");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(1).getValue(), "news");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(2).getLabel(), "Polls");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(2).getValue(), "polls");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(3).getLabel(), "Reminders");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(3).getValue(), "reminders");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(4).getLabel(), "Search");
        Assert.assertEquals(dataForm.getFields().get(7).getOptions().get(4).getValue(), "search");
        Assert.assertEquals(dataForm.getFields().get(7).getValues().get(0), "news");
        Assert.assertEquals(dataForm.getFields().get(7).getValues().get(1), "search");

        Assert.assertEquals(dataForm.getFields().get(8).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(8).getValues().get(0), "Section 3: Subscriber List");

        Assert.assertEquals(dataForm.getFields().get(9).getType(), DataForm.Field.Type.LIST_SINGLE);
        Assert.assertEquals(dataForm.getFields().get(9).getVar(), "maxsubs");
        Assert.assertEquals(dataForm.getFields().get(9).getLabel(), "Maximum number of subscribers");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().size(), 6);
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(0).getLabel(), "10");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(0).getValue(), "10");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(1).getLabel(), "20");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(1).getValue(), "20");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(2).getLabel(), "30");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(2).getValue(), "30");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(3).getLabel(), "50");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(3).getValue(), "50");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(4).getLabel(), "100");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(4).getValue(), "100");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(5).getLabel(), "None");
        Assert.assertEquals(dataForm.getFields().get(9).getOptions().get(5).getValue(), "none");
        Assert.assertEquals(dataForm.getFields().get(9).getValues().get(0), "20");

        Assert.assertEquals(dataForm.getFields().get(10).getType(), DataForm.Field.Type.FIXED);
        Assert.assertEquals(dataForm.getFields().get(10).getValues().get(0), "Section 4: Invitations");

        Assert.assertEquals(dataForm.getFields().get(11).getType(), DataForm.Field.Type.JID_MULTI);
        Assert.assertEquals(dataForm.getFields().get(11).getVar(), "invitelist");
        Assert.assertEquals(dataForm.getFields().get(11).getLabel(), "People to invite");

        Assert.assertNotNull(dataForm.findField("FORM_TYPE"));
    }
View Full Code Here

     */
    public int requestNumberOfMessages() throws XmppException {
        ServiceDiscoveryManager serviceDiscoveryManager = xmppSession.getExtensionManager(ServiceDiscoveryManager.class);
        InfoNode infoDiscovery = serviceDiscoveryManager.discoverInformation(null, OfflineMessage.NAMESPACE);
        if (!infoDiscovery.getExtensions().isEmpty()) {
            DataForm dataForm = infoDiscovery.getExtensions().get(0);
            if (dataForm != null) {
                for (DataForm.Field field : dataForm.getFields()) {
                    if ("number_of_messages".equals(field.getVar())) {
                        String numberOfMessages = field.getValues().get(0);
                        return Integer.parseInt(numberOfMessages);
                    }
                }
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.