Пример #1
0
  /**
   * Fired when softphone is register sucessfully
   *
   * @param evt RegistrationEvent
   */
  public void registered(RegistrationEvent evt) {
    status = SipRegisterStatus.Registered;

    preferences.setPreferredAddress(NetworkAddressManager.getLocalHost().getHostAddress());
    // preference.commit();

    registerStatusChanged(new RegisterEvent(this, SipRegisterStatus.Registered, evt.getReason()));

    if (callTo.length() > 2) {
      handleDialRequest(callTo);
    }
    registerMenu.setSelected(true);
  }
Пример #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);
    }
  }