/** * Called when the mode provided by the connection is changed to online or the user sets the mode to online. * If Handler is in onlinemode some preparations are done like checking and perhaps retrieving the spaces service adress. */ private void prepareOnlineMode(){ if (getMode() == Mode.ONLINE){ if (domain == null){ domain = userInfo.getDomain(); } if (connectionHandler.getNetworkInformation().getSpacesServiceJID() != null) { this.connection.removePacketListener(packetListener); AndFilter andFilter = new AndFilter(); OrFilter orFilter = new OrFilter(); orFilter.addFilter(new IQTypeFilter(IQ.Type.ERROR)); orFilter.addFilter(new IQTypeFilter(IQ.Type.RESULT)); andFilter.addFilter(orFilter); andFilter.addFilter(new FromContainsFilter(connectionHandler.getNetworkInformation().getSpacesServiceJID())); this.connection.addPacketListener(packetListener, andFilter); } } }
/** * Test if entity caps actually prevent a disco info request and reply * * @throws XMPPException * */ public void testPreventDiscoInfo() throws XMPPException { con0.addPacketSendingListener(new PacketListener() { @Override public void processPacket(Packet packet) { discoInfoSend = true; } }, new AndFilter(new StanzaTypeFilter(DiscoverInfo.class), new IQTypeFilter(IQ.Type.get))); // add a bogus feature so that con1 ver won't match con0's sdm1.addFeature(DISCOVER_TEST_FEATURE); dropCapsCache(); // discover that DiscoverInfo info = sdm0.discoverInfo(con1.getUser()); // that discovery should cause a disco#info assertTrue(discoInfoSend); assertTrue(info.containsFeature(DISCOVER_TEST_FEATURE)); discoInfoSend = false; // discover that info = sdm0.discoverInfo(con1.getUser()); // that discovery shouldn't cause a disco#info assertFalse(discoInfoSend); assertTrue(info.containsFeature(DISCOVER_TEST_FEATURE)); }
private void initListeners() { listeners = new ArrayList<FileTransferListener>(); connection.addPacketListener(new PacketListener() { public void processPacket(Packet packet) { fireNewRequest((StreamInitiation) packet); } }, new AndFilter(new PacketTypeFilter(StreamInitiation.class), new IQTypeFilter(IQ.Type.SET))); }
/** * Setter for the XMPPConnection. Use this only when you create a new connection object. * @param connectionHandler The XMPPConnection object this instance of a SpaceHandler should use. * @throws SpaceManagementException Thrown when there's no response from the server. */ public void changeConnectionHandler(ConnectionHandler connectionHandler) throws SpaceManagementException { this.connectionHandler = connectionHandler; this.connection = this.connectionHandler.getXMPPConnection(); if (connectionHandler.getNetworkInformation().getSpacesServiceJID() != null){ AndFilter andFilter = new AndFilter(); OrFilter orFilter = new OrFilter(); orFilter.addFilter(new IQTypeFilter(IQ.Type.ERROR)); orFilter.addFilter(new IQTypeFilter(IQ.Type.RESULT)); andFilter.addFilter(orFilter); andFilter.addFilter(new FromContainsFilter(connectionHandler.getNetworkInformation().getSpacesServiceJID())); this.connection.addPacketListener(packetListener, andFilter); } }
/** * Test if entity caps actually prevent a disco info request and reply * * @throws XMPPException * */ public void testPreventDiscoInfo() throws XMPPException { con0.addPacketSendingListener(new PacketListener() { @Override public void processPacket(Packet packet) { discoInfoSend = true; } }, new AndFilter(new PacketTypeFilter(DiscoverInfo.class), new IQTypeFilter(IQ.Type.GET))); // add a bogus feature so that con1 ver won't match con0's sdm1.addFeature(DISCOVER_TEST_FEATURE); dropCapsCache(); // discover that DiscoverInfo info = sdm0.discoverInfo(con1.getUser()); // that discovery should cause a disco#info assertTrue(discoInfoSend); assertTrue(info.containsFeature(DISCOVER_TEST_FEATURE)); discoInfoSend = false; // discover that info = sdm0.discoverInfo(con1.getUser()); // that discovery shouldn't cause a disco#info assertFalse(discoInfoSend); assertTrue(info.containsFeature(DISCOVER_TEST_FEATURE)); }