Search in sources :

Example 11 with XMPPException

use of org.jivesoftware.smack.XMPPException in project Smack by igniterealtime.

the class IntTestUtil method deleteViaIbr.

public static void deleteViaIbr(XMPPTCPConnection connection) throws InterruptedException {
    // mechanisms
    if (!connection.isConnected()) {
        try {
            connection.connect().login();
        } catch (XMPPException | SmackException | IOException e) {
            LOGGER.log(Level.WARNING, "Exception reconnection account for deletion", e);
        }
    }
    final int maxAttempts = 3;
    AccountManager am = AccountManager.getInstance(connection);
    int attempts;
    for (attempts = 0; attempts < maxAttempts; attempts++) {
        try {
            am.deleteAccount();
        } catch (XMPPErrorException | NoResponseException e) {
            LOGGER.log(Level.WARNING, "Exception deleting account for " + connection, e);
            continue;
        } catch (NotConnectedException e) {
            LOGGER.log(Level.WARNING, "Exception deleting account for " + connection, e);
            try {
                connection.connect().login();
            } catch (XMPPException | SmackException | IOException e2) {
                LOGGER.log(Level.WARNING, "Exception while trying to re-connect " + connection, e);
            }
            continue;
        }
        LOGGER.info("Successfully deleted account of " + connection);
        break;
    }
    if (attempts > maxAttempts) {
        LOGGER.log(Level.SEVERE, "Could not delete account for connection: " + connection);
    }
}
Also used : XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) SmackException(org.jivesoftware.smack.SmackException) AccountManager(org.jivesoftware.smackx.iqregister.AccountManager) IOException(java.io.IOException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException) XMPPException(org.jivesoftware.smack.XMPPException)

Example 12 with XMPPException

use of org.jivesoftware.smack.XMPPException in project Smack by igniterealtime.

the class IntTestUtil method deleteViaServiceAdministration.

public static void deleteViaServiceAdministration(XMPPTCPConnection connection, Configuration config) {
    EntityBareJid accountToDelete = connection.getUser().asEntityBareJid();
    final int maxAttempts = 3;
    int attempts;
    for (attempts = 0; attempts < maxAttempts; attempts++) {
        connection.disconnect();
        try {
            connection.connect().login(config.adminAccountUsername, config.adminAccountPassword);
        } catch (XMPPException | SmackException | IOException | InterruptedException e) {
            LOGGER.log(Level.WARNING, "Exception deleting account for " + connection, e);
            continue;
        }
        ServiceAdministrationManager adminManager = ServiceAdministrationManager.getInstanceFor(connection);
        try {
            adminManager.deleteUser(accountToDelete);
        } catch (NoResponseException | XMPPErrorException | NotConnectedException | InterruptedException e) {
            LOGGER.log(Level.WARNING, "Exception deleting account for " + connection, e);
            continue;
        }
    }
    if (attempts > maxAttempts) {
        LOGGER.log(Level.SEVERE, "Could not delete account for connection: " + connection);
    }
}
Also used : ServiceAdministrationManager(org.jivesoftware.smackx.admin.ServiceAdministrationManager) XMPPErrorException(org.jivesoftware.smack.XMPPException.XMPPErrorException) NotConnectedException(org.jivesoftware.smack.SmackException.NotConnectedException) SmackException(org.jivesoftware.smack.SmackException) IOException(java.io.IOException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException) XMPPException(org.jivesoftware.smack.XMPPException) EntityBareJid(org.jxmpp.jid.EntityBareJid)

Example 13 with XMPPException

use of org.jivesoftware.smack.XMPPException in project Smack by igniterealtime.

the class SmackIntegrationTestFramework method prepareEnvironment.

protected SmackIntegrationTestEnvironment prepareEnvironment() throws SmackException, IOException, XMPPException, InterruptedException, KeyManagementException, NoSuchAlgorithmException {
    XMPPTCPConnection conOne = null;
    XMPPTCPConnection conTwo = null;
    XMPPTCPConnection conThree = null;
    try {
        conOne = getConnectedConnectionFor(AccountNum.One);
        conTwo = getConnectedConnectionFor(AccountNum.Two);
        conThree = getConnectedConnectionFor(AccountNum.Three);
    } catch (Exception e) {
        // TODO Reverse the order, i.e. conThree should be disconnected first.
        if (conOne != null) {
            conOne.disconnect();
        }
        if (conTwo != null) {
            conTwo.disconnect();
        }
        if (conThree != null) {
            conThree.disconnect();
        }
        throw e;
    }
    return new SmackIntegrationTestEnvironment(conOne, conTwo, conThree, testRunResult.testRunId, config);
}
Also used : XMPPTCPConnection(org.jivesoftware.smack.tcp.XMPPTCPConnection) SmackException(org.jivesoftware.smack.SmackException) NoResponseException(org.jivesoftware.smack.SmackException.NoResponseException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) InvocationTargetException(java.lang.reflect.InvocationTargetException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) XMPPException(org.jivesoftware.smack.XMPPException)

Example 14 with XMPPException

use of org.jivesoftware.smack.XMPPException in project Smack by igniterealtime.

the class JingleSessionStateUnknown method receiveSessionInitiateAction.

/**
     * In the UNKNOWN state we received a <session-initiate> action.
     * This method processes that action.
     * @throws SmackException 
     * @throws InterruptedException 
     */
private IQ receiveSessionInitiateAction(JingleSession session, Jingle inJingle) throws SmackException, InterruptedException {
    IQ response = null;
    boolean shouldAck = true;
    if (!shouldAck) {
        response = session.createJingleError(inJingle, JingleError.NEGOTIATION_ERROR);
    } else {
        // Create the Ack
        response = session.createAck(inJingle);
        session.setSessionState(JingleSessionStatePending.getInstance());
        // Now set up all of the initial content negotiators for the session.
        for (JingleContent jingleContent : inJingle.getContentsList()) {
            // First create the content negotiator for this <content> section.
            ContentNegotiator contentNeg = new ContentNegotiator(session, jingleContent.getCreator(), jingleContent.getName());
            // Get the media negotiator that goes with the <description> of this content.
            JingleDescription jingleDescription = jingleContent.getDescription();
            // Loop through each media manager looking for the ones that matches the incoming 
            // session-initiate <content> choices.
            // (Set the first media manager as the default, so that in case things don't match we can still negotiate.)
            JingleMediaManager chosenMediaManager = session.getMediaManagers().get(0);
            for (JingleMediaManager mediaManager : session.getMediaManagers()) {
                boolean matches = true;
                for (PayloadType mediaPayloadType : mediaManager.getPayloads()) {
                    for (PayloadType descPayloadType2 : jingleDescription.getPayloadTypesList()) {
                        if (mediaPayloadType.getId() != descPayloadType2.getId()) {
                            matches = false;
                        }
                    }
                    if (matches) {
                        chosenMediaManager = mediaManager;
                    }
                }
            }
            // Create the media negotiator for this content description.
            contentNeg.setMediaNegotiator(new MediaNegotiator(session, chosenMediaManager, jingleDescription.getPayloadTypesList(), contentNeg));
            // Then create a transport negotiator for that transport.
            for (JingleTransport jingleTransport : jingleContent.getJingleTransportsList()) {
                for (JingleMediaManager mediaManager : session.getMediaManagers()) {
                    JingleTransportManager transportManager = mediaManager.getTransportManager();
                    TransportResolver resolver = null;
                    try {
                        resolver = transportManager.getResolver(session);
                    } catch (XMPPException e) {
                        LOGGER.log(Level.WARNING, "exception", e);
                    }
                    if (resolver.getType().equals(TransportResolver.Type.rawupd)) {
                        contentNeg.setTransportNegotiator(new TransportNegotiator.RawUdp(session, resolver, contentNeg));
                    }
                    if (resolver.getType().equals(TransportResolver.Type.ice)) {
                        contentNeg.setTransportNegotiator(new TransportNegotiator.Ice(session, resolver, contentNeg));
                    }
                }
            }
            // Add the content negotiator to the session.
            session.addContentNegotiator(contentNeg);
        }
        // Now setup to track the media negotiators, so that we know when (if) to send a session-accept.
        session.setupListeners();
    }
    return response;
}
Also used : JingleDescription(org.jivesoftware.smackx.jingleold.packet.JingleDescription) IQ(org.jivesoftware.smack.packet.IQ) MediaNegotiator(org.jivesoftware.smackx.jingleold.media.MediaNegotiator) JingleTransport(org.jivesoftware.smackx.jingleold.packet.JingleTransport) PayloadType(org.jivesoftware.smackx.jingleold.media.PayloadType) TransportNegotiator(org.jivesoftware.smackx.jingleold.nat.TransportNegotiator) JingleMediaManager(org.jivesoftware.smackx.jingleold.media.JingleMediaManager) TransportResolver(org.jivesoftware.smackx.jingleold.nat.TransportResolver) JingleContent(org.jivesoftware.smackx.jingleold.packet.JingleContent) XMPPException(org.jivesoftware.smack.XMPPException) JingleTransportManager(org.jivesoftware.smackx.jingleold.nat.JingleTransportManager)

Example 15 with XMPPException

use of org.jivesoftware.smack.XMPPException in project Smack by igniterealtime.

the class Demo method initialize.

public void initialize() {
    ICETransportManager icetm0 = new ICETransportManager(xmppConnection, "10.47.47.53", 3478);
    List<JingleMediaManager> mediaManagers = new ArrayList<JingleMediaManager>();
    //mediaManagers.add(new JmfMediaManager(icetm0));
    mediaManagers.add(new SpeexMediaManager(icetm0));
    mediaManagers.add(new ScreenShareMediaManager(icetm0));
    jm = new JingleManager(xmppConnection, mediaManagers);
    jm.addCreationListener(icetm0);
    jm.addJingleSessionRequestListener(new JingleSessionRequestListener() {

        public void sessionRequested(JingleSessionRequest request) {
            try {
                // Accept the call
                incoming = request.accept();
                // Start the call
                incoming.startIncoming();
            } catch (XMPPException e) {
                LOGGER.log(Level.WARNING, "exception", e);
            }
        }
    });
    createGUI();
}
Also used : ICETransportManager(org.jivesoftware.smackx.jingle.nat.ICETransportManager) JingleMediaManager(org.jivesoftware.smackx.jingle.media.JingleMediaManager) ArrayList(java.util.ArrayList) JingleManager(org.jivesoftware.smackx.jingle.JingleManager) JingleSessionRequest(org.jivesoftware.smackx.jingle.JingleSessionRequest) ScreenShareMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.sshare.ScreenShareMediaManager) SpeexMediaManager(org.jivesoftware.smackx.jingle.mediaimpl.jspeex.SpeexMediaManager) XMPPException(org.jivesoftware.smack.XMPPException) JingleSessionRequestListener(org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener)

Aggregations

XMPPException (org.jivesoftware.smack.XMPPException)52 ArrayList (java.util.ArrayList)15 JingleSessionRequestListener (org.jivesoftware.smackx.jingle.listeners.JingleSessionRequestListener)13 JingleMediaManager (org.jivesoftware.smackx.jingle.media.JingleMediaManager)13 NotConnectedException (org.jivesoftware.smack.SmackException.NotConnectedException)9 IOException (java.io.IOException)8 SmackException (org.jivesoftware.smack.SmackException)7 PayloadType (org.jivesoftware.smackx.jingle.media.PayloadType)6 NoResponseException (org.jivesoftware.smack.SmackException.NoResponseException)5 Message (org.jivesoftware.smack.packet.Message)5 FixedResolver (org.jivesoftware.smackx.jingle.nat.FixedResolver)5 FixedTransportManager (org.jivesoftware.smackx.jingle.nat.FixedTransportManager)5 TransportCandidate (org.jivesoftware.smackx.jingle.nat.TransportCandidate)5 TCPConnection (org.jivesoftware.smack.TCPConnection)4 XMPPConnection (org.jivesoftware.smack.XMPPConnection)4 Form (org.jivesoftware.smackx.Form)4 JingleSessionListener (org.jivesoftware.smackx.jingle.listeners.JingleSessionListener)4 JmfMediaManager (org.jivesoftware.smackx.jingle.mediaimpl.jmf.JmfMediaManager)4 ICETransportManager (org.jivesoftware.smackx.jingle.nat.ICETransportManager)4 SocketException (java.net.SocketException)3