@Override public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout) { StanzaFilter replyFilter = new IQReplyFilter(request, this); return sendAsync(request, replyFilter, timeout); }
@Override public boolean accept(Stanza packet) { if (!super.accept(packet)) { return false; } return IQTypeFilter.RESULT.accept(packet); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); sb.append(" (" + super.toString() + ')'); return sb.toString(); } }
@Override public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException { StanzaFilter packetFilter = new IQReplyFilter(packet, this); // Create the packet collector before sending the packet StanzaCollector packetCollector = createStanzaCollectorAndSend(packetFilter, packet); return packetCollector; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(getClass().getSimpleName()); sb.append(" (" + super.toString() + ')'); return sb.toString(); } }
@Override public boolean accept(Stanza packet) { if (!super.accept(packet)) { return false; } return IQTypeFilter.RESULT.accept(packet); }
private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null); mucLightBlockingIQ.setType(Type.get); mucLightBlockingIQ.setTo(mucLightService); StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection()); IQ responseIq = connection().createStanzaCollectorAndSend(responseFilter, mucLightBlockingIQ) .nextResultOrThrow(); MUCLightBlockingIQ mucLightBlockingIQResult = (MUCLightBlockingIQ) responseIq; return mucLightBlockingIQResult; }
private MamQueryPage queryArchivePage(MamQueryIQ mamQueryIq) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { final XMPPConnection connection = getAuthenticatedConnectionOrThrow(); MamFinIQ mamFinIQ; StanzaCollector mamFinIQCollector = connection.createStanzaCollector(new IQReplyFilter(mamQueryIq, connection)); StanzaCollector.Configuration resultCollectorConfiguration = StanzaCollector.newConfiguration() .setStanzaFilter(new MamResultFilter(mamQueryIq)).setCollectorToReset(mamFinIQCollector); StanzaCollector resultCollector = connection.createStanzaCollector(resultCollectorConfiguration); try { connection.sendStanza(mamQueryIq); mamFinIQ = mamFinIQCollector.nextResultOrThrow(); } finally { mamFinIQCollector.cancel(); resultCollector.cancel(); } return new MamQueryPage(resultCollector, mamFinIQ); }
@Override public SmackFuture<IQ, Exception> sendIqRequestAsync(IQ request, long timeout) { StanzaFilter replyFilter = new IQReplyFilter(request, this); return sendAsync(request, replyFilter, timeout); }
@Override public StanzaCollector createStanzaCollectorAndSend(IQ packet) throws NotConnectedException, InterruptedException { StanzaFilter packetFilter = new IQReplyFilter(packet, this); // Create the packet collector before sending the packet StanzaCollector packetCollector = createStanzaCollectorAndSend(packetFilter, packet); return packetCollector; }
@SuppressWarnings("deprecation") @Override public void sendIqWithResponseCallback(IQ iqRequest, final StanzaListener callback, final ExceptionCallback exceptionCallback, long timeout) throws NotConnectedException, InterruptedException { StanzaFilter replyFilter = new IQReplyFilter(iqRequest, this); sendStanzaWithResponseCallback(iqRequest, replyFilter, callback, exceptionCallback, timeout); }
/** * Registers a user with a gateway. * * @param con the XMPPConnection. * @param gatewayDomain the domain of the gateway (service name) * @param username the username. * @param password the password. * @param nickname the nickname. * @throws InterruptedException * @throws XMPPException thrown if there was an issue registering with the gateway. */ public static void registerUser(XMPPConnection con, DomainBareJid gatewayDomain, String username, String password, String nickname, StanzaListener callback) throws SmackException.NotConnectedException, InterruptedException { Map<String, String> attributes = new HashMap<>(); if (username != null) { attributes.put("username", username); } if (password != null) { attributes.put("password", password); } if (nickname != null) { attributes.put("nick", nickname); } Registration registration = new Registration( attributes ); registration.setType(IQ.Type.set); registration.setTo(gatewayDomain); registration.addExtension(new GatewayRegisterExtension()); con.sendStanzaWithResponseCallback( registration, new IQReplyFilter( registration, con ), callback); }
versionRequest.setTo(jid); connection.sendStanzaWithResponseCallback( versionRequest, new IQReplyFilter( versionRequest, connection ), stanza -> { final Version versionResult = (Version) stanza; softwareField.setText(versionResult.getName()); time.setTo(jid); connection.sendStanzaWithResponseCallback( time, new IQReplyFilter( time, connection ), stanza -> {; timeField.setText( new SimpleDateFormat( ).format( ((Time)stanza).getTime())); ((CardLayout)(cards.getLayout())).last( cards );
/** * @param con the XMPPConnection. * @param gatewayDomain the domain of the gateway (service name) * @throws InterruptedException * @throws XMPPException thrown if there was an issue unregistering with the gateway. */ public static void unregister(XMPPConnection con, DomainBareJid gatewayDomain) throws SmackException.NotConnectedException, InterruptedException { Map<String,String> map = new HashMap<>(); map.put("remove", ""); Registration registration = new Registration( map ); registration.setType(IQ.Type.set); registration.setTo(gatewayDomain); con.sendStanzaWithResponseCallback( registration, new IQReplyFilter( registration, con ), stanza -> { IQ response = (IQ) stanza; if (response.getType() == IQ.Type.error ) { Log.warning( "Unable to unregister from gateway: " + stanza ); } } ); }
private MUCLightBlockingIQ getBlockingList(DomainBareJid mucLightService) throws NoResponseException, XMPPErrorException, InterruptedException, NotConnectedException { MUCLightBlockingIQ mucLightBlockingIQ = new MUCLightBlockingIQ(null, null); mucLightBlockingIQ.setType(Type.get); mucLightBlockingIQ.setTo(mucLightService); StanzaFilter responseFilter = new IQReplyFilter(mucLightBlockingIQ, connection()); IQ responseIq = connection().createStanzaCollectorAndSend(responseFilter, mucLightBlockingIQ) .nextResultOrThrow(); MUCLightBlockingIQ mucLightBlockingIQResult = (MUCLightBlockingIQ) responseIq; return mucLightBlockingIQResult; }
/** * Returns the latest version of Spark available via Spark Manager or Jive Software. * * @param connection the XMPPConnection to use. * @return the information for about the latest Spark Client. * @throws InterruptedException * @throws XMPPException If unable to retrieve latest version. */ public static SparkVersion getLatestVersion(XMPPConnection connection) throws SmackException, XMPPException.XMPPErrorException, InterruptedException { SparkVersion request = new SparkVersion(); request.setType(IQ.Type.get); request.setTo("updater." + connection.getXMPPServiceDomain()); // TODO: This should not use stanza collectors but simply createStanzaCollectorAndSend(IQ).nextResultOrThrow(); StanzaCollector collector = connection.createStanzaCollector(new IQReplyFilter( request, connection )); connection.sendStanza(request); SparkVersion response; try { response = collector.nextResult(); } finally { // Cancel the collector. collector.cancel(); } if (response == null) { throw SmackException.NoResponseException.newWith( connection, collector ); } XMPPException.XMPPErrorException.ifHasErrorThenThrow( response ); return response; }
private MamQueryPage queryArchivePage(MamQueryIQ mamQueryIq) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, NotLoggedInException { final XMPPConnection connection = getAuthenticatedConnectionOrThrow(); MamFinIQ mamFinIQ; StanzaCollector mamFinIQCollector = connection.createStanzaCollector(new IQReplyFilter(mamQueryIq, connection)); StanzaCollector.Configuration resultCollectorConfiguration = StanzaCollector.newConfiguration() .setStanzaFilter(new MamResultFilter(mamQueryIq)).setCollectorToReset(mamFinIQCollector); StanzaCollector resultCollector = connection.createStanzaCollector(resultCollectorConfiguration); try { connection.sendStanza(mamQueryIq); mamFinIQ = mamFinIQCollector.nextResultOrThrow(); } finally { mamFinIQCollector.cancel(); resultCollector.cancel(); } return new MamQueryPage(resultCollector, mamFinIQ); }