Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2006-12-29 02:11:46 -0500
committerslewis2006-12-29 02:11:46 -0500
commite1c75cab28ef215f931b53a75778503300ee3615 (patch)
tree56a855c193f165bd5cc634520345313bd0f7e245 /protocols
parenta87d7026cb387f6cb22a416abb496a10ee7976b5 (diff)
downloadorg.eclipse.ecf-e1c75cab28ef215f931b53a75778503300ee3615.tar.gz
org.eclipse.ecf-e1c75cab28ef215f931b53a75778503300ee3615.tar.xz
org.eclipse.ecf-e1c75cab28ef215f931b53a75778503300ee3615.zip
Added handling of vcard-temp:x:update namespace for smack extension provider. Also added to IPresence interface access to photo data provided by smack extension provider. Also added implementation in XMPPContainer and XMPPSOClientContainer classes.
Diffstat (limited to 'protocols')
-rw-r--r--protocols/bundles/org.jivesoftware.smack/src/META-INF/smack.providers9
-rw-r--r--protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/packet/VCardTempXUpdateExtension.java45
-rw-r--r--protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/provider/VCardTempXUpdateProvider.java46
3 files changed, 100 insertions, 0 deletions
diff --git a/protocols/bundles/org.jivesoftware.smack/src/META-INF/smack.providers b/protocols/bundles/org.jivesoftware.smack/src/META-INF/smack.providers
index 98867a4fa..71312601f 100644
--- a/protocols/bundles/org.jivesoftware.smack/src/META-INF/smack.providers
+++ b/protocols/bundles/org.jivesoftware.smack/src/META-INF/smack.providers
@@ -179,5 +179,14 @@
<namespace>http://jabber.org/protocol/ibb</namespace>
<className>org.jivesoftware.smackx.provider.IBBProviders$Data</className>
</extensionProvider>
+
+ <!-- Photo -->
+ <extensionProvider>
+ <elementName>x</elementName>
+ <namespace>vcard-temp:x:update</namespace>
+ <className>org.jivesoftware.smackx.provider.VCardTempXUpdateProvider</className>
+ </extensionProvider>
+
+
</smackProviders> \ No newline at end of file
diff --git a/protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/packet/VCardTempXUpdateExtension.java b/protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/packet/VCardTempXUpdateExtension.java
new file mode 100644
index 000000000..ac1ade0b1
--- /dev/null
+++ b/protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/packet/VCardTempXUpdateExtension.java
@@ -0,0 +1,45 @@
+package org.jivesoftware.smackx.packet;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.util.StringUtils;
+
+public class VCardTempXUpdateExtension implements PacketExtension {
+
+ String photoData;
+
+ public String getElementName() {
+ return "x";
+ }
+
+ /**
+ * Returns the XML namespace of the extension sub-packet root element.
+ * According the specification the namespace is always "http://jabber.org/protocol/xhtml-im"
+ *
+ * @return the XML namespace of the packet extension.
+ */
+ public String getNamespace() {
+ return "vcard-temp:x:update";
+ }
+
+ public String toXML() {
+ StringBuffer buf = new StringBuffer();
+ buf.append("<").append(getElementName()).append(" xmlns=\"").append(getNamespace()).append(
+ "\">");
+ // Loop through all the bodies and append them to the string buffer
+ buf.append("<photo>").append(getPhotoDataAsString()).append("</photo>");
+ buf.append("</").append(getElementName()).append(">");
+ return buf.toString();
+ }
+
+ public String getPhotoDataAsString() {
+ return photoData;
+ }
+
+ public byte[] getPhotoDataAsBytes() {
+ return StringUtils.decodeBase64(photoData);
+ }
+
+ public void setPhotoData(String data) {
+ this.photoData = data;
+ }
+}
diff --git a/protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/provider/VCardTempXUpdateProvider.java b/protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/provider/VCardTempXUpdateProvider.java
new file mode 100644
index 000000000..28811434d
--- /dev/null
+++ b/protocols/bundles/org.jivesoftware.smack/src/org/jivesoftware/smackx/provider/VCardTempXUpdateProvider.java
@@ -0,0 +1,46 @@
+package org.jivesoftware.smackx.provider;
+
+import org.jivesoftware.smack.packet.PacketExtension;
+import org.jivesoftware.smack.provider.PacketExtensionProvider;
+import org.jivesoftware.smackx.packet.VCardTempXUpdateExtension;
+import org.jivesoftware.smackx.packet.XHTMLExtension;
+import org.xmlpull.v1.XmlPullParser;
+
+/**
+ * vCard provider.
+ *
+ * @author Scott Lewis
+ */
+public class VCardTempXUpdateProvider implements PacketExtensionProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jivesoftware.smack.provider.PacketExtensionProvider#parseExtension(org.xmlpull.v1.XmlPullParser)
+ */
+ public PacketExtension parseExtension(XmlPullParser parser)
+ throws Exception {
+ VCardTempXUpdateExtension photoExtension = new VCardTempXUpdateExtension();
+ boolean done = false;
+ StringBuffer buffer = new StringBuffer();;
+ while (!done) {
+ int eventType = parser.next();
+ if (eventType == XmlPullParser.START_TAG) {
+ if (parser.getName().equals("photo"))
+ buffer = new StringBuffer();
+ } else if (eventType == XmlPullParser.TEXT) {
+ if (buffer != null) buffer.append(parser.getText());
+ } else if (eventType == XmlPullParser.END_TAG) {
+ if (parser.getName().equals("photo")) {
+ photoExtension.setPhotoData(buffer.toString());
+ }
+ else if (parser.getName().equals(photoExtension.getElementName())) {
+ done = true;
+ }
+ }
+ }
+
+ return photoExtension;
+ }
+
+}

Back to the top