Package net.rim.device.api.io.transport

Examples of net.rim.device.api.io.transport.ConnectionFactory


    }
   
    _success = success;
    _error = error;
   
    _factory = new ConnectionFactory();
   
    if (DeviceInfo.isSimulator()) {
      _factory.setPreferredTransportTypes(new int[] { TransportInfo.TRANSPORT_TCP_WIFI, TransportInfo.TRANSPORT_TCP_CELLULAR });
    }
   
View Full Code Here


      _transports = transports;
    }
    _success = success;
    _error = error;
   
    _factory = new ConnectionFactory();
   
    if (DeviceInfo.isSimulator()) {
      _factory.setPreferredTransportTypes(new int[] { TransportInfo.TRANSPORT_TCP_WIFI, TransportInfo.TRANSPORT_TCP_CELLULAR });
    }
   
View Full Code Here

     * Sets the ConnectionFactory to have transport settings from the WidgetConfigImpl.
     */
    private void updateConnectionFactory() {
        // Cast the WidgetConfig to WidgetConfigImpl version.
        WidgetConfigImpl wConfigImpl = (WidgetConfigImpl) _wConfig;
        ConnectionFactory connFact = new ConnectionFactory();

        // Set default transport order.
        connFact.setPreferredTransportTypes( PREFERRED_TRANSPORTS );

        // Set default time out for all connections to 30 seconds.
        connFact.setTimeLimit( 30000L );

        // Set transports if specified in config.xml.
        if( wConfigImpl.getPreferredTransports() != null ) {
            connFact.setPreferredTransportTypes( wConfigImpl.getPreferredTransports() );

            // Set the timeout for transports.
            if( wConfigImpl.getTransportTimeout() != null && wConfigImpl.getTransportTimeout().intValue() >= 0 ) {
                // setTimeLimit sets the max time limit for making a connection.
                connFact.setTimeLimit( wConfigImpl.getTransportTimeout().longValue() );
            }
        }

        // Set options.
        connFact.setTransportTypeOptions( TransportInfo.TRANSPORT_BIS_B, new BisBOptions( "mds-public" ) );
        connFact.setTimeoutSupported( true );

        // Set BrowserFieldConfig.
        _bfConfig.setProperty( BrowserFieldConfig.CONNECTION_FACTORY, connFact );

    }
View Full Code Here

    }
    return _dispatcher;
  }

  public Dispatcher() {
    _factory = new ConnectionFactory();
    _factory.setAttemptsLimit(3);
    if (DeviceInfo.isSimulator()) {
      _factory.setPreferredTransportTypes(new int[] { TransportInfo.TRANSPORT_TCP_WIFI,
          TransportInfo.TRANSPORT_TCP_CELLULAR });
    }
View Full Code Here

            displayMessage("Please provide a URL");
            return;
        }

        // Create ConnectionFactory
        final ConnectionFactory factory = new ConnectionFactory();

        // Register as listener
        factory.setConnectionAttemptListener(this);

        // Set connection mode
        switch (_connectionMode.getSelectedIndex()) {
        case 0:
            factory.setConnectionMode(ConnectionFactory.ACCESS_READ);
            break;
        case 1:
            factory.setConnectionMode(ConnectionFactory.ACCESS_WRITE);
            break;
        case 2:
            factory.setConnectionMode(ConnectionFactory.ACCESS_READ_WRITE);
            break;
        }

        // Set connection timeout
        factory.setTimeoutSupported(_timeoutSupported.getChecked());

        factory.setEndToEndDesired(_endToEndDesired.getChecked());
        factory.setEndToEndRequired(_endToEndRequired.getChecked());

        try {
            final String connectionTimeoutText = _connectionTimeout.getText();
            if (connectionTimeoutText != null
                    && connectionTimeoutText.trim().length() > 0) {
                // Parse connection timeout text into long
                final long connectionTimeout =
                        Long.parseLong(connectionTimeoutText);
                if (connectionTimeout >= 0) {
                    // Set connection timeout value
                    factory.setConnectionTimeout(connectionTimeout);
                }
            }
        } catch (final NumberFormatException nfe) {
            displayMessage("Long.parseLong(String) threw : " + nfe.toString());
        }

        // Set connection security settings for tls/ssl
        factory.setEndToEndDesired(_endToEndDesired.getChecked());
        factory.setEndToEndRequired(_endToEndRequired.getChecked());

        // Set time limit
        final long timeLimit = Long.parseLong(_timeLimit.getText());
        if (timeLimit > 0) {
            factory.setTimeLimit(timeLimit);
        }

        // Set attempts limit
        final int attemptsLimit = Integer.parseInt(_attemptsLimit.getText());
        if (attemptsLimit > 0) {
            factory.setAttemptsLimit(attemptsLimit);
        }

        // Set retry factor
        final long retryFactor = Long.parseLong(_retryFactor.getText());
        if (retryFactor > 0) {
            factory.setRetryFactor(retryFactor);
        }

        // Set TCP Cellular options
        if (_tcpApn.getText().trim().length() != 0
                || _tcpApnUser.getText().trim().length() != 0
                || _tcpApnPassword.getText().trim().length() != 0) {

            final TcpCellularOptions tcpOptions = new TcpCellularOptions();
            tcpOptions.setApn(_tcpApn.getText().trim());
            tcpOptions.setTunnelAuthUsername(_tcpApnUser.getText().trim());
            tcpOptions.setTunnelAuthPassword(_tcpApnPassword.getText().trim());

            factory.setTransportTypeOptions(
                    TransportInfo.TRANSPORT_TCP_CELLULAR, tcpOptions);
        }

        // Set WAP Options
        if (!_wapGatewayApn.getText().trim().equals("")
                || !_wapGatewayIp.getText().trim().equals("")
                || !_wapGatewayPort.getText().trim().equals("")
                || !_wapSourceIp.getText().trim().equals("")
                || !_wapSourcePort.getText().trim().equals("")
                || !_wapUser.getText().trim().equals("")
                || !_wapPassword.getText().trim().equals("")
                || _wapEnableWTLS.getChecked()) {

            final WapOptions wapOptions = new WapOptions();
            wapOptions.setWapGatewayApn(_wapGatewayApn.getText().trim());
            wapOptions.setWapGatewayIp(_wapGatewayIp.getText().trim());
            wapOptions.setWapGatewayPort(_wapGatewayPort.getText().trim());
            wapOptions.setWapSourceIp(_wapSourceIp.getText().trim());
            wapOptions.setWapSourcePort(_wapSourcePort.getText().trim());
            wapOptions.setTunnelAuthUsername(_wapUser.getText().trim());
            wapOptions.setTunnelAuthPassword(_wapPassword.getText().trim());
            wapOptions.setWapEnableWTLS(_wapEnableWTLS.getChecked());

            factory.setTransportTypeOptions(TransportInfo.TRANSPORT_WAP,
                    wapOptions);
        }

        // Set BisB options
        factory.setTransportTypeOptions(TransportInfo.TRANSPORT_BIS_B,
                new BisBOptions(_bisBConnectionType.getText().trim()));

        // Get preferred transports option
        int[] preferredTransports = null;

        if (_transportSelection.getChecked()) {
            if (_order1.getSelectedIndex() == 0
                    && _order2.getSelectedIndex() == 0
                    && _order3.getSelectedIndex() == 0
                    && _order4.getSelectedIndex() == 0
                    && _order5.getSelectedIndex() == 0
                    && _order6.getSelectedIndex() == 0) {
                // Display a warning if none of the preferred transport is
                // specified when "Preferred Transports" check box is checked
                displayMessage("Please select at least one transport or uncheck \"Preferred Transports\"");
                return;
            }

            // Get rid of the "none" elements
            final IntVector transportIdsVector = new IntVector();
            if (_order1.getSelectedIndex() != 0) {
                transportIdsVector.addElement(_order1.getSelectedIndex());
            }
            if (_order2.getSelectedIndex() != 0) {
                transportIdsVector.addElement(_order2.getSelectedIndex());
            }
            if (_order3.getSelectedIndex() != 0) {
                transportIdsVector.addElement(_order3.getSelectedIndex());
            }
            if (_order4.getSelectedIndex() != 0) {
                transportIdsVector.addElement(_order4.getSelectedIndex());
            }
            if (_order5.getSelectedIndex() != 0) {
                transportIdsVector.addElement(_order5.getSelectedIndex());
            }
            if (_order6.getSelectedIndex() != 0) {
                transportIdsVector.addElement(_order6.getSelectedIndex());
            }

            transportIdsVector.trimToSize();
            preferredTransports = transportIdsVector.getArray();
        }

        // Process disallowed transports
        final IntVector disallowedTransports = new IntVector();

        if (_disallowDirectTCP.getChecked()) {
            disallowedTransports
                    .addElement(TransportInfo.TRANSPORT_TCP_CELLULAR);
        }
        if (_disallowWap.getChecked()) {
            disallowedTransports.addElement(TransportInfo.TRANSPORT_WAP);
        }
        if (_disallowWap2.getChecked()) {
            disallowedTransports.addElement(TransportInfo.TRANSPORT_WAP2);
        }
        if (_disallowMds.getChecked()) {
            disallowedTransports.addElement(TransportInfo.TRANSPORT_MDS);
        }
        if (_disallowBisB.getChecked()) {
            disallowedTransports.addElement(TransportInfo.TRANSPORT_BIS_B);
        }
        if (_disallowWifi.getChecked()) {
            disallowedTransports.addElement(TransportInfo.TRANSPORT_TCP_WIFI);
        }

        // Trim excess
        disallowedTransports.trimToSize();

        // Configure the factory if needed
        if (disallowedTransports.size() > 0) {
            factory.setDisallowedTransportTypes(disallowedTransports.getArray());
        }

        // Get the connection
        Status.show("Attempting Connection...", 500);
        final Thread t =
View Full Code Here

        /**
         * @see Thread#run()
         */
        public void run() {
            // Create a ConnectionFactory
            final ConnectionFactory factory = new ConnectionFactory();

            // Use the factory to get a connection
            final ConnectionDescriptor connectionDescriptor =
                    factory.getConnection(_url, _connectionType, _connectionUID);

            if (connectionDescriptor != null) {
                // Connection succeeded
                final int transportUsed =
                        connectionDescriptor.getTransportDescriptor()
View Full Code Here

TOP

Related Classes of net.rim.device.api.io.transport.ConnectionFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.