Package org.jivesoftware.smackx.packet

Examples of org.jivesoftware.smackx.packet.DelayInformation


                return;
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    Date date = null;

                    DelayInformation inf = (DelayInformation) packet
                            .getExtension("x", "jabber:x:delay");
                    if (inf != null && inf.getStamp() != null)
                        date = inf.getStamp();

                    final String messageBody = packet.getBody();

                    String tempString = from;
                    int index = from.indexOf("/");
View Full Code Here


  public static String getSendDate(Message msg, Locale loc) {
    for (Iterator iter = msg.getExtensions().iterator(); iter.hasNext();) {
      PacketExtension extension = (PacketExtension) iter.next();
      if (extension.getNamespace().equals("jabber:x:delay")) {
        DelayInformation delayInfo = (DelayInformation) extension;
        Date date = delayInfo.getStamp();
        // why does formatter with this method return a time in the afternoon
        // like 03:24 instead of 15:24 like formatTime does??
        return Formatter.getInstance(loc).formatDateAndTime(date);
      }
    }
View Full Code Here

    spheneEvent.setParam(EVENT_PARAM_ALREADYHANDLED,alreadyHandled);
    changeListener.fireEvent(spheneEvent);
    topComposite.getDisplay().asyncExec(new Runnable() {
      public void run() {
        String packetId = message.getPacketID();
        DelayInformation delay = (DelayInformation) message
            .getExtension("x", "jabber:x:delay");
        Date date = null;
        if (delay == null)
          date = new Date();
        else
          date = delay.getStamp();
        String msg = null;
        if(styledTextHistory != null) {
          msg = message.getBody();
        } else {
          msg = escapeMessageString(message.getBody());
View Full Code Here

                        }
                    }

                    Date date = null;
                    String append = "";
                    DelayInformation inf = (DelayInformation) packet
                            .getExtension("x", "jabber:x:delay");
                    if (inf != null
                            && buddy.getConversation() instanceof ChatPanel) {

                            append = " (" + resources.getString( "offline" ).toLowerCase();
                            if( inf.getReason() != null && !inf.getReason().equals( "" )) append += ": " + inf.getReason();

                            append += ")";

                         if (inf.getStamp() != null)
                            date = inf.getStamp();
                    }

                    buddy.getConversation().receiveMessage(messageSbj,
                            append, messageBody, resource, date, decryptedFlag,
                            verifiedFlag);
View Full Code Here

                if (messageBody == null)
                    return;

                Date date = new Date();

                DelayInformation inf = (DelayInformation) packet.getExtension(
                        "x", "jabber:x:delay");
                if (inf != null && inf.getStamp() != null)
                    date = inf.getStamp();

                buddy.getConversation().receiveMessage("", "", messageBody, null,
                        date, false, false);
            }
        });
View Full Code Here

   
    public void processPacket(Packet packet)
    {
          EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
      ItemsExtension itemsElem = (ItemsExtension)event.getEvent();
      DelayInformation delay = (DelayInformation)packet.getExtension("delay", "urn:xmpp:delay");
     
      // If there was no delay based on XEP-0203, then try XEP-0091 for backward compatibility
      if (delay == null)
      {
        delay = (DelayInformation)packet.getExtension("x", "jabber:x:delay");
      }
      ItemPublishEvent eventItems = new ItemPublishEvent(itemsElem.getNode(), (List<Item>)itemsElem.getItems(), getSubscriptionIds(packet), (delay == null ? null : delay.getStamp()));
      listener.handlePublishedItems(eventItems);
    }
View Full Code Here

    }

    @Test
    public void delayInformationTest() throws Exception {
        DelayInformationProvider p = new DelayInformationProvider();
        DelayInformation delayInfo;
        XmlPullParser parser;
        String control;
        GregorianCalendar calendar = new GregorianCalendar(2002, 9 - 1, 10, 23, 8, 25);
        calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
        Date date = calendar.getTime();
       
        control = XMLBuilder.create("x")
            .a("xmlns", "jabber:x:delay")
            .a("from", "capulet.com")
            .a("stamp", "2002-09-10T23:08:25Z")
            .t("Offline Storage")
            .asString(outputProperties);
       
        parser = getParser(control, "x");
        delayInfo = (DelayInformation) p.parseExtension(parser);
       
        assertEquals("capulet.com", delayInfo.getFrom());
        assertEquals(date, delayInfo.getStamp());
        assertEquals("Offline Storage", delayInfo.getReason());

        assertEquals(XmlPullParser.END_TAG, parser.getEventType());
        assertEquals("x", parser.getName());

        control = XMLBuilder.create("x")
            .a("xmlns", "jabber:x:delay")
            .a("from", "capulet.com")
            .a("stamp", "2002-09-10T23:08:25Z")
            .asString(outputProperties);
       
        parser = getParser(control, "x");
        delayInfo = (DelayInformation) p.parseExtension(parser);

        assertEquals("capulet.com", delayInfo.getFrom());
        assertEquals(date, delayInfo.getStamp());
        assertNull(delayInfo.getReason());

        assertEquals(XmlPullParser.END_TAG, parser.getEventType());
        assertEquals("x", parser.getName());

    }
View Full Code Here

            Message msg;
            // Get first historic message
            msg = muc2.nextMessage(1000);
            assertNotNull("First message is null", msg);
            DelayInformation delay = (DelayInformation) msg.getExtension("x", "jabber:x:delay");
            assertNotNull("Message contains no delay information", delay);
            SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
            UTC_FORMAT.setTimeZone(TimeZone.getDefault());
            System.out.println(UTC_FORMAT.format(delay.getStamp()));

            assertEquals("Body of first message is incorrect", "Message 3", msg.getBody());
            // Try to get second historic message
            msg = muc2.nextMessage(1000);
            assertNull("Second message is not null", msg);
View Full Code Here

         */
        if (stamp == null) {
            stamp = new Date();
        }
       
        DelayInformation delayInformation = new DelayInformation(stamp);
        delayInformation.setFrom(parser.getAttributeValue("", "from"));
        String reason = parser.nextText();

        /*
         * parser.nextText() returns empty string if there is no reason.
         * DelayInformation API specifies that null should be returned in that
         * case.
         */
        reason = "".equals(reason) ? null : reason;
        delayInformation.setReason(reason);
       
        return delayInformation;
    }
View Full Code Here

                        "class org.jivesoftware.smack.packet.Message")) {
                    Message m = (Message) packet;

                    if (m.getBody() != null) {
                        //System.out.println("Body is " + m.getBody());
                        DelayInformation inf = null;
                        try {
                            inf = (DelayInformation) packet.getExtension("x",
                                    "jabber:x:delay");

                            // get offline message timestamp
                            System.out.println("Inf:" + inf + ",PacketType:");
                            if (inf != null) {

                                Map<String, String> messages = new HashMap<String, String>();
                                String[] username = m.getFrom().split("/");
                                messages.put("from", username[0]);
                                messages.put("message", m.getBody());
                                // Date date = inf.getStamp();
                                messages.put("time", inf.getStamp().toString());
                                System.out.println("Adding offline:" + messages);
                                offlines.add(messages);
                            }
                        } catch (Exception e) {
                            // log.error(e);
View Full Code Here

TOP

Related Classes of org.jivesoftware.smackx.packet.DelayInformation

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.