Java 类org.jivesoftware.smackx.receipts.DeliveryReceiptRequest 实例源码

项目:XmppTest    文件:SmackImpl.java   
@Override
public void sendMessage(String toJID, String message) {// 发送消息
    // TODO Auto-generated method stub
    final Message newMessage = new Message(toJID, Message.Type.chat);
    newMessage.setBody(message);
    newMessage.addExtension(new DeliveryReceiptRequest());
    if (isAuthenticated()) {
        addChatMessageToDB(ChatConstants.OUTGOING, toJID, message,
                ChatConstants.DS_SENT_OR_READ, System.currentTimeMillis(),
                newMessage.getPacketID());
        mXMPPConnection.sendPacket(newMessage);
    } else {
        // send offline -> store to DB
        addChatMessageToDB(ChatConstants.OUTGOING, toJID, message,
                ChatConstants.DS_NEW, System.currentTimeMillis(),
                newMessage.getPacketID());
    }
}
项目:smartedu    文件:SmackImpl.java   
@Override
public void sendMessage(String toJID, String message) {// 发送消息
    // TODO Auto-generated method stub
    final Message newMessage = new Message(toJID, Message.Type.chat);
    newMessage.setBody(message);
    newMessage.addExtension(new DeliveryReceiptRequest());
    if (isAuthenticated()) {
        addChatMessageToDB(ChatConstants.OUTGOING, toJID, message,
                ChatConstants.DS_SENT_OR_READ, System.currentTimeMillis(),
                newMessage.getPacketID());
        mXMPPConnection.sendPacket(newMessage);
    } else {
        // send offline -> store to DB
        addChatMessageToDB(ChatConstants.OUTGOING, toJID, message,
                ChatConstants.DS_NEW, System.currentTimeMillis(),
                newMessage.getPacketID());
    }
}
项目:XmppTest    文件:SmackImpl.java   
static void registerSmackProviders() {
    ProviderManager pm = ProviderManager.getInstance();
    // add IQ handling
    pm.addIQProvider("query", "http://jabber.org/protocol/disco#info",
            new DiscoverInfoProvider());
    // add delayed delivery notifications
    pm.addExtensionProvider("delay", "urn:xmpp:delay",
            new DelayInfoProvider());
    pm.addExtensionProvider("x", "jabber:x:delay", new DelayInfoProvider());
    // add carbons and forwarding
    pm.addExtensionProvider("forwarded", Forwarded.NAMESPACE,
            new Forwarded.Provider());
    pm.addExtensionProvider("sent", Carbon.NAMESPACE, new Carbon.Provider());
    pm.addExtensionProvider("received", Carbon.NAMESPACE,
            new Carbon.Provider());
    // add delivery receipts
    pm.addExtensionProvider(DeliveryReceipt.ELEMENT,
            DeliveryReceipt.NAMESPACE, new DeliveryReceipt.Provider());
    pm.addExtensionProvider(DeliveryReceiptRequest.ELEMENT,
            DeliveryReceipt.NAMESPACE,
            new DeliveryReceiptRequest.Provider());
    // add XMPP Ping (XEP-0199)
    pm.addIQProvider("ping", "urn:xmpp:ping", new PingProvider());

    ServiceDiscoveryManager.setIdentityName(XMPP_IDENTITY_NAME);
    ServiceDiscoveryManager.setIdentityType(XMPP_IDENTITY_TYPE);
}
项目:androidclient    文件:KontalkConnection.java   
private AckPredicate() {
    super(new StanzaFilter() {
        @Override
        public boolean accept(Stanza packet) {
            return (packet instanceof Message &&
                (((Message) packet).getBody() != null ||
                  DeliveryReceipt.from((Message) packet) != null ||
                   DeliveryReceiptRequest.from(packet) != null));
        }
    }, 5);
}
项目:smartedu    文件:SmackImpl.java   
static void registerSmackProviders() {
    ProviderManager pm = ProviderManager.getInstance();
    // add IQ handling
    pm.addIQProvider("query", "http://jabber.org/protocol/disco#info",
            new DiscoverInfoProvider());
    // add delayed delivery notifications
    pm.addExtensionProvider("delay", "urn:xmpp:delay",
            new DelayInfoProvider());
    pm.addExtensionProvider("x", "jabber:x:delay", new DelayInfoProvider());
    // add carbons and forwarding
    pm.addExtensionProvider("forwarded", Forwarded.NAMESPACE,
            new Forwarded.Provider());
    pm.addExtensionProvider("sent", Carbon.NAMESPACE, new Carbon.Provider());
    pm.addExtensionProvider("received", Carbon.NAMESPACE,
            new Carbon.Provider());
    // add delivery receipts
    pm.addExtensionProvider(DeliveryReceipt.ELEMENT,
            DeliveryReceipt.NAMESPACE, new DeliveryReceipt.Provider());
    pm.addExtensionProvider(DeliveryReceiptRequest.ELEMENT,
            DeliveryReceipt.NAMESPACE,
            new DeliveryReceiptRequest.Provider());
    // add XMPP Ping (XEP-0199)
    pm.addIQProvider("ping", "urn:xmpp:ping", new PingProvider());

    ServiceDiscoveryManager.setIdentityName(XMPP_IDENTITY_NAME);
    ServiceDiscoveryManager.setIdentityType(XMPP_IDENTITY_TYPE);
}
项目:maven-yaxim    文件:SmackableImp.java   
static void registerSmackProviders() {
    ProviderManager pm = ProviderManager.getInstance();
    // add IQ handling
    pm.addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
    pm.addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
    // add delayed delivery notifications
    pm.addExtensionProvider("delay","urn:xmpp:delay", new DelayInfoProvider());
    pm.addExtensionProvider("x","jabber:x:delay", new DelayInfoProvider());
    // add XEP-0092 Software Version
    pm.addIQProvider("query", Version.NAMESPACE, new Version.Provider());

    // add carbons and forwarding
    pm.addExtensionProvider("forwarded", Forwarded.NAMESPACE, new Forwarded.Provider());
    pm.addExtensionProvider("sent", Carbon.NAMESPACE, new Carbon.Provider());
    pm.addExtensionProvider("received", Carbon.NAMESPACE, new Carbon.Provider());
    // add delivery receipts
    pm.addExtensionProvider(DeliveryReceipt.ELEMENT, DeliveryReceipt.NAMESPACE, new DeliveryReceipt.Provider());
    pm.addExtensionProvider(DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE, new DeliveryReceiptRequest.Provider());
    // add XMPP Ping (XEP-0199)
    pm.addIQProvider("ping","urn:xmpp:ping", new PingProvider());

    ServiceDiscoveryManager.setDefaultIdentity(YAXIM_IDENTITY);

    // XEP-0115 Entity Capabilities
    pm.addExtensionProvider("c", "http://jabber.org/protocol/caps", new CapsExtensionProvider());

    XmppStreamHandler.addExtensionProviders();
}
项目:maven-yaxim    文件:SmackableImp.java   
public void sendOfflineMessages() {
    Cursor cursor = mContentResolver.query(ChatProvider.CONTENT_URI,
            SEND_OFFLINE_PROJECTION, SEND_OFFLINE_SELECTION,
            null, null);
    final int      _ID_COL = cursor.getColumnIndexOrThrow(ChatConstants._ID);
    final int      JID_COL = cursor.getColumnIndexOrThrow(ChatConstants.JID);
    final int      MSG_COL = cursor.getColumnIndexOrThrow(ChatConstants.MESSAGE);
    final int       TS_COL = cursor.getColumnIndexOrThrow(ChatConstants.DATE);
    final int PACKETID_COL = cursor.getColumnIndexOrThrow(ChatConstants.PACKET_ID);
    ContentValues mark_sent = new ContentValues();
    mark_sent.put(ChatConstants.DELIVERY_STATUS, ChatConstants.DS_SENT_OR_READ);
    while (cursor.moveToNext()) {
        int _id = cursor.getInt(_ID_COL);
        String toJID = cursor.getString(JID_COL);
        String message = cursor.getString(MSG_COL);
        String packetID = cursor.getString(PACKETID_COL);
        long ts = cursor.getLong(TS_COL);
        Log.d(TAG, "sendOfflineMessages: " + toJID + " > " + message);
        final Message newMessage = new Message(toJID, Message.Type.chat);
        newMessage.setBody(message);
        DelayInformation delay = new DelayInformation(new Date(ts));
        newMessage.addExtension(delay);
        newMessage.addExtension(new DelayInfo(delay));
        newMessage.addExtension(new DeliveryReceiptRequest());
        if ((packetID != null) && (packetID.length() > 0)) {
            newMessage.setPacketID(packetID);
        } else {
            packetID = newMessage.getPacketID();
            mark_sent.put(ChatConstants.PACKET_ID, packetID);
        }
        Uri rowuri = Uri.parse("content://" + ChatProvider.AUTHORITY
            + "/" + ChatProvider.TABLE_NAME + "/" + _id);
        mContentResolver.update(rowuri, mark_sent,
                    null, null);
        mXMPPConnection.sendPacket(newMessage);     // must be after marking delivered, otherwise it may override the SendFailListener
    }
    cursor.close();
}
项目:maven-yaxim    文件:SmackableImp.java   
public void sendMessage(String toJID, String message) {
    final Message newMessage = new Message(toJID, Message.Type.chat);
    newMessage.setBody(message);
    newMessage.addExtension(new DeliveryReceiptRequest());
    if (isAuthenticated()) {
        addChatMessageToDB(ChatConstants.OUTGOING, toJID, message, ChatConstants.DS_SENT_OR_READ,
                System.currentTimeMillis(), newMessage.getPacketID());
        mXMPPConnection.sendPacket(newMessage);
    } else {
        // send offline -> store to DB
        addChatMessageToDB(ChatConstants.OUTGOING, toJID, message, ChatConstants.DS_NEW,
                System.currentTimeMillis(), newMessage.getPacketID());
    }
}
项目:XmppTest    文件:SmackImpl.java   
/***************** start 发送离线消息 ***********************/
public void sendOfflineMessages() {
    Cursor cursor = mContentResolver.query(ChatProvider.CONTENT_URI,
            SEND_OFFLINE_PROJECTION, SEND_OFFLINE_SELECTION, null, null);// 查询数据库获取离线消息游标
    final int _ID_COL = cursor.getColumnIndexOrThrow(ChatConstants._ID);
    final int JID_COL = cursor.getColumnIndexOrThrow(ChatConstants.JID);
    final int MSG_COL = cursor.getColumnIndexOrThrow(ChatConstants.MESSAGE);
    final int TS_COL = cursor.getColumnIndexOrThrow(ChatConstants.DATE);
    final int PACKETID_COL = cursor
            .getColumnIndexOrThrow(ChatConstants.PACKET_ID);
    ContentValues mark_sent = new ContentValues();
    mark_sent.put(ChatConstants.DELIVERY_STATUS,
            ChatConstants.DS_SENT_OR_READ);
    while (cursor.moveToNext()) {// 遍历之后将离线消息发出
        int _id = cursor.getInt(_ID_COL);
        String toJID = cursor.getString(JID_COL);
        String message = cursor.getString(MSG_COL);
        String packetID = cursor.getString(PACKETID_COL);
        long ts = cursor.getLong(TS_COL);
        L.d("sendOfflineMessages: " + toJID + " > " + message);
        final Message newMessage = new Message(toJID, Message.Type.chat);
        newMessage.setBody(message);
        DelayInformation delay = new DelayInformation(new Date(ts));
        newMessage.addExtension(delay);
        newMessage.addExtension(new DelayInfo(delay));
        newMessage.addExtension(new DeliveryReceiptRequest());
        if ((packetID != null) && (packetID.length() > 0)) {
            newMessage.setPacketID(packetID);
        } else {
            packetID = newMessage.getPacketID();
            mark_sent.put(ChatConstants.PACKET_ID, packetID);
        }
        Uri rowuri = Uri.parse("content://" + ChatProvider.AUTHORITY + "/"
                + ChatProvider.TABLE_NAME + "/" + _id);
        // 将消息标记为已发送再调用发送,因为,假设此消息又未发送成功,有SendFailListener重新标记消息
        mContentResolver.update(rowuri, mark_sent, null, null);
        mXMPPConnection.sendPacket(newMessage); // must be after marking
                                                // delivered, otherwise it
                                                // may override the
                                                // SendFailListener
    }
    cursor.close();
}
项目:desktopclient-java    文件:KonMessageListener.java   
private void processChatMessage(Message m) {
    LOGGER.config("message: "+m);
    // note: thread and subject are null if message comes from the Kontalk
    // Android client

    MessageIDs ids = MessageIDs.from(m);

    Date delayDate = getDelay(m);

    // process possible chat state notification (XEP-0085)
    ExtensionElement csExt = m.getExtension(ChatStateExtension.NAMESPACE);
    ChatState chatState = null;
    if (csExt != null) {
        chatState = ((ChatStateExtension) csExt).getChatState();
        mControl.onChatStateNotification(ids,
                Optional.ofNullable(delayDate),
                chatState);
    }

    // must be an incoming message
    // get content/text from body and/or encryption/url extension
    MessageContent content = ClientUtils.parseMessageContent(m, false);

    // make sure not to save a message without content
    if (content.isEmpty()) {
        if (chatState == null) {
            LOGGER.warning("can't find any content in message");
        } else if (chatState == ChatState.active) {
            LOGGER.info("only active chat state");
        }
        return;
    }

    // add message
    mControl.onNewInMessage(ids, Optional.ofNullable(delayDate), content);

    // send a 'received' for a receipt request (XEP-0184)
    DeliveryReceiptRequest request = DeliveryReceiptRequest.from(m);
    if (request != null && !ids.xmppID.isEmpty()) {
        Message received = new Message(m.getFrom(), Message.Type.chat);
        received.addExtension(new DeliveryReceipt(ids.xmppID));
        mClient.sendPacket(received);
    }
}
项目:smartedu    文件:SmackImpl.java   
/***************** start 发送离线消息 ***********************/
public void sendOfflineMessages() {
    Cursor cursor = mContentResolver.query(ChatProvider.CONTENT_URI,
            SEND_OFFLINE_PROJECTION, SEND_OFFLINE_SELECTION, null, null);// 查询数据库获取离线消息游标
    final int _ID_COL = cursor.getColumnIndexOrThrow(ChatConstants._ID);
    final int JID_COL = cursor.getColumnIndexOrThrow(ChatConstants.JID);
    final int MSG_COL = cursor.getColumnIndexOrThrow(ChatConstants.MESSAGE);
    final int TS_COL = cursor.getColumnIndexOrThrow(ChatConstants.DATE);
    final int PACKETID_COL = cursor
            .getColumnIndexOrThrow(ChatConstants.PACKET_ID);
    ContentValues mark_sent = new ContentValues();
    mark_sent.put(ChatConstants.DELIVERY_STATUS,
            ChatConstants.DS_SENT_OR_READ);
    while (cursor.moveToNext()) {// 遍历之后将离线消息发出
        int _id = cursor.getInt(_ID_COL);
        String toJID = cursor.getString(JID_COL);
        String message = cursor.getString(MSG_COL);
        String packetID = cursor.getString(PACKETID_COL);
        long ts = cursor.getLong(TS_COL);
        AppLogger.d("sendOfflineMessages: " + toJID + " > " + message);
        final Message newMessage = new Message(toJID, Message.Type.chat);
        newMessage.setBody(message);
        DelayInformation delay = new DelayInformation(new Date(ts));
        newMessage.addExtension(delay);
        newMessage.addExtension(new DelayInfo(delay));
        newMessage.addExtension(new DeliveryReceiptRequest());
        if ((packetID != null) && (packetID.length() > 0)) {
            newMessage.setPacketID(packetID);
        } else {
            packetID = newMessage.getPacketID();
            mark_sent.put(ChatConstants.PACKET_ID, packetID);
        }
        Uri rowuri = Uri.parse("content://" + ChatProvider.AUTHORITY + "/"
                + ChatProvider.TABLE_NAME + "/" + _id);
        // 将消息标记为已发送再调用发送,因为,假设此消息又未发送成功,有SendFailListener重新标记消息
        mContentResolver.update(rowuri, mark_sent, null, null);
        mXMPPConnection.sendPacket(newMessage); // must be after marking
                                                // delivered, otherwise it
                                                // may override the
                                                // SendFailListener
    }
    cursor.close();
}