예제 #1
0
  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");
          }
        });
  }
  /** Initialize the features provided by beem. */
  private void initFeatures() {
    ServiceDiscoveryManager.setIdentityName("Beem");
    ServiceDiscoveryManager.setIdentityType("phone");
    ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(mAdaptee);
    if (sdm == null) sdm = new ServiceDiscoveryManager(mAdaptee);

    sdm.addFeature("http://jabber.org/protocol/disco#info");
    // nikita: must be uncommented when the feature will be enabled
    // sdm.addFeature("jabber:iq:privacy");
    sdm.addFeature("http://jabber.org/protocol/caps");
    sdm.addFeature("urn:xmpp:avatar:metadata");
    sdm.addFeature("urn:xmpp:avatar:metadata+notify");
    sdm.addFeature("urn:xmpp:avatar:data");
    sdm.addFeature("http://jabber.org/protocol/nick");
    sdm.addFeature("http://jabber.org/protocol/nick+notify");
    sdm.addFeature(PingExtension.NAMESPACE);

    mChatStateManager = ChatStateManager.getInstance(mAdaptee);
    BeemCapsManager caps = new BeemCapsManager(sdm, mAdaptee, mService);
    caps.setNode("http://www.beem-project.com");
  }