Java 类org.jivesoftware.smackx.packet.MessageEvent 实例源码

项目:spark-svn-mirror    文件:ChatRoomImpl.java   
private void checkEvents(String from, String packetID, MessageEvent messageEvent) {
    if (messageEvent.isDelivered() || messageEvent.isDisplayed()) {
        // Create the message to send
        Message msg = new Message(from);
        // Create a MessageEvent Package and add it to the message
        MessageEvent event = new MessageEvent();
        if (messageEvent.isDelivered()) {
            event.setDelivered(true);
        }
        if (messageEvent.isDisplayed()) {
            event.setDisplayed(true);
        }
        event.setPacketID(packetID);
        msg.addExtension(event);
        // Send the packet
        SparkManager.getConnection().sendPacket(msg);
    }
}
项目:EIM    文件:MessageEventManager.java   
/**
 * Adds event notification requests to a message. For each event type that
 * the user wishes event notifications from the message recepient for, <tt>true</tt>
 * should be passed in to this method.
 * 
 * @param message the message to add the requested notifications.
 * @param offline specifies if the offline event is requested.
 * @param delivered specifies if the delivered event is requested.
 * @param displayed specifies if the displayed event is requested.
 * @param composing specifies if the composing event is requested.
 */
public static void addNotificationsRequests(Message message, boolean offline,
        boolean delivered, boolean displayed, boolean composing)
{
    // Create a MessageEvent Package and add it to the message
    MessageEvent messageEvent = new MessageEvent();
    messageEvent.setOffline(offline);
    messageEvent.setDelivered(delivered);
    messageEvent.setDisplayed(displayed);
    messageEvent.setComposing(composing);
    message.addExtension(messageEvent);
}
项目:EIM    文件:MessageEventManager.java   
private void init() {
    // Listens for all message event packets and fire the proper message event listeners.
    packetListener = new PacketListener() {
        public void processPacket(Packet packet) {
            Message message = (Message) packet;
            MessageEvent messageEvent =
                (MessageEvent) message.getExtension("x", "jabber:x:event");
            if (messageEvent.isMessageEventRequest()) {
                // Fire event for requests of message events
                for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventRequestListeners(
                        message.getFrom(),
                        message.getPacketID(),
                        ((String) it.next()).concat("NotificationRequested"));
            } else
                // Fire event for notifications of message events
                for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventNotificationListeners(
                        message.getFrom(),
                        messageEvent.getPacketID(),
                        ((String) it.next()).concat("Notification"));

        };

    };
    con.addPacketListener(packetListener, packetFilter);
}
项目:EIM    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was delivered to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDeliveredNotification(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.setDelivered(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:EIM    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was displayed to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDisplayedNotification(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.setDisplayed(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:EIM    文件:MessageEventManager.java   
/**
 * Sends the notification that the receiver of the message is composing a reply
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendComposingNotification(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.setComposing(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:EIM    文件:MessageEventManager.java   
/**
 * 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);
}
项目:EIM    文件:MessageEventProvider.java   
/**
 * 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;
}
项目:androidPN-client.    文件:MessageEventManager.java   
/**
 * Adds event notification requests to a message. For each event type that
 * the user wishes event notifications from the message recepient for, <tt>true</tt>
 * should be passed in to this method.
 * 
 * @param message the message to add the requested notifications.
 * @param offline specifies if the offline event is requested.
 * @param delivered specifies if the delivered event is requested.
 * @param displayed specifies if the displayed event is requested.
 * @param composing specifies if the composing event is requested.
 */
public static void addNotificationsRequests(Message message, boolean offline,
        boolean delivered, boolean displayed, boolean composing)
{
    // Create a MessageEvent Package and add it to the message
    MessageEvent messageEvent = new MessageEvent();
    messageEvent.setOffline(offline);
    messageEvent.setDelivered(delivered);
    messageEvent.setDisplayed(displayed);
    messageEvent.setComposing(composing);
    message.addExtension(messageEvent);
}
项目:androidPN-client.    文件:MessageEventManager.java   
private void init() {
    // Listens for all message event packets and fire the proper message event listeners.
    packetListener = new PacketListener() {
        public void processPacket(Packet packet) {
            Message message = (Message) packet;
            MessageEvent messageEvent =
                (MessageEvent) message.getExtension("x", "jabber:x:event");
            if (messageEvent.isMessageEventRequest()) {
                // Fire event for requests of message events
                for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventRequestListeners(
                        message.getFrom(),
                        message.getPacketID(),
                        it.next().concat("NotificationRequested"));
            } else
                // Fire event for notifications of message events
                for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventNotificationListeners(
                        message.getFrom(),
                        messageEvent.getPacketID(),
                        it.next().concat("Notification"));

        };

    };
    con.addPacketListener(packetListener, packetFilter);
}
项目:androidPN-client.    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was delivered to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDeliveredNotification(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.setDelivered(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:androidPN-client.    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was displayed to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDisplayedNotification(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.setDisplayed(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:androidPN-client.    文件:MessageEventManager.java   
/**
 * Sends the notification that the receiver of the message is composing a reply
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendComposingNotification(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.setComposing(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:androidPN-client.    文件:MessageEventManager.java   
/**
 * 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);
}
项目:androidPN-client.    文件:MessageEventProvider.java   
/**
 * 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;
}
项目:xmppsupport_v2    文件:MessageEventManager.java   
private void init() {
    // Listens for all message event packets and fire the proper message
    // event listeners.
    packetListener = new PacketListener() {
        public void processPacket(Packet packet) {
            Message message = (Message) packet;
            MessageEvent messageEvent = (MessageEvent) message
                    .getExtension("x", "jabber:x:event");
            if (messageEvent.isMessageEventRequest()) {
                // Fire event for requests of message events
                for (Iterator it = messageEvent.getEventTypes(); it
                        .hasNext();)
                    fireMessageEventRequestListeners(message.getFrom(),
                            message.getPacketID(),
                            ((String) it.next())
                                    .concat("NotificationRequested"));
            } else
                // Fire event for notifications of message events
                for (Iterator it = messageEvent.getEventTypes(); it
                        .hasNext();)
                    fireMessageEventNotificationListeners(
                            message.getFrom(), messageEvent.getPacketID(),
                            ((String) it.next()).concat("Notification"));

        };

    };
    con.addPacketListener(packetListener, packetFilter);
}
项目:xmppsupport_v2    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was delivered to the sender of
 * the original message
 * 
 * @param to
 *            the recipient of the notification.
 * @param packetID
 *            the id of the message to send.
 */
public void sendDeliveredNotification(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.setDelivered(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:xmppsupport_v2    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was displayed to the sender of
 * the original message
 * 
 * @param to
 *            the recipient of the notification.
 * @param packetID
 *            the id of the message to send.
 */
public void sendDisplayedNotification(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.setDisplayed(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:xmppsupport_v2    文件:MessageEventManager.java   
/**
 * Sends the notification that the receiver of the message is composing a
 * reply
 * 
 * @param to
 *            the recipient of the notification.
 * @param packetID
 *            the id of the message to send.
 */
public void sendComposingNotification(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.setComposing(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:xmppsupport_v2    文件:MessageEventManager.java   
/**
 * 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);
}
项目:xmppsupport_v2    文件:MessageEventProvider.java   
/**
 * 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;
}
项目:java-bells    文件:MessageEventManager.java   
/**
 * Adds event notification requests to a message. For each event type that
 * the user wishes event notifications from the message recepient for, <tt>true</tt>
 * should be passed in to this method.
 * 
 * @param message the message to add the requested notifications.
 * @param offline specifies if the offline event is requested.
 * @param delivered specifies if the delivered event is requested.
 * @param displayed specifies if the displayed event is requested.
 * @param composing specifies if the composing event is requested.
 */
public static void addNotificationsRequests(Message message, boolean offline,
        boolean delivered, boolean displayed, boolean composing)
{
    // Create a MessageEvent Package and add it to the message
    MessageEvent messageEvent = new MessageEvent();
    messageEvent.setOffline(offline);
    messageEvent.setDelivered(delivered);
    messageEvent.setDisplayed(displayed);
    messageEvent.setComposing(composing);
    message.addExtension(messageEvent);
}
项目:java-bells    文件:MessageEventManager.java   
private void init() {
    // Listens for all message event packets and fire the proper message event listeners.
    packetListener = new PacketListener() {
        public void processPacket(Packet packet) {
            Message message = (Message) packet;
            MessageEvent messageEvent =
                (MessageEvent) message.getExtension("x", "jabber:x:event");
            if (messageEvent.isMessageEventRequest()) {
                // Fire event for requests of message events
                for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventRequestListeners(
                        message.getFrom(),
                        message.getPacketID(),
                        it.next().concat("NotificationRequested"));
            } else
                // Fire event for notifications of message events
                for (Iterator<String> it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventNotificationListeners(
                        message.getFrom(),
                        messageEvent.getPacketID(),
                        it.next().concat("Notification"));

        };

    };
    con.addPacketListener(packetListener, packetFilter);
}
项目:java-bells    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was delivered to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDeliveredNotification(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.setDelivered(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:java-bells    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was displayed to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDisplayedNotification(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.setDisplayed(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:java-bells    文件:MessageEventManager.java   
/**
 * Sends the notification that the receiver of the message is composing a reply
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendComposingNotification(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.setComposing(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:java-bells    文件:MessageEventManager.java   
/**
 * 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);
}
项目:java-bells    文件:MessageEventProvider.java   
/**
 * 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;
}
项目:telegraph    文件:MessageEventManager.java   
/**
 * Adds event notification requests to a message. For each event type that
 * the user wishes event notifications from the message recepient for, <tt>true</tt>
 * should be passed in to this method.
 * 
 * @param message the message to add the requested notifications.
 * @param offline specifies if the offline event is requested.
 * @param delivered specifies if the delivered event is requested.
 * @param displayed specifies if the displayed event is requested.
 * @param composing specifies if the composing event is requested.
 */
public static void addNotificationsRequests(Message message, boolean offline,
        boolean delivered, boolean displayed, boolean composing)
{
    // Create a MessageEvent Package and add it to the message
    MessageEvent messageEvent = new MessageEvent();
    messageEvent.setOffline(offline);
    messageEvent.setDelivered(delivered);
    messageEvent.setDisplayed(displayed);
    messageEvent.setComposing(composing);
    message.addExtension(messageEvent);
}
项目:telegraph    文件:MessageEventManager.java   
private void init() {
    // Listens for all message event packets and fire the proper message event listeners.
    packetListener = new PacketListener() {
        public void processPacket(Packet packet) {
            Message message = (Message) packet;
            MessageEvent messageEvent =
                (MessageEvent) message.getExtension("x", "jabber:x:event");
            if (messageEvent.isMessageEventRequest()) {
                // Fire event for requests of message events
                for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventRequestListeners(
                        message.getFrom(),
                        message.getPacketID(),
                        ((String) it.next()).concat("NotificationRequested"));
            } else
                // Fire event for notifications of message events
                for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventNotificationListeners(
                        message.getFrom(),
                        messageEvent.getPacketID(),
                        ((String) it.next()).concat("Notification"));

        };

    };
    con.addPacketListener(packetListener, packetFilter);
}
项目:telegraph    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was delivered to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDeliveredNotification(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.setDelivered(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:telegraph    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was displayed to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDisplayedNotification(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.setDisplayed(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:telegraph    文件:MessageEventManager.java   
/**
 * Sends the notification that the receiver of the message is composing a reply
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendComposingNotification(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.setComposing(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:telegraph    文件:MessageEventManager.java   
/**
 * 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);
}
项目:telegraph    文件:MessageEventProvider.java   
/**
 * 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;
}
项目:NewCommunication-Android    文件:MessageEventManager.java   
/**
 * Adds event notification requests to a message. For each event type that
 * the user wishes event notifications from the message recepient for, <tt>true</tt>
 * should be passed in to this method.
 * 
 * @param message the message to add the requested notifications.
 * @param offline specifies if the offline event is requested.
 * @param delivered specifies if the delivered event is requested.
 * @param displayed specifies if the displayed event is requested.
 * @param composing specifies if the composing event is requested.
 */
public static void addNotificationsRequests(Message message, boolean offline,
        boolean delivered, boolean displayed, boolean composing)
{
    // Create a MessageEvent Package and add it to the message
    MessageEvent messageEvent = new MessageEvent();
    messageEvent.setOffline(offline);
    messageEvent.setDelivered(delivered);
    messageEvent.setDisplayed(displayed);
    messageEvent.setComposing(composing);
    message.addExtension(messageEvent);
}
项目:NewCommunication-Android    文件:MessageEventManager.java   
private void init() {
    // Listens for all message event packets and fire the proper message event listeners.
    packetListener = new PacketListener() {
        public void processPacket(Packet packet) {
            Message message = (Message) packet;
            MessageEvent messageEvent =
                (MessageEvent) message.getExtension("x", "jabber:x:event");
            if (messageEvent.isMessageEventRequest()) {
                // Fire event for requests of message events
                for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventRequestListeners(
                        message.getFrom(),
                        message.getPacketID(),
                        ((String) it.next()).concat("NotificationRequested"));
            } else
                // Fire event for notifications of message events
                for (Iterator it = messageEvent.getEventTypes(); it.hasNext();)
                    fireMessageEventNotificationListeners(
                        message.getFrom(),
                        messageEvent.getPacketID(),
                        ((String) it.next()).concat("Notification"));

        };

    };
    con.addPacketListener(packetListener, packetFilter);
}
项目:NewCommunication-Android    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was delivered to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDeliveredNotification(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.setDelivered(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:NewCommunication-Android    文件:MessageEventManager.java   
/**
 * Sends the notification that the message was displayed to the sender of the original message
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendDisplayedNotification(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.setDisplayed(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}
项目:NewCommunication-Android    文件:MessageEventManager.java   
/**
 * Sends the notification that the receiver of the message is composing a reply
 * 
 * @param to the recipient of the notification.
 * @param packetID the id of the message to send.
 */
public void sendComposingNotification(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.setComposing(true);
    messageEvent.setPacketID(packetID);
    msg.addExtension(messageEvent);
    // Send the packet
    con.sendPacket(msg);
}