コード例 #1
0
  private void loadLocalPreferences() {
    preference = new SipPreference();

    PreferenceManager pm = SparkManager.getPreferenceManager();
    pm.addPreference(preference);

    preferences = (SipPreferences) preference.getData();

    SIPConfig.setUseStun(preferences.isUseStun());
    SIPConfig.setStunServer(preferences.getStunServer());
    SIPConfig.setStunPort(preferences.getStunPort());
    SIPConfig.setPreferredNetworkAddress(preferences.getPreferredAddress());

    preference.setCommitSettings(true);

    if (preferences.isRegisterAtStart()) {
      register();
    }
  }
コード例 #2
0
  /**
   * Setup the Preferences according to remote server
   *
   * @param con XMPPConnection connection
   */
  private void setupRemotePreferences(XMPPConnection con) {

    try {
      ProviderManager.addIQProvider(
          SipAccountPacket.ELEMENT_NAME,
          SipAccountPacket.NAMESPACE,
          new SipAccountPacket.Provider());

      ProviderManager.addIQProvider(
          LogPacket.ELEMENT_NAME, LogPacket.NAMESPACE, new LogPacket.Provider());

      SipAccountPacket sp = SipAccountPacket.getSipSettings(con);

      if (sp != null) {

        SipAccount sipAccount = sp.getSipAccount();

        if (sipAccount != null) {
          this.saccount = sipAccount;
          preference = new SipPreference();
          preference.setShowGUI(false);
          preference.setCommitSettings(false);

          preferences = new SipPreferences();

          preferences.setUserName(sipAccount.getSipUsername());
          preferences.setAuthUserName(sipAccount.getAuthUsername());
          preferences.setServer(sipAccount.getServer());
          preferences.setPassword(sipAccount.getPassword());
          preferences.setRegisterAtStart(true);

          preferences.setStunServer(sipAccount.getStunServer());
          preferences.setStunPort(sipAccount.getStunPort());
          preferences.setUseStun(sipAccount.isUseStun());
          preferences.setVoicemail(sipAccount.getVoiceMailNumber());
          preferences.setOutboundproxy(sipAccount.getOutboundproxy());
          preferences.setPromptCredentials(sipAccount.isPromptCredentials());

          SIPConfig.setUseStun(preferences.isUseStun());
          SIPConfig.setStunServer(preferences.getStunServer());
          SIPConfig.setStunPort(preferences.getStunPort());
          SIPConfig.setOutboundProxy(preferences.getOutboundproxy());

          preference.setData(preferences);
          SIPConfig.setPreferredNetworkAddress(
              NetworkAddressManager.getLocalHost(false).getHostAddress());

          if (preferences.isRegisterAtStart()) {
            register();
          }

          if (preferences.isPromptCredentials()) {
            loadLocalPreferences();
          }

        } else {

        }
      }

    } catch (Exception e) {
      Log.error("setupRemotePreferences", e);
    }
  }