• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java DelayInformation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.jivesoftware.smackx.delay.packet.DelayInformation的典型用法代码示例。如果您正苦于以下问题:Java DelayInformation类的具体用法?Java DelayInformation怎么用?Java DelayInformation使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



DelayInformation类属于org.jivesoftware.smackx.delay.packet包,在下文中一共展示了DelayInformation类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDelay

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
private static Date getDelay(Message m) {
    // first: new XEP-0203 specification
    ExtensionElement delay = DelayInformation.from(m);

    // fallback: obsolete XEP-0091 specification
    if (delay == null) {
        delay = m.getExtension("x", "jabber:x:delay");
    }

    if (delay instanceof DelayInformation) {
        Date date = ((DelayInformation) delay).getStamp();
        if (date.after(new Date()))
            LOGGER.warning("delay time is in future: "+date);
        return date;
    }

    return null;
}
 
开发者ID:kontalk,项目名称:desktopclient-java,代码行数:19,代码来源:KonMessageListener.java


示例2: getDelayInformation

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
/**
 * Get Delayed Delivery information. This method first looks for a PacketExtension with the
 * XEP-203 namespace and falls back to the XEP-91 namespace.
 *
 * @param packet
 * @return the Delayed Delivery information or <code>null</code>
 */
public static DelayInformation getDelayInformation(Stanza packet) {
    DelayInformation delayInformation = getXep203DelayInformation(packet);
    if (delayInformation != null) {
        return delayInformation;
    }
    return getLegacyDelayInformation(packet);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:15,代码来源:DelayInformationManager.java


示例3: getDelayTimestamp

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
/**
 * Get the Delayed Delivery timestamp or <code>null</code>
 *
 * @param packet
 * @return the Delayed Delivery timestamp or <code>null</code>
 */
public static Date getDelayTimestamp(Stanza packet) {
    DelayInformation delayInformation = getDelayInformation(packet);
    if (delayInformation == null) {
        return null;
    }
    return delayInformation.getStamp();
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:DelayInformationManager.java


示例4: parse

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
@Override
public final DelayInformation parse(XmlPullParser parser,
                int initialDepth) throws XmlPullParserException,
                IOException, SmackException {
    String stampString = (parser.getAttributeValue("", "stamp"));
    String from = parser.getAttributeValue("", "from");
    String reason = null;
    if (!parser.isEmptyElementTag()) {
        int event = parser.next();
        switch (event) {
        case XmlPullParser.TEXT:
            reason = parser.getText();
            parser.next();
            break;
        case XmlPullParser.END_TAG:
            reason = "";
            break;
        default:
            throw new IllegalStateException("Unexpected event: " + event);
        }
    } else {
        parser.next();
    }
    Date stamp;
    try {
        stamp = parseDate(stampString);
    } catch (ParseException e) {
        throw new SmackException(e);
    }
    return new DelayInformation(stamp, from, reason);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:32,代码来源:AbstractDelayInformationProvider.java


示例5: parse

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
@Override
public Forwarded parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException {
    DelayInformation di = null;
    Stanza packet = null;

    outerloop: while (true) {
        int eventType = parser.next();
        switch (eventType) {
        case XmlPullParser.START_TAG:
            String name = parser.getName();
            String namespace = parser.getNamespace();
            switch (name) {
            case DelayInformation.ELEMENT:
                if (DelayInformation.NAMESPACE.equals(namespace)) {
                    di = DelayInformationProvider.INSTANCE.parse(parser, parser.getDepth());
                } else {
                    LOGGER.warning("Namespace '" + namespace + "' does not match expected namespace '"
                                    + DelayInformation.NAMESPACE + "'");
                }
                break;
            case Message.ELEMENT:
                packet = PacketParserUtils.parseMessage(parser);
                break;
            default:
                LOGGER.warning("Unsupported forwarded packet type: " + name);
            }
            break;
        case XmlPullParser.END_TAG:
            if (parser.getDepth() == initialDepth) {
                break outerloop;
            }
            break;
        }
    }

    if (packet == null)
        throw new SmackException("forwarded extension must contain a packet");
    return new Forwarded(di, packet);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:40,代码来源:ForwardedProvider.java


示例6: validatePresenceWithDelayedDelivery

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
@Test
public void validatePresenceWithDelayedDelivery() throws Exception {
    String stanza = "<presence from='[email protected]' to='[email protected]'>"
            + "<delay xmlns='urn:xmpp:delay' stamp='2002-09-10T23:41:07Z'/></presence>";

    Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
    
    DelayInformation delay = DelayInformationManager.getXep203DelayInformation(presence);
    assertNotNull(delay);
    Date date = XmppDateTime.parseDate("2002-09-10T23:41:07Z");
    assertEquals(date, delay.getStamp());
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:13,代码来源:DelayInformationTest.java


示例7: parsePresenceWithInvalidLegacyDelayed

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
@Test
public void parsePresenceWithInvalidLegacyDelayed() throws Exception {
    String stanza = "<presence from='[email protected]' to='[email protected]'>"
                    + "<x xmlns='jabber:x:delay'/></presence>";

    Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
    DelayInformation delay = DelayInformationManager.getXep203DelayInformation(presence);
    assertNull((Object)delay);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:10,代码来源:DelayInformationTest.java


示例8: getStanzaDelay

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
public static Date getStanzaDelay(Stanza packet) {
    ExtensionElement _delay = packet.getExtension("delay", "urn:xmpp:delay");
    if (_delay == null)
        _delay = packet.getExtension("x", "jabber:x:delay");

    Date stamp = null;
    if (_delay != null) {
        if (_delay instanceof DelayInformation) {
            stamp = ((DelayInformation) _delay).getStamp();
        }
    }

    return stamp;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:15,代码来源:XMPPUtils.java


示例9: createIntent

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
public static Intent createIntent(Context ctx, Presence p, RosterEntry entry) {
    Intent i = new Intent(ACTION_PRESENCE);
    Presence.Type type = p.getType();
    i.putExtra(EXTRA_TYPE, type != null ? type.name() : Presence.Type.available.name());
    i.putExtra(EXTRA_PACKET_ID, p.getStanzaId());

    i.putExtra(EXTRA_FROM, StringUtils.maybeToString(p.getFrom().toString()));
    i.putExtra(EXTRA_TO, StringUtils.maybeToString(p.getTo()));
    i.putExtra(EXTRA_STATUS, p.getStatus());
    Presence.Mode mode = p.getMode();
    i.putExtra(EXTRA_SHOW, mode != null ? mode.name() : Presence.Mode.available.name());
    i.putExtra(EXTRA_PRIORITY, p.getPriority());

    String jid = p.getFrom().asBareJid().toString();

    long timestamp;
    DelayInformation delay = p.getExtension(DelayInformation.ELEMENT, DelayInformation.NAMESPACE);
    if (delay != null) {
        timestamp = delay.getStamp().getTime();
    }
    else {
        // try last seen from database
        timestamp = UsersProvider.getLastSeen(ctx, jid);
        if (timestamp < 0)
            timestamp = System.currentTimeMillis();
    }

    i.putExtra(EXTRA_STAMP, timestamp);

    // public key fingerprint
    String fingerprint = PublicKeyPresence.getFingerprint(p);
    if (fingerprint == null) {
        // try untrusted fingerprint from database
        fingerprint = Keyring.getFingerprint(ctx, jid, MyUsers.Keys.TRUST_UNKNOWN);
    }
    i.putExtra(EXTRA_FINGERPRINT, fingerprint);

    // subscription information
    if (entry != null) {
        i.putExtra(EXTRA_ROSTER_NAME, entry.getName());

        RosterPacket.ItemType subscriptionType = entry.getType();
        i.putExtra(EXTRA_SUBSCRIBED_FROM, subscriptionType == RosterPacket.ItemType.both ||
            subscriptionType == RosterPacket.ItemType.from);
        i.putExtra(EXTRA_SUBSCRIBED_TO, subscriptionType == RosterPacket.ItemType.both ||
            subscriptionType == RosterPacket.ItemType.to);
    }

    return i;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:51,代码来源:PresenceListener.java


示例10: updateUsersDatabase

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
@SuppressWarnings("WeakerAccess")
int updateUsersDatabase(Presence p) {
    String jid = p.getFrom().asBareJid().toString();

    ContentValues values = new ContentValues(4);
    values.put(Users.REGISTERED, 1);

    // status
    String status = p.getStatus();
    if (status != null)
        values.put(Users.STATUS, status);
    else
        values.putNull(Users.STATUS);

    // delay
    long timestamp;
    DelayInformation delay = p.getExtension(DelayInformation.ELEMENT, DelayInformation.NAMESPACE);
    if (delay != null) {
        // delay from presence (rare)
        timestamp = delay.getStamp().getTime();
    }
    else {
        // logged in/out now
        timestamp = System.currentTimeMillis();
    }

    if (timestamp > 0)
        values.put(Users.LAST_SEEN, timestamp);

    // public key extension (for fingerprint)
    PublicKeyPresence pkey = p.getExtension(PublicKeyPresence.ELEMENT_NAME, PublicKeyPresence.NAMESPACE);
    if (pkey != null) {
        String fingerprint = pkey.getFingerprint();
        if (fingerprint != null) {
            // insert new key with empty key data
            Keyring.setKey(getContext(), jid, fingerprint, new Date());
        }
    }

    return getContext().getContentResolver().update(Users.CONTENT_URI,
        values, Users.JID + "=?", new String[] { jid });
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:43,代码来源:PresenceListener.java


示例11: handlePresence

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
private void handlePresence(Presence p) {
    Intent i = new Intent(ACTION_PRESENCE);
    Presence.Type type = p.getType();
    i.putExtra(EXTRA_TYPE, type != null ? type.name() : Presence.Type.available.name());
    i.putExtra(EXTRA_PACKET_ID, p.getPacketID());

    String from = p.getFrom();
    String network = StringUtils.parseServer(from);
    // our network - convert to userId
    if (network.equalsIgnoreCase(getServer().getNetwork())) {
        StringBuilder b = new StringBuilder();
        b.append(StringUtils.parseName(from));
        b.append(StringUtils.parseResource(from));
        i.putExtra(EXTRA_FROM_USERID, b.toString());
    }

    i.putExtra(EXTRA_FROM, from);
    i.putExtra(EXTRA_TO, p.getTo());
    i.putExtra(EXTRA_STATUS, p.getStatus());
    Presence.Mode mode = p.getMode();
    i.putExtra(EXTRA_SHOW, mode != null ? mode.name() : Presence.Mode.available.name());
    i.putExtra(EXTRA_PRIORITY, p.getPriority());

    // getExtension doesn't work here
    Iterator<PacketExtension> iter = p.getExtensions().iterator();
    while (iter.hasNext()) {
        PacketExtension _ext = iter.next();
        if (_ext instanceof DelayInformation) {
            DelayInformation delay = (DelayInformation) _ext;
            i.putExtra(EXTRA_STAMP, delay.getStamp().getTime());
            break;
        }
    }

    // non-standard stanza group extension
    PacketExtension ext = p.getExtension(StanzaGroupExtension.ELEMENT_NAME, StanzaGroupExtension.NAMESPACE);
    if (ext != null && ext instanceof StanzaGroupExtension) {
        StanzaGroupExtension g = (StanzaGroupExtension) ext;
        i.putExtra(EXTRA_GROUP_ID, g.getId());
        i.putExtra(EXTRA_GROUP_COUNT, g.getCount());
    }

    Log.v(MessageCenterService.TAG, "broadcasting presence: " + i);
    sendBroadcast(i);
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:46,代码来源:PresenceListener.java


示例12: getXep203DelayInformation

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
/**
 * Get Delayed Delivery information as defined in XEP-203
 * <p>
 * Prefer {@link #getDelayInformation(Stanza)} over this method for backwards compatibility.
 * </p>
 * @param packet
 * @return the Delayed Delivery information or <code>null</code>
 */
public static DelayInformation getXep203DelayInformation(Stanza packet) {
    return DelayInformation.from(packet);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:DelayInformationManager.java


示例13: getLegacyDelayInformation

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
/**
 * Get Delayed Delivery information as defined in XEP-91
 * <p>
 * Prefer {@link #getDelayInformation(Stanza)} over this method for backwards compatibility.
 * </p>
 * @param packet
 * @return the Delayed Delivery information or <code>null</code>
 */
public static DelayInformation getLegacyDelayInformation(Stanza packet) {
    return packet.getExtension(LEGACY_DELAYED_DELIVERY_ELEMENT, LEGACY_DELAYED_DELIVERY_NAMESPACE);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:DelayInformationManager.java


示例14: Forwarded

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
/**
 * Creates a new Forwarded stanza(/packet) extension.
 *
 * @param delay an optional {@link DelayInformation} timestamp of the packet.
 * @param fwdPacket the stanza(/packet) that is forwarded (required).
 */
public Forwarded(DelayInformation delay, Stanza fwdPacket) {
    this.delay = delay;
    this.forwardedPacket = fwdPacket;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:11,代码来源:Forwarded.java


示例15: getDelayInformation

import org.jivesoftware.smackx.delay.packet.DelayInformation; //导入依赖的package包/类
/**
 * get the timestamp of the forwarded packet.
 *
 * @return the {@link DelayInformation} representing the time when the original stanza(/packet) was sent. May be null.
 */
public DelayInformation getDelayInformation() {
    return delay;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:9,代码来源:Forwarded.java



注:本文中的org.jivesoftware.smackx.delay.packet.DelayInformation类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OffsetComparator类代码示例发布时间:2022-05-22
下一篇:
Java LogLevel类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap