Search in sources :

Example 1 with SipPreferences

use of org.jivesoftware.sparkplugin.preferences.SipPreferences in project Spark by igniterealtime.

the class SoftPhoneManager method setupRemotePreferences.

/**
 * 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);
    }
}
Also used : SipPreference(org.jivesoftware.sparkplugin.preferences.SipPreference) LogPacket(org.jivesoftware.sparkplugin.calllog.LogPacket) SipAccount(org.jivesoftware.sparkplugin.sipaccount.SipAccount) SipPreferences(org.jivesoftware.sparkplugin.preferences.SipPreferences) SipAccountPacket(org.jivesoftware.sparkplugin.sipaccount.SipAccountPacket)

Aggregations

LogPacket (org.jivesoftware.sparkplugin.calllog.LogPacket)1 SipPreference (org.jivesoftware.sparkplugin.preferences.SipPreference)1 SipPreferences (org.jivesoftware.sparkplugin.preferences.SipPreferences)1 SipAccount (org.jivesoftware.sparkplugin.sipaccount.SipAccount)1 SipAccountPacket (org.jivesoftware.sparkplugin.sipaccount.SipAccountPacket)1