コード例 #1
0
ファイル: XMPPSession.java プロジェクト: Coselding/Openfire
  /**
   * Create an XMPP Session instance.
   *
   * @param registration Registration information used for logging in.
   * @param jid JID associated with this session.
   * @param transport Transport instance associated with this session.
   * @param priority Priority of this session.
   */
  public XMPPSession(
      Registration registration, JID jid, XMPPTransport transport, Integer priority) {
    super(registration, jid, transport, priority);
    setSupportedFeature(SupportedFeature.attention);
    setSupportedFeature(SupportedFeature.chatstates);

    Log.debug(
        "Creating " + getTransport().getType() + " session for " + registration.getUsername());
    String connecthost;
    Integer connectport;
    String domain;

    connecthost =
        JiveGlobals.getProperty(
            "plugin.gateway." + getTransport().getType() + ".connecthost",
            (getTransport().getType().equals(TransportType.gtalk)
                ? "talk.google.com"
                : getTransport().getType().equals(TransportType.facebook)
                    ? "chat.facebook.com"
                    : "jabber.org"));
    connectport =
        JiveGlobals.getIntProperty(
            "plugin.gateway." + getTransport().getType() + ".connectport", 5222);

    if (getTransport().getType().equals(TransportType.gtalk)) {
      domain = "gmail.com";
    } else if (getTransport().getType().equals(TransportType.facebook)) {
      // if (connecthost.equals("www.facebook.com")) {
      connecthost = "chat.facebook.com";
      // }
      // if (connectport.equals(80)) {
      connectport = 5222;
      // }
      domain = "chat.facebook.com";
    } else if (getTransport().getType().equals(TransportType.renren)) {
      connecthost = "talk.renren.com";
      connectport = 5222;
      domain = "renren.com";
    } else {
      domain = connecthost;
    }

    // For different domains other than 'gmail.com', which is given with Google Application services
    if (registration.getUsername().indexOf("@") > -1) {
      domain = registration.getUsername().substring(registration.getUsername().indexOf("@") + 1);
    }

    // If administrator specified "*" for domain, allow user to connect to anything.
    if (connecthost.equals("*")) {
      connecthost = domain;
    }

    config = new ConnectionConfiguration(connecthost, connectport, domain);
    config.setCompressionEnabled(
        JiveGlobals.getBooleanProperty(
            "plugin.gateway." + getTransport().getType() + ".usecompression", false));

    if (getTransport().getType().equals(TransportType.facebook)) {
      // SASLAuthentication.supportSASLMechanism("PLAIN", 0);
      // config.setSASLAuthenticationEnabled(false);
      // config.setSecurityMode(ConnectionConfiguration.SecurityMode.enabled);
    }

    // instead, send the initial presence right after logging in. This
    // allows us to use a different presence mode than the plain old
    // 'available' as initial presence.
    config.setSendPresence(false);

    if (getTransport().getType().equals(TransportType.gtalk)
        && JiveGlobals.getBooleanProperty("plugin.gateway.gtalk.mailnotifications", true)) {
      ProviderManager.getInstance()
          .addIQProvider(
              GoogleMailBoxPacket.MAILBOX_ELEMENT,
              GoogleMailBoxPacket.MAILBOX_NAMESPACE,
              new GoogleMailBoxPacket.Provider());
      ProviderManager.getInstance()
          .addExtensionProvider(
              GoogleNewMailExtension.ELEMENT_NAME,
              GoogleNewMailExtension.NAMESPACE,
              new GoogleNewMailExtension.Provider());
    }
  }
コード例 #2
0
 /**
  * Retrieves a pseudo roster based off of a registration.
  *
  * @param registration To retrieve the roster for.
  * @return A Pseudo roster
  */
 public PseudoRoster getPseudoRoster(Registration registration) {
   return getPseudoRoster(registration.getRegistrationID());
 }