static {
    instance = new ConnectionManager();
    Application.getInstance().addManager(instance);

    SmackConfiguration.setPacketReplyTimeout(PACKET_REPLY_TIMEOUT);

    ServiceDiscoveryManager.setIdentityType("handheld");
    ServiceDiscoveryManager.setIdentityName(
        Application.getInstance().getString(R.string.client_name));

    SASLAuthentication.registerSASLMechanism("X-MESSENGER-OAUTH2", XMessengerOAuth2.class);
    SASLAuthentication.supportSASLMechanism("X-MESSENGER-OAUTH2");

    String path = System.getProperty("javax.net.ssl.trustStore");
    if (path == null)
      TRUST_STORE_PATH =
          System.getProperty("java.home")
              + File.separator
              + "etc"
              + File.separator
              + "security"
              + File.separator
              + "cacerts.bks";
    else TRUST_STORE_PATH = path;

    Connection.addConnectionCreationListener(
        new ConnectionCreationListener() {
          @Override
          public void connectionCreated(final Connection connection) {
            ServiceDiscoveryManager.getInstanceFor(connection).addFeature("sslc2s");
          }
        });
  }
 // Register file transfer features on every established connection
 // to make sure we register them before creating our
 // ServiceDiscoveryManager
 static {
   Connection.addConnectionCreationListener(
       new ConnectionCreationListener() {
         public void connectionCreated(Connection connection) {
           FileTransferNegotiator.getInstanceFor(connection);
         }
       });
 }
 // Create a new ServiceDiscoveryManager on every established connection
 static {
   Connection.addConnectionCreationListener(
       new ConnectionCreationListener() {
         public void connectionCreated(Connection connection) {
           getInstanceFor(connection);
         }
       });
 }
Example #4
0
 /**
  * Register the listener for all the connection creations. When a new connection is created a new
  * AdHocCommandManager is also created and related to that connection.
  */
 static {
   Connection.addConnectionCreationListener(
       new ConnectionCreationListener() {
         public void connectionCreated(Connection connection) {
           getAddHocCommandsManager(connection);
         }
       });
 }
Example #5
0
 // Enable the XHTML support on every established connection
 // The ServiceDiscoveryManager class should have been already initialized
 static {
   Connection.addConnectionCreationListener(
       new ConnectionCreationListener() {
         public void connectionCreated(Connection connection) {
           XHTMLManager.setServiceEnabled(connection, true);
         }
       });
 }
 static {
   // Create a new PrivacyListManager on every established connection. In the init()
   // method of PrivacyListManager, we'll add a listener that will delete the
   // instance when the connection is closed.
   Connection.addConnectionCreationListener(
       new ConnectionCreationListener() {
         public void connectionCreated(Connection connection) {
           connection.addConnectionListener(new ReconnectionManager(connection));
         }
       });
 }
  /*
   * create a new InBandBytestreamManager and register its shutdown listener
   * on every established connection
   */
  static {
    Connection.addConnectionCreationListener(
        new ConnectionCreationListener() {
          @Override
          public void connectionCreated(Connection connection) {
            final InBandBytestreamManager manager;
            manager = InBandBytestreamManager.getByteStreamManager(connection);

            // register shutdown listener
            connection.addConnectionListener(
                new AbstractConnectionListener() {

                  @Override
                  public void connectionClosed() {
                    manager.disableService();
                  }
                });
          }
        });
  }