use of org.jivesoftware.smackx.vcardtemp.provider.VCardProvider in project Zom-Android by zom.
the class XmppConnection method addProviderManagerExtensions.
public static void addProviderManagerExtensions() {
ProviderManager.addIQProvider("query", "jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Time
try {
ProviderManager.addIQProvider("query", "jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time"));
} catch (ClassNotFoundException e) {
Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Time");
}
// Pings
ProviderManager.addIQProvider("ping", "urn:xmpp:ping", new PingProvider());
// Roster Exchange
// providerManager.addExtensionProvider("x", "jabber:x:roster", new RosterExchangeProvider());
ProviderManager.addIQProvider("vCard", "vcard-temp", new VCardProvider());
// Message Events
// providerManager.addExtensionProvider("x", "jabber:x:event",
// new MessageEventProvider());
// XHTML
ProviderManager.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider());
// Group Chat Invitations
ProviderManager.addExtensionProvider("x", "jabber:x:conference", new GroupChatInvitation.Provider());
// Service Discovery # Items
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
// Service Discovery # Info
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Data Forms
ProviderManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
// MUC User
ProviderManager.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new MUCUserProvider());
// MUC Admin
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
// MUC Owner
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/muc#owner", new MUCOwnerProvider());
// Version
try {
ProviderManager.addIQProvider("query", "jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
} catch (ClassNotFoundException e) {
// Not sure what's happening here.
}
// VCard
ProviderManager.addIQProvider("vCard", "vcard-temp", new VCardProvider());
// Offline Message Requests
ProviderManager.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
// Offline Message Indicator
ProviderManager.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
// Last Activity
ProviderManager.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider());
// User Search
ProviderManager.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider());
// SharedGroupsInfo
ProviderManager.addIQProvider("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
// JEP-33: Extended Stanza Addressing
ProviderManager.addExtensionProvider("addresses", "http://jabber.org/protocol/address", new MultipleAddressesProvider());
// FileTransfer
ProviderManager.addIQProvider("si", "http://jabber.org/protocol/si", new StreamInitiationProvider());
// Privacy
ProviderManager.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
ProviderManager.addIQProvider("command", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider());
ProviderManager.addExtensionProvider("malformed-action", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.MalformedActionError());
ProviderManager.addExtensionProvider("bad-locale", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadLocaleError());
ProviderManager.addExtensionProvider("bad-payload", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadPayloadError());
ProviderManager.addExtensionProvider("bad-sessionid", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadSessionIDError());
ProviderManager.addExtensionProvider("session-expired", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.SessionExpiredError());
ProviderManager.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
// Offline Message Indicator
ProviderManager.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
ProviderManager.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
// pm.addExtensionProvider("status ","", new XMLPlayerList());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
ProviderManager.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Private Data Storage
// ProviderManager.addIQProvider("query","jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
// Time
/**
* try {
* ProviderManager.addIQProvider("query","jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time"));
* } catch (ClassNotFoundException e) {
* Log.w("TestClient", "Can't load class for org.jivesoftware.smackx.packet.Time");
* }
*/
// Roster Exchange
// ProviderManager.addExtensionProvider("x","jabber:x:roster", new RosterExchangeProvider());
// Message Events
// ProviderManager.addExtensionProvider("x","jabber:x:event", new MessageEventProvider());
// Chat State
ChatStateExtensionProvider csep = new ChatStateExtensionProvider();
ProviderManager.addExtensionProvider("active", "http://jabber.org/protocol/chatstates", csep);
ProviderManager.addExtensionProvider("composing", "http://jabber.org/protocol/chatstates", csep);
ProviderManager.addExtensionProvider("paused", "http://jabber.org/protocol/chatstates", csep);
ProviderManager.addExtensionProvider("inactive", "http://jabber.org/protocol/chatstates", csep);
ProviderManager.addExtensionProvider("gone", "http://jabber.org/protocol/chatstates", csep);
// XHTML
// ProviderManager.addExtensionProvider("html","http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider());
// Group Chat Invitations
// ProviderManager.addExtensionProvider("x","jabber:x:conference", new GroupChatInvitation.Provider());
// Service Discovery # Items
// ProviderManager.addIQProvider("query","http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
// Service Discovery # Info
// ProviderManager.addIQProvider("query","http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Data Forms
// ProviderManager.addExtensionProvider("x","jabber:x:data", new DataFormProvider());
// MUC User
// ProviderManager.addExtensionProvider("x","http://jabber.org/protocol/muc#user", new MUCUserProvider());
// MUC Admin
// ProviderManager.addIQProvider("query","http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
// MUC Owner
// ProviderManager.addIQProvider("query","http://jabber.org/protocol/muc#owner", new MUCOwnerProvider());
// Delayed Delivery
// ProviderManager.addExtensionProvider("x","jabber:x:delay", new DelayInformationProvider());
// Version
/**
* try {
* ProviderManager.addIQProvider("query","jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
* } catch (ClassNotFoundException err) {
* // Not sure what's happening here.
* }
*/
// VCard
// ProviderManager.addIQProvider("vCard","vcard-temp", new VCardProvider());
// Offline Message Requests
// ProviderManager.addIQProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
// Offline Message Indicator
// ProviderManager.addExtensionProvider("offline","http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
// Last Activity
// ProviderManager.addIQProvider("query","jabber:iq:last", new LastActivity.Provider());
// User Search
// ProviderManager.addIQProvider("query","jabber:iq:search", new UserSearch.Provider());
// SharedGroupsInfo
// ProviderManager.addIQProvider("sharedgroup","http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
// JEP-33: Extended Stanza Addressing
// ProviderManager.addExtensionProvider("addresses","http://jabber.org/protocol/address", new MultipleAddressesProvider());
// FileTransfer
// ProviderManager.addIQProvider("si","http://jabber.org/protocol/si", new StreamInitiationProvider());
// ProviderManager.addIQProvider("query","http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
// Privacy
/**
* ProviderManager.addIQProvider("query","jabber:iq:privacy", new PrivacyProvider());
* ProviderManager.addIQProvider("command", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider());
* ProviderManager.addExtensionProvider("malformed-action", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.MalformedActionError());
* ProviderManager.addExtensionProvider("bad-locale", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadLocaleError());
* ProviderManager.addExtensionProvider("bad-payload", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadPayloadError());
* ProviderManager.addExtensionProvider("bad-sessionid", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadSessionIDError());
* ProviderManager.addExtensionProvider("session-expired", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.SessionExpiredError());
*/
}
use of org.jivesoftware.smackx.vcardtemp.provider.VCardProvider in project xabber-android by redsolution.
the class ContactVcardViewerFragment method parseVCard.
public static VCard parseVCard(String xml) throws Exception {
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(new StringReader(xml));
int eventType = parser.next();
if (eventType != XmlPullParser.START_TAG) {
throw new IllegalStateException(String.valueOf(eventType));
}
if (!VCard.ELEMENT.equals(parser.getName())) {
throw new IllegalStateException(parser.getName());
}
if (!VCard.NAMESPACE.equals(parser.getNamespace())) {
throw new IllegalStateException(parser.getNamespace());
}
return (new VCardProvider()).parse(parser);
}
use of org.jivesoftware.smackx.vcardtemp.provider.VCardProvider in project Spark by igniterealtime.
the class VCardManager method loadFromFileSystem.
/**
* Attempts to load
*
* @param jid the jid of the user.
* @return the VCard if found, otherwise null.
*/
private VCard loadFromFileSystem(String jid) {
if (jid == null || jid.trim().isEmpty()) {
return null;
}
// Unescape JID
String fileName = Base64.encodeBytes(jid.getBytes());
// remove tab
fileName = fileName.replaceAll("\t", "");
// remove new line (Unix)
fileName = fileName.replaceAll("\n", "");
// remove new line (Windows)
fileName = fileName.replaceAll("\r", "");
final File vcardFile = new File(vcardStorageDirectory, fileName);
if (!vcardFile.exists()) {
return null;
}
final VCard vcard;
try (final BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(vcardFile), "UTF-8"))) {
// Otherwise load from file system.
VCardProvider provider = new VCardProvider();
parser.setInput(in);
// Skip forward until we're at <vCard xmlns='vcard-temp'>
while (!(parser.getEventType() == XmlPullParser.START_TAG && VCard.ELEMENT.equals(parser.getName()) && VCard.NAMESPACE.equals(parser.getNamespace()))) {
parser.next();
}
vcard = provider.parse(parser);
} catch (Exception e) {
Log.warning("Unable to load vCard for " + jid, e);
vcardFile.delete();
return null;
}
addVCard(jid, vcard);
// Check to see if the file is older 60 minutes. If so, reload.
final String timestamp = vcard.getField("timestamp");
if (timestamp != null) {
final Duration duration = Duration.between(Instant.ofEpochMilli(Long.parseLong(timestamp)), Instant.now());
if (duration.toMinutes() >= 60) {
addToQueue(jid);
}
}
return vcard;
}
Aggregations