use of org.jivesoftware.smack.provider.PrivacyProvider in project SmartMesh_Android by SmartMeshFoundation.
the class XmppUtils method configureConnection.
/**
* XMPP configuration
*/
private void configureConnection(ProviderManager pm) {
// Private Data Storage
pm.addIQProvider("query", "jabber:iq:private", new PrivateDataManager.PrivateDataIQProvider());
// Time
try {
pm.addIQProvider("query", "jabber:iq:time", Class.forName("org.jivesoftware.smackx.packet.Time"));
} catch (Exception e) {
e.printStackTrace();
// Logger.v(TAG,
// "Can't load class for org.jivesoftware.smackx.packet.Time");
}
// Roster Exchange
pm.addExtensionProvider("x", "jabber:x:roster", new RosterExchangeProvider());
// Message Events
pm.addExtensionProvider("x", "jabber:x:event", new MessageEventProvider());
// Chat State
pm.addExtensionProvider("active", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("composing", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("paused", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("inactive", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
pm.addExtensionProvider("gone", "http://jabber.org/protocol/chatstates", new ChatStateExtension.Provider());
// XHTML
pm.addExtensionProvider("html", "http://jabber.org/protocol/xhtml-im", new XHTMLExtensionProvider());
// Group Chat Invitations
pm.addExtensionProvider("x", "jabber:x:conference", new GroupChatInvitation.Provider());
// Service Discovery # Items //Analytical room list
pm.addIQProvider("query", "http://jabber.org/protocol/disco#items", new DiscoverItemsProvider());
// Service Discovery # Info //A single room
pm.addIQProvider("query", "http://jabber.org/protocol/disco#info", new DiscoverInfoProvider());
// Data Forms
pm.addExtensionProvider("x", "jabber:x:data", new DataFormProvider());
// MUC User
pm.addExtensionProvider("x", "http://jabber.org/protocol/muc#user", new MUCUserProvider());
// MUC Admin
pm.addIQProvider("query", "http://jabber.org/protocol/muc#admin", new MUCAdminProvider());
// MUC Owner
pm.addIQProvider("query", "http://jabber.org/protocol/muc#owner", new MUCOwnerProvider());
// Delayed Delivery
pm.addExtensionProvider("x", "jabber:x:delay", new DelayInformationProvider());
// Version
try {
pm.addIQProvider("query", "jabber:iq:version", Class.forName("org.jivesoftware.smackx.packet.Version"));
} catch (ClassNotFoundException e) {
// Not sure what's happening here.
}
// VCard
pm.addIQProvider("vCard", "vcard-temp", new VCardProvider());
// Offline Message Requests
pm.addIQProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageRequest.Provider());
// Offline Message Indicator
pm.addExtensionProvider("offline", "http://jabber.org/protocol/offline", new OfflineMessageInfo.Provider());
// Last Activity
pm.addIQProvider("query", "jabber:iq:last", new LastActivity.Provider());
// User Search
pm.addIQProvider("query", "jabber:iq:search", new UserSearch.Provider());
// SharedGroupsInfo
pm.addIQProvider("sharedgroup", "http://www.jivesoftware.org/protocol/sharedgroup", new SharedGroupsInfo.Provider());
// JEP-33: Extended Stanza Addressing
pm.addExtensionProvider("addresses", "http://jabber.org/protocol/address", new MultipleAddressesProvider());
// FileTransfer
pm.addIQProvider("si", "http://jabber.org/protocol/si", new StreamInitiationProvider());
pm.addIQProvider("query", "http://jabber.org/protocol/bytestreams", new BytestreamsProvider());
// pm.addIQProvider("open", "http://jabber.org/protocol/ibb",
// new IBBProviders.Open());
//
// pm.addIQProvider("close", "http://jabber.org/protocol/ibb",s
// new IBBProviders.Close());
//
// pm.addExtensionProvider("data", "http://jabber.org/protocol/ibb",
// new IBBProviders.Data());
// Privacy
pm.addIQProvider("query", "jabber:iq:privacy", new PrivacyProvider());
pm.addIQProvider("command", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider());
pm.addExtensionProvider("malformed-action", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.MalformedActionError());
pm.addExtensionProvider("bad-locale", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadLocaleError());
pm.addExtensionProvider("bad-payload", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadPayloadError());
pm.addExtensionProvider("bad-sessionid", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.BadSessionIDError());
pm.addExtensionProvider("session-expired", "http://jabber.org/protocol/commands", new AdHocCommandDataProvider.SessionExpiredError());
}
use of org.jivesoftware.smack.provider.PrivacyProvider in project Smack by igniterealtime.
the class PrivacyProviderTest method testDeclineLists.
/**
* Check the parser with an xml with empty lists. It includes the active,
* default and special list.
* To create the xml string based from an xml file, replace:\n with: "\n + "
*/
public void testDeclineLists() {
// Make the XML to test
String xml = "" + " <iq type='result' id='getlist1' to='romeo@example.net/orchard'> " + " <query xmlns='jabber:iq:privacy'> " + " <active/> " + " <default/> " + " </query> " + " </iq> ";
try {
// Create the xml parser
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser);
assertNotNull(packet);
assertEquals(null, packet.getDefaultName());
assertEquals(null, packet.getActiveName());
assertEquals(true, packet.isDeclineActiveList());
assertEquals(true, packet.isDeclineDefaultList());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.jivesoftware.smack.provider.PrivacyProvider in project Smack by igniterealtime.
the class PrivacyProviderTest method testFull.
/**
* Check the parser with an xml with all kind of stanzas.
* To create the xml string based from an xml file, replace:\n with: "\n + "
*/
public void testFull() {
// Make the XML to test
String xml = "" + " <iq type='result' id='getlist2' to='romeo@example.net/orchard'> " + " <query xmlns='jabber:iq:privacy'> " + " <active name='testFilter'/> " + " <default name='testSubscription'/> " + " <list name='testFilter'> " + " <item type='jid' " + " value='tybalt@example.com' " + " action='deny' " + " order='1'/> " + " <item action='allow' order='2'> " + " <message/> " + " <presence-in/> " + " <presence-out/> " + " <iq/> " + " </item> " + " </list> " + " <list name='testSubscription'> " + " <item type='subscription' " + " value='both' " + " action='allow' " + " order='10'/> " + " <item type='subscription' " + " value='to' " + " action='allow' " + " order='11'/> " + " <item type='subscription' " + " value='from' " + " action='allow' " + " order='12'/> " + " <item type='subscription' " + " value='none' " + " action='deny' " + " order='5'> " + " <message/> " + " </item> " + " <item action='deny' order='15'/> " + " </list> " + " <list name='testJID'> " + " <item type='jid' " + " value='juliet@example.com' " + " action='allow' " + " order='6'/> " + " <item type='jid' " + " value='benvolio@example.org/palm' " + " action='deny' " + " order='7'/> " + " <item type='jid' " + " action='allow' " + " order='42'/> " + " <item action='deny' order='666'/> " + " </list> " + " <list name='testGroup'> " + " <item type='group' " + " value='Enemies' " + " action='deny' " + " order='4'> " + " <message/> " + " </item> " + " <item action='deny' order='666'/> " + " </list> " + " <list name='testEmpty'/> " + " </query> " + " <error type='cancel'> " + " <item-not-found " + " xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/> " + " </error> " + "</iq> ";
try {
// Create the xml parser
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser);
// check if it exist
assertNotNull(packet);
// assertEquals(xml, packet.getChildElementXML());
// check the default and active names
assertEquals("testFilter", packet.getActiveName());
assertEquals("testSubscription", packet.getDefaultName());
// check the list
assertEquals(2, packet.getPrivacyList("testFilter").size());
assertEquals(5, packet.getPrivacyList("testSubscription").size());
assertEquals(4, packet.getPrivacyList("testJID").size());
assertEquals(2, packet.getPrivacyList("testGroup").size());
assertEquals(0, packet.getPrivacyList("testEmpty").size());
// check each privacy item
PrivacyItem item = packet.getItem("testGroup", 4);
assertEquals("Enemies", item.getValue());
assertEquals(PrivacyItem.Type.group, item.getType());
assertEquals(false, item.isAllow());
assertEquals(true, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
item = packet.getItem("testFilter", 1);
assertEquals("tybalt@example.com", item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
assertEquals(false, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testFilter", 2);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
assertEquals(true, item.isAllow());
assertEquals(true, item.isFilterMessage());
assertEquals(true, item.isFilterIQ());
assertEquals(true, item.isFilterPresence_in());
assertEquals(true, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
// TEST THE testSubscription LIST
item = packet.getItem("testSubscription", 10);
assertEquals("both", item.getValue());
assertEquals(PrivacyItem.Type.subscription, item.getType());
assertEquals(true, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testSubscription", 11);
assertEquals("to", item.getValue());
assertEquals(PrivacyItem.Type.subscription, item.getType());
assertEquals(true, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testSubscription", 12);
assertEquals("from", item.getValue());
assertEquals(PrivacyItem.Type.subscription, item.getType());
assertEquals(true, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testSubscription", 5);
assertEquals("none", item.getValue());
assertEquals(PrivacyItem.Type.subscription, item.getType());
assertEquals(false, item.isAllow());
assertEquals(true, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
item = packet.getItem("testSubscription", 15);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
assertEquals(false, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
// TEST THE testJID LIST
item = packet.getItem("testJID", 6);
assertEquals("juliet@example.com", item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
assertEquals(true, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testJID", 7);
assertEquals("benvolio@example.org/palm", item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
assertEquals(false, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testJID", 42);
assertEquals(null, item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
assertEquals(true, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testJID", 666);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
assertEquals(false, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
// TEST THE testGroup LIST
item = packet.getItem("testGroup", 4);
assertEquals("Enemies", item.getValue());
assertEquals(PrivacyItem.Type.group, item.getType());
assertEquals(false, item.isAllow());
assertEquals(true, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
item = packet.getItem("testGroup", 666);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
assertEquals(false, item.isAllow());
assertEquals(false, item.isFilterMessage());
assertEquals(false, item.isFilterIQ());
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
use of org.jivesoftware.smack.provider.PrivacyProvider in project Smack by igniterealtime.
the class PrivacyProviderTest method testEmptyLists.
/**
* Check the parser with an xml with empty lists. It includes the active,
* default and special list.
* To create the xml string based from an xml file, replace:\n with: "\n + "
*/
public void testEmptyLists() {
// Make the XML to test
String xml = "" + " <iq type='result' id='getlist1' to='romeo@example.net/orchard'> " + " <query xmlns='jabber:iq:privacy'> " + " <active/> " + " <default name='public'/> " + " <list name='public'/> " + " <list name='private'/> " + " <list name='special'/> " + " </query> " + " </iq> ";
try {
// Create the xml parser
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser);
assertNotNull(packet);
assertNotNull(packet.getChildElementXML());
assertEquals("public", packet.getDefaultName());
assertEquals(null, packet.getActiveName());
assertEquals(0, packet.getPrivacyList("public").size());
assertEquals(0, packet.getPrivacyList("private").size());
assertEquals(0, packet.getPrivacyList("special").size());
assertEquals(true, packet.isDeclineActiveList());
assertEquals(false, packet.isDeclineDefaultList());
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
Aggregations