コード例 #1
0
  protected void setupSIP(Context context, SIP5060ProvisioningRequest req) throws IOException {

    AppProperties props = new AppProperties(context);

    // Setup the SIP preferences
    SharedPreferences settings =
        context.getSharedPreferences(RegisterAccount.PREFS_FILE, Context.MODE_PRIVATE);

    SharedPreferences sipSettings =
        context.getSharedPreferences(Settings.sharedPrefsFile, Context.MODE_PRIVATE);
    Editor edSIP = sipSettings.edit();

    String num = req.getPhoneNumber();

    LumicallDataSource ds = new LumicallDataSource(context);
    ds.open();
    SIPIdentity sipIdentity = createSIPIdentity(props, settings, req);
    for (SIPIdentity s : ds.getSIPIdentities()) {
      if (s.getUri().equals(sipIdentity.getUri())) sipIdentity.setId(s.getId());
    }
    ds.persistSIPIdentity(sipIdentity);
    ds.deleteSIP5060ProvisioningRequest(req);
    ds.close();
    edSIP.putString(Settings.PREF_SIP, Long.toString(sipIdentity.getId()));
    if (!sipSettings.contains(Settings.PREF_TEL)) edSIP.putString(Settings.PREF_TEL, "-1");

    /* edSIP.putString(Settings.PREF_USERNAME, settings.getString(RegisterAccount.PREF_PHONE_NUMBER, null));
    edSIP.putString(Settings.PREF_PASSWORD, settings.getString(RegisterAccount.PREF_SECRET, null));
    edSIP.putString(Settings.PREF_SERVER, DEFAULT_SIP_SERVER);
    edSIP.putString(Settings.PREF_DOMAIN, DEFAULT_SIP_DOMAIN);
    edSIP.putString(Settings.PREF_PROTOCOL, "tcp");  // FIXME - change to TLS
    edSIP.putBoolean(Settings.PREF_STUN, true);
    edSIP.putString(Settings.PREF_STUN_SERVER, DEFAULT_STUN_SERVER);
    edSIP.putString(Settings.PREF_STUN_SERVER_PORT, "" + DEFAULT_STUN_SERVER_PORT); */
    edSIP.putBoolean(Settings.PREF_WLAN, true);
    edSIP.putBoolean(Settings.PREF_EDGE, true);
    edSIP.putBoolean(Settings.PREF_3G, true);
    edSIP.putBoolean(Settings.PREF_ON, true);

    if (edSIP.commit()) Log.v(TAG, "Configured prefs for number " + num);
    else {
      Log.e(TAG, "error while committing preferences");
    }

    // Receiver.engine(context).updateDNS();
    Receiver.engine(context).halt();
    Receiver.engine(context).StartEngine();
  }
コード例 #2
0
  private SIPIdentity createSIPIdentity(
      AppProperties props, SharedPreferences settings, SIP5060ProvisioningRequest req) {

    SIPIdentity sipIdentity = new SIPIdentity();
    String uri = req.getPhoneNumber() + "@" + props.getSipDomain();
    sipIdentity.setUri(uri);
    sipIdentity.setAuthUser(uri);
    sipIdentity.setAuthPassword(req.getAuthPassword());
    sipIdentity.setReg(true);
    // sipIdentity.setRegServerName(props.getSipServer());
    sipIdentity.setRegServerName("");
    sipIdentity.setRegServerPort(props.getSipPort());
    sipIdentity.setRegServerProtocol(props.getSipProtocol());
    // sipIdentity.setOutboundServerName(props.getSipServer());
    sipIdentity.setOutboundServerName("");
    sipIdentity.setOutboundServerPort(props.getSipPort());
    sipIdentity.setOutboundServerProtocol(props.getSipProtocol());
    sipIdentity.setCarrierRoute(false);
    // sipIdentity.setStunServerName(props.getStunServer());
    sipIdentity.setStunServerName("");
    sipIdentity.setStunServerPort(props.getStunPort());
    sipIdentity.setStunServerProtocol("udp");
    return sipIdentity;
  }