public void setPushNotificationEnabled(boolean enable) { getConfig().setBool("app", "push_notification", enable); if (enable) { // Add push infos to exisiting proxy configs String regId = getPushNotificationRegistrationID(); String appId = getString(R.string.push_sender_id); if (regId != null && getLc().getProxyConfigList().length > 0) { for (LinphoneProxyConfig lpc : getLc().getProxyConfigList()) { String contactInfos = "app-id=" + appId + ";pn-type=google;pn-tok=" + regId; lpc.edit(); lpc.setContactUriParameters(contactInfos); lpc.done(); Log.d("Push notif infos added to proxy config"); } getLc().refreshRegisters(); } } else { if (getLc().getProxyConfigList().length > 0) { for (LinphoneProxyConfig lpc : getLc().getProxyConfigList()) { lpc.edit(); lpc.setContactUriParameters(null); lpc.done(); Log.d("Push notif infos removed from proxy config"); } getLc().refreshRegisters(); } } }
public void setAccountContactParameters(int n, String contactParams) { LinphoneProxyConfig prxCfg = getProxyConfig(n); prxCfg.edit(); prxCfg.setContactUriParameters(contactParams); prxCfg.done(); }
/** * Creates a new account * * @throws LinphoneCoreException */ public void saveNewAccount() throws LinphoneCoreException { if (tempUsername == null || tempUsername.length() < 1 || tempDomain == null || tempDomain.length() < 1) { Log.w("Skipping account save: username or domain not provided"); return; } String identity = "sip:" + tempUsername + "@" + tempDomain; String proxy = "sip:"; if (tempProxy == null) { proxy += tempDomain; } else { if (!tempProxy.startsWith("sip:") && !tempProxy.startsWith("<sip:") && !tempProxy.startsWith("sips:") && !tempProxy.startsWith("<sips:")) { proxy += tempProxy; } else { proxy = tempProxy; } } LinphoneAddress proxyAddr = LinphoneCoreFactory.instance().createLinphoneAddress(proxy); LinphoneAddress identityAddr = LinphoneCoreFactory.instance().createLinphoneAddress(identity); if (tempDisplayName != null) { identityAddr.setDisplayName(tempDisplayName); } if (tempTransport != null) { proxyAddr.setTransport(tempTransport); } String route = tempOutboundProxy ? proxyAddr.asStringUriOnly() : null; LinphoneProxyConfig prxCfg = lc.createProxyConfig( identityAddr.asString(), proxyAddr.asStringUriOnly(), route, tempEnabled); if (tempContactsParams != null) prxCfg.setContactUriParameters(tempContactsParams); if (tempExpire != null) { try { prxCfg.setExpires(Integer.parseInt(tempExpire)); } catch (NumberFormatException nfe) { } } prxCfg.enableAvpf(tempAvpfEnabled); prxCfg.setAvpfRRInterval(tempAvpfRRInterval); prxCfg.enableQualityReporting(tempQualityReportingEnabled); prxCfg.setQualityReportingCollector(tempQualityReportingCollector); prxCfg.setQualityReportingInterval(tempQualityReportingInterval); if (tempRealm != null) prxCfg.setRealm(tempRealm); LinphoneAuthInfo authInfo = LinphoneCoreFactory.instance() .createAuthInfo(tempUsername, tempUserId, tempPassword, null, null, tempDomain); lc.addProxyConfig(prxCfg); lc.addAuthInfo(authInfo); if (!tempNoDefault && LinphonePreferences.instance().getAccountCount() == 1) lc.setDefaultProxyConfig(prxCfg); }