当前位置: 首页>>代码示例>>Java>>正文


Java DefaultPacketExtension类代码示例

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


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

示例1: extractHeadersFromXmpp

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
public Map<String, Object> extractHeadersFromXmpp(Packet xmppPacket, Exchange exchange) {
    Map<String, Object> answer = new HashMap<String, Object>();

    PacketExtension jpe = xmppPacket.getExtension(JivePropertiesExtension.NAMESPACE);
    if (jpe != null && jpe instanceof JivePropertiesExtension) {
        extractHeadersFrom((JivePropertiesExtension)jpe, exchange, answer);
    }
    if (jpe != null && jpe instanceof DefaultPacketExtension) {
        extractHeadersFrom((DefaultPacketExtension)jpe, exchange, answer);
    }

    if (xmppPacket instanceof Message) {
        Message xmppMessage = (Message) xmppPacket;
        answer.put(XmppConstants.MESSAGE_TYPE, xmppMessage.getType());
        answer.put(XmppConstants.SUBJECT, xmppMessage.getSubject());
        answer.put(XmppConstants.THREAD_ID, xmppMessage.getThread());
    } else if (xmppPacket instanceof PubSub) {
        PubSub pubsubPacket = (PubSub) xmppPacket;
        answer.put(XmppConstants.MESSAGE_TYPE, pubsubPacket.getType());
    }
    answer.put(XmppConstants.FROM, xmppPacket.getFrom());
    answer.put(XmppConstants.PACKET_ID, xmppPacket.getPacketID());
    answer.put(XmppConstants.TO, xmppPacket.getTo());

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:XmppBinding.java

示例2: setPresence

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
/**
 * Sets the current presence on this contact item.
 *
 * @param presence the presence.
 */
public void setPresence(Presence presence) {

    this.presence = presence;

    final PacketExtension packetExtension = presence.getExtension("x", "vcard-temp:x:update");

    // Handle vCard update packet.
    if (packetExtension != null && packetExtension instanceof DefaultPacketExtension) {
        DefaultPacketExtension o = (DefaultPacketExtension)packetExtension;
        String hash = o.getValue("photo");
        if (hash != null) {
            this.hash = hash;

            if (!hashExists(hash)) {
                updateAvatar();
                updateAvatarInSideIcon();
            }
        }
    }

    
    updatePresenceIcon(presence);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:29,代码来源:ContactItem.java

示例3: extractHeadersFrom

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
private void extractHeadersFrom(DefaultPacketExtension jpe, Exchange exchange, Map<String, Object> answer) {
    for (String name : jpe.getNames()) {
        Object value = jpe.getValue(name);
        if (!headerFilterStrategy.applyFilterToExternalHeaders(name, value, exchange)) {
            answer.put(name, value);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:XmppBinding.java

示例4: parseIQ

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
       Privacy privacy = new Privacy();
       /* privacy.addExtension(PacketParserUtils.parsePacketExtension(parser
               .getName(), parser.getNamespace(), parser)); */
       privacy.addExtension(new DefaultPacketExtension(parser.getName(), parser.getNamespace()));
       boolean done = false;
       while (!done) {
           int eventType = parser.next();
           if (eventType == XmlPullParser.START_TAG) {
               if (parser.getName().equals("active")) {
               	String activeName = parser.getAttributeValue("", "name");
               	if (activeName == null) {
               		privacy.setDeclineActiveList(true);
               	} else {
               		privacy.setActiveName(activeName);
               	}
               }
               else if (parser.getName().equals("default")) {
               	String defaultName = parser.getAttributeValue("", "name");
               	if (defaultName == null) {
               		privacy.setDeclineDefaultList(true);
               	} else {
               		privacy.setDefaultName(defaultName);
               	}
               }
               else if (parser.getName().equals("list")) {
                   parseList(parser, privacy);
               }
           }
           else if (eventType == XmlPullParser.END_TAG) {
               if (parser.getName().equals("query")) {
                   done = true;
               }
           }
       }

       return privacy;
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:39,代码来源:PrivacyProvider.java

示例5: parseIQ

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
	Privacy privacy = new Privacy();
	/*
	 * privacy.addExtension(PacketParserUtils.parsePacketExtension(parser
	 * .getName(), parser.getNamespace(), parser));
	 */
	privacy.addExtension(new DefaultPacketExtension(parser.getName(),
			parser.getNamespace()));
	boolean done = false;
	while (!done) {
		int eventType = parser.next();
		if (eventType == XmlPullParser.START_TAG) {
			if (parser.getName().equals("active")) {
				String activeName = parser.getAttributeValue("", "name");
				if (activeName == null) {
					privacy.setDeclineActiveList(true);
				} else {
					privacy.setActiveName(activeName);
				}
			} else if (parser.getName().equals("default")) {
				String defaultName = parser.getAttributeValue("", "name");
				if (defaultName == null) {
					privacy.setDeclineDefaultList(true);
				} else {
					privacy.setDefaultName(defaultName);
				}
			} else if (parser.getName().equals("list")) {
				parseList(parser, privacy);
			}
		} else if (eventType == XmlPullParser.END_TAG) {
			if (parser.getName().equals("query")) {
				done = true;
			}
		}
	}

	return privacy;
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:39,代码来源:PrivacyProvider.java

示例6: parsePacketExtension

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
/**
 * Parses a packet extension sub-packet.
 * 
 * @param elementName
 *            the XML element name of the packet extension.
 * @param namespace
 *            the XML namespace of the packet extension.
 * @param parser
 *            the XML parser, positioned at the starting element of the
 *            extension.
 * @return a PacketExtension.
 * @throws Exception
 *             if a parsing error occurs.
 */
public static PacketExtension parsePacketExtension(String elementName,
        String namespace, XmlPullParser parser) throws Exception {
    DefaultPacketExtension extension = new DefaultPacketExtension(
            elementName, namespace);
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            String name = parser.getName();
            // If an empty element, set the value with the empty string.
            if (parser.isEmptyElementTag()) {
                extension.setValue(name, "");
            }
            // Otherwise, get the the element text.
            else {
                eventType = parser.next();
                if (eventType == XmlPullParser.TEXT) {
                    String value = parser.getText();
                    extension.setValue(name, value);
                }
            }
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(elementName)) {
                done = true;
            }
        }
    }
    return extension;
}
 
开发者ID:abmargb,项目名称:jamppa,代码行数:44,代码来源:PacketParserUtils.java

示例7: sendForfeit

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
/**
 * Sends a forfeit message to the other player.
 */
public void sendForfeit() {
    DefaultPacketExtension forfeit = new DefaultPacketExtension(GameForfeit.ELEMENT_NAME, GameForfeit.NAMESPACE);
    forfeit.setValue("gameID", Integer.toString(gameID));
    Message message = new Message();
    message.setTo(opponentJID);
    message.addExtension(forfeit);
    connection.sendPacket(message);
    connection.removePacketListener(gameMoveListener);
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:13,代码来源:ReversiPanel.java

示例8: parsePacketExtension

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
/**
 * Parses a packet extension sub-packet.
 *
 * @param elementName the XML element name of the packet extension.
 * @param namespace the XML namespace of the packet extension.
 * @param parser the XML parser, positioned at the starting element of the extension.
 * @return a PacketExtension.
 * @throws Exception if a parsing error occurs.
 */
public static PacketExtension parsePacketExtension(String elementName, String namespace, XmlPullParser parser)
        throws Exception
{
    // See if a provider is registered to handle the extension.
    Object provider = ProviderManager.getInstance().getExtensionProvider(elementName, namespace);
    if (provider != null) {
        if (provider instanceof PacketExtensionProvider) {
            return ((PacketExtensionProvider)provider).parseExtension(parser);
        }
        else if (provider instanceof Class) {
            return (PacketExtension)parseWithIntrospection(
                    elementName, (Class)provider, parser);
        }
    }
    // No providers registered, so use a default extension.
    DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace);
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            String name = parser.getName();
            // If an empty element, set the value with the empty string.
            if (parser.isEmptyElementTag()) {
                extension.setValue(name,"");
            }
            // Otherwise, get the the element text.
            else {
                eventType = parser.next();
                if (eventType == XmlPullParser.TEXT) {
                    String value = parser.getText();
                    extension.setValue(name, value);
                }
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(elementName)) {
                done = true;
            }
        }
    }
    return extension;
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:52,代码来源:PacketParserUtils.java

示例9: parsePacketExtension

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
/**
 * Parses a packet extension sub-packet.
 *
 * @param elementName the XML element name of the packet extension.
 * @param namespace the XML namespace of the packet extension.
 * @param parser the XML parser, positioned at the starting element of the extension.
 * @return a PacketExtension.
 * @throws Exception if a parsing error occurs.
 */
public static PacketExtension parsePacketExtension(String elementName, String namespace, XmlPullParser parser)
        throws Exception
{
    // See if a provider is registered to handle the extension.
    Object provider = ProviderManager.getInstance().getExtensionProvider(elementName, namespace);
    if (provider != null) {
        if (provider instanceof PacketExtensionProvider) {
            return ((PacketExtensionProvider)provider).parseExtension(parser);
        }
        else if (provider instanceof Class) {
            return (PacketExtension)parseWithIntrospection(
                    elementName, (Class<?>)provider, parser);
        }
    }
    // No providers registered, so use a default extension.
    DefaultPacketExtension extension = new DefaultPacketExtension(elementName, namespace);
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            String name = parser.getName();
            // If an empty element, set the value with the empty string.
            if (parser.isEmptyElementTag()) {
                extension.setValue(name,"");
            }
            // Otherwise, get the the element text.
            else {
                eventType = parser.next();
                if (eventType == XmlPullParser.TEXT) {
                    String value = parser.getText();
                    extension.setValue(name, value);
                }
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(elementName)) {
                done = true;
            }
        }
    }
    return extension;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:52,代码来源:PacketParserUtils.java

示例10: initStatusListener

import org.jivesoftware.smack.packet.DefaultPacketExtension; //导入依赖的package包/类
public static void initStatusListener() {
    ChatManager chatManager = ChatManager.getInstance();

    final PacketListener presenceListener = new PacketListener() {
        public void processPacket(Packet packet) {
            if (packet instanceof Presence) {
                Presence p = (Presence)packet;
                DefaultPacketExtension ext = (DefaultPacketExtension)p.getExtension("workgroup", "http://jivesoftware.com/protocol/workgroup");
                if (ext != null) {
                    String lastModified = ext.getValue("lastModified");
                    if (lastModified != null) {
                        String workgroupName = StringUtils.parseName(p.getFrom());
                        String previousDate = (String)CHANGE_MAP.get(workgroupName);

                        final SimpleDateFormat UTC_FORMAT = new SimpleDateFormat("yyyyMMdd'T'HH:mm:ss");
                        UTC_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+0"));

                        try {
                            Date newDate = UTC_FORMAT.parse(lastModified);

                            if (ModelUtil.hasLength(previousDate)) {
                                Date oldDate = UTC_FORMAT.parse(previousDate);
                                if (newDate.getTime() > oldDate.getTime()) {
                                    CHANGE_MAP.put(workgroupName, lastModified);
                                    fireWorkgroupChanged(p.getFrom());
                                    workgroupForms.remove(p.getFrom());
                                }
                            }
                            else {
                                CHANGE_MAP.put(workgroupName, lastModified);
                            }
                        }
                        catch (ParseException e) {
                            WebLog.logError("Error processing workgroup packet.", e);
                        }

                    }
                }
            }
        }
    };

    if (chatManager.getGlobalConnection() == null || !chatManager.getGlobalConnection().isConnected()) {
        ConnectionSettings settings = chatManager.getChatSettingsManager().getSettings();
        WebLog.logError("A connection to the server could not be made when attempting connection to " + settings.getServerDomain());
    }
    else {
        chatManager.getGlobalConnection().addPacketListener(presenceListener, new PacketTypeFilter(Presence.class));
        workgroups.clear();
        workgroupForms.clear();
        workgroupPresence.clear();
    }
}
 
开发者ID:igniterealtime,项目名称:Fastpath-webchat,代码行数:54,代码来源:WorkgroupStatus.java


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