Search in sources :

Example 6 with MessageEvent

use of org.jivesoftware.smackx.packet.MessageEvent in project ecf by eclipse.

the class MessageEventProvider method parseExtension.

/**
 * Parses a MessageEvent packet (extension sub-packet).
 *
 * @param parser the XML parser, positioned at the starting element of the extension.
 * @return a PacketExtension.
 * @throws Exception if a parsing error occurs.
 */
public PacketExtension parseExtension(XmlPullParser parser) throws Exception {
    MessageEvent messageEvent = new MessageEvent();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            if (parser.getName().equals("id"))
                messageEvent.setPacketID(parser.nextText());
            if (parser.getName().equals(MessageEvent.COMPOSING))
                messageEvent.setComposing(true);
            if (parser.getName().equals(MessageEvent.DELIVERED))
                messageEvent.setDelivered(true);
            if (parser.getName().equals(MessageEvent.DISPLAYED))
                messageEvent.setDisplayed(true);
            if (parser.getName().equals(MessageEvent.OFFLINE))
                messageEvent.setOffline(true);
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("x")) {
                done = true;
            }
        }
    }
    return messageEvent;
}
Also used : MessageEvent(org.jivesoftware.smackx.packet.MessageEvent)

Example 7 with MessageEvent

use of org.jivesoftware.smackx.packet.MessageEvent in project ecf by eclipse.

the class MessageEventManager method sendCancelledNotification.

/**
 * Sends the notification that the receiver of the message has cancelled composing a reply.
 *
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendCancelledNotification(String to, String packetID) {
    // Create the message to send
    Message msg = new Message(to);
    // Create a MessageEvent Package and add it to the message
    MessageEvent messageEvent = new MessageEvent();
    messageEvent.setCancelled(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
Also used : Message(org.jivesoftware.smack.packet.Message) MessageEvent(org.jivesoftware.smackx.packet.MessageEvent)

Aggregations

MessageEvent (org.jivesoftware.smackx.packet.MessageEvent)7 Message (org.jivesoftware.smack.packet.Message)5 Iterator (java.util.Iterator)1 PacketListener (org.jivesoftware.smack.PacketListener)1 Packet (org.jivesoftware.smack.packet.Packet)1