예제 #1
0
  private void displayCall(Resources resources, LinphoneCall call, int index) {
    String sipUri = call.getRemoteAddress().asStringUriOnly();
    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
      Log.e("Incall activity cannot parse remote address", e);
      lAddress =
          LinphoneCoreFactory.instance().createLinphoneAddress("uknown", "unknown", "unkonown");
    }

    // Control Row
    LinearLayout callView =
        (LinearLayout) inflater.inflate(R.layout.active_call_control_row, container, false);
    callView.setId(index + 1);
    setContactName(callView, lAddress, sipUri, resources);
    displayCallStatusIconAndReturnCallPaused(callView, call);
    setRowBackground(callView, index);
    registerCallDurationTimer(callView, call);
    callsList.addView(callView);

    // Image Row
    LinearLayout imageView =
        (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
    Contact contact =
        ContactsManager.getInstance()
            .findContactWithAddress(imageView.getContext().getContentResolver(), lAddress);
    if (contact != null) {
      displayOrHideContactPicture(
          imageView, contact.getPhotoUri(), contact.getThumbnailUri(), false);
    } else {
      displayOrHideContactPicture(imageView, null, null, false);
    }
    callsList.addView(imageView);

    callView.setTag(imageView);
    callView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (v.getTag() != null) {
              View imageView = (View) v.getTag();
              if (imageView.getVisibility() == View.VISIBLE) imageView.setVisibility(View.GONE);
              else imageView.setVisibility(View.VISIBLE);
              callsList.invalidate();
            }
          }
        });
  }
  public LpConfig getConfig() {
    LinphoneCore lc = getLc();
    if (lc != null) {
      return lc.getConfig();
    }

    if (!LinphoneManager.isInstanciated()) {
      Log.w("LinphoneManager not instanciated yet...");
      return LinphoneCoreFactory.instance()
          .createLpConfig(mContext.getFilesDir().getAbsolutePath() + "/.linphonerc");
    }

    return LinphoneCoreFactory.instance()
        .createLpConfig(LinphoneManager.getInstance().mLinphoneConfigFile);
  }
예제 #3
0
  private void displayChatHeader(String displayName, String pictureUri) {
    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
      Contact contact =
          ContactsManager.getInstance()
              .findContactWithAddress(getActivity().getContentResolver(), lAddress);
      if (contact != null) {
        LinphoneUtils.setImagePictureFromUri(
            getActivity(),
            contactPicture.getView(),
            contact.getPhotoUri(),
            contact.getThumbnailUri(),
            R.drawable.unknown_small);

      } else {
        contactPicture.setImageResource(R.drawable.unknown_small);
      }
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }

    contactName.setTextSize(15);
    if (displayName == null
        && getResources().getBoolean(R.bool.only_display_username_if_unknown)
        && LinphoneUtils.isSipAddress(sipUri)) {
      contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
    } else if (displayName == null) {
      contactName.setText(sipUri);
    } else {
      contactName.setText(displayName);
    }
  }
  public void setAccountProxy(int n, String proxy) {
    if (proxy == null || proxy.length() <= 0) {
      proxy = getAccountDomain(n);
    }

    if (!proxy.contains("sip:")) {
      proxy = "sip:" + proxy;
    }

    try {
      LinphoneAddress proxyAddr = LinphoneCoreFactory.instance().createLinphoneAddress(proxy);
      if (!proxy.contains("transport=")) {
        proxyAddr.setTransport(getAccountTransport(n));
      }

      LinphoneProxyConfig prxCfg = getProxyConfig(n);
      prxCfg.edit();
      prxCfg.setProxy(proxyAddr.asStringUriOnly());
      prxCfg.done();

      if (isAccountOutboundProxySet(n)) {
        setAccountOutboundProxyEnabled(n, true);
      }
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }
  }
  public String getAccountDisplayName(int n) {
    try {
      LinphoneAddress addr =
          LinphoneCoreFactory.instance().createLinphoneAddress(getProxyConfig(n).getIdentity());
      return addr.getDisplayName();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
 public void setAccountDisplayName(int n, String displayName) {
   try {
     LinphoneProxyConfig prxCfg = getProxyConfig(n);
     LinphoneAddress addr =
         LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
     addr.setDisplayName(displayName);
     prxCfg.edit();
     prxCfg.setIdentity(addr.asString());
     prxCfg.done();
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  private LinphoneAuthInfo getAuthInfo(int n) {
    LinphoneProxyConfig prxCfg = getProxyConfig(n);
    try {
      LinphoneAddress addr =
          LinphoneCoreFactory.instance().createLinphoneAddress(prxCfg.getIdentity());
      LinphoneAuthInfo authInfo = getLc().findAuthInfo(addr.getUserName(), null, addr.getDomain());
      return authInfo;
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }

    return null;
  }
  public void displayHistoryDetail(String sipUri, LinphoneCallLog log) {
    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
      Log.e("Cannot display history details", e);
      return;
    }
    Contact c =
        ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);

    String displayName = c != null ? c.getName() : null;
    String pictureUri = c != null && c.getPhotoUri() != null ? c.getPhotoUri().toString() : null;

    String status;
    if (log.getDirection() == CallDirection.Outgoing) {
      status = "Outgoing";
    } else {
      if (log.getStatus() == CallStatus.Missed) {
        status = "Missed";
      } else {
        status = "Incoming";
      }
    }

    String callTime = secondsToDisplayableString(log.getCallDuration());
    String callDate = String.valueOf(log.getTimestamp());

    Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
    if (fragment2 != null
        && fragment2.isVisible()
        && currentFragment == FragmentsAvailable.HISTORY_DETAIL) {
      HistoryDetailFragment historyDetailFragment = (HistoryDetailFragment) fragment2;
      historyDetailFragment.changeDisplayedHistory(
          sipUri, displayName, pictureUri, status, callTime, callDate);
    } else {
      Bundle extras = new Bundle();
      extras.putString("SipUri", sipUri);
      if (displayName != null) {
        extras.putString("DisplayName", displayName);
        extras.putString("PictureUri", pictureUri);
      }
      extras.putString("CallStatus", status);
      extras.putString("CallTime", callTime);
      extras.putString("CallDate", callDate);

      changeCurrentFragment(FragmentsAvailable.HISTORY_DETAIL, extras);
    }
  }
  public TransportType getAccountTransport(int n) {
    TransportType transport = null;
    LinphoneProxyConfig proxyConfig = getProxyConfig(n);

    if (proxyConfig != null) {
      LinphoneAddress proxyAddr;
      try {
        proxyAddr = LinphoneCoreFactory.instance().createLinphoneAddress(proxyConfig.getProxy());
        transport = proxyAddr.getTransport();
      } catch (LinphoneCoreException e) {
        e.printStackTrace();
      }
    }

    return transport;
  }
예제 #10
0
    @Override
    protected void onPostExecute(byte[] result) {
      if (progressDialog != null && progressDialog.isShowing()) {
        progressDialog.dismiss();
      }

      mUploadingImageStream = new ByteArrayInputStream(result);

      LinphoneContent content =
          LinphoneCoreFactory.instance().createLinphoneContent("image", "jpeg", result, null);
      String fileName = path.substring(path.lastIndexOf("/") + 1);
      content.setName(fileName);

      LinphoneChatMessage message = chatRoom.createFileTransferMessage(content);
      message.setListener(ChatFragment.this);
      message.setAppData(path);

      chatRoom.sendChatMessage(message);
      currentMessageInFileTransferUploadState = message;
    }
  public void setAccountTransport(int n, String transport) {
    LinphoneProxyConfig proxyConfig = getProxyConfig(n);

    if (proxyConfig != null && transport != null) {
      LinphoneAddress proxyAddr;
      try {
        proxyAddr = LinphoneCoreFactory.instance().createLinphoneAddress(proxyConfig.getProxy());
        int port = 0;
        if (transport.equals(getString(R.string.pref_transport_udp_key))) {
          proxyAddr.setTransport(TransportType.LinphoneTransportUdp);
        } else if (transport.equals(getString(R.string.pref_transport_tcp_key))) {
          proxyAddr.setTransport(TransportType.LinphoneTransportTcp);
        } else if (transport.equals(getString(R.string.pref_transport_tls_key))) {
          proxyAddr.setTransport(TransportType.LinphoneTransportTls);
          port = 5223;
        }

        /* 3G mobile firewall might block random TLS port, so we force use of 5223.
         * However we must NOT use this port when changing to TCP/UDP because otherwise
         * REGISTER (and everything actually) will fail...
         * */
        if ("sip.linphone.org".equals(proxyConfig.getDomain())) {
          proxyAddr.setPort(port);
        }

        LinphoneProxyConfig prxCfg = getProxyConfig(n);
        prxCfg.edit();
        prxCfg.setProxy(proxyAddr.asStringUriOnly());
        prxCfg.done();

        if (isAccountOutboundProxySet(n)) {
          setAccountOutboundProxyEnabled(n, true);
        }
      } catch (LinphoneCoreException e) {
        e.printStackTrace();
      }
    }
  }
  // Added by me
  public void createGroupChat(String groupName, String[] groupMembers, int groupSize) {
    // Intent intent = new Intent(this, ChatActivity.class);
    // intent.putExtra("GroupName", groupName);
    // intent.putExtra("GroupMembers", groupMembers);
    // intent.putExtra("GroupSize", groupSize);
    // intent.putExtra("ChatType", 1);

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      LinphoneChatRoom chatRoom = null;
      chatRoom = lc.getOrCreateGroupChatRoom(groupName, groupMembers, groupSize, 0, 0);

      if (chatRoom != null) {
        LinphoneAddress la = chatRoom.getPeerAddress();

        String sipUri = la.asStringUriOnly();
        String displayName = la.getDisplayName();
        String addrStr = la.asString();

        // intent.putExtra("SipUri", sipUri);
        // intent.putExtra("DisplayName", displayName);

        LinphoneProxyConfig pc = lc.getDefaultProxyConfig();
        String identity = pc.getIdentity();

        String id = "";
        try {
          la = LinphoneCoreFactory.instance().createLinphoneAddress(identity);
          id = la.getUserName();
        } catch (LinphoneCoreException e) {
          Log.e("Cannot display chat", e);
          // return;
        }

        String message = id + " created group " + groupName;
        LinphoneChatMessage msg = chatRoom.createLinphoneGroupChatMessage(message);
        chatRoom.sendGroupChatMessage(msg);
        // chatRoom.sendGroupMessage(message);

        onMessageSent(sipUri, message);

        goToChatList();

        /*String toDisplay = "Display Name: " + displayName;
        toDisplay += "\nSIP URI: " + sipUri;
        toDisplay += "\nGroup Name: " + chatRoom.getGroupName();
        toDisplay += "\nGroup Address: " + addrStr;
        displayCustomToast(toDisplay, Toast.LENGTH_SHORT);*/
      }

      // LinphoneProxyConfig pc = lc.getDefaultProxyConfig();
      // String identity = pc.getIdentity();
      // displayCustomToast("I am: " + identity, Toast.LENGTH_SHORT);
    }

    /*startOrientationSensor();
    startActivityForResult(intent, CHAT_ACTIVITY);

    LinphoneService.instance().resetMessageNotifCount();
    LinphoneService.instance().removeMessageNotification();
    displayMissedChats(getChatStorage().getUnreadMessageCount());*/
  }
  public void displayChat(String sipUri) {
    if (getResources().getBoolean(R.bool.disable_chat)) {
      return;
    }

    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
      Log.e("Cannot display chat", e);
      return;
    }
    Contact contact =
        ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
    String displayName = contact != null ? contact.getName() : null;

    String pictureUri = null;
    String thumbnailUri = null;
    if (contact != null && contact.getPhotoUri() != null) {
      pictureUri = contact.getPhotoUri().toString();
      thumbnailUri = contact.getThumbnailUri().toString();
    }

    if (isTablet()) {
      if (currentFragment == FragmentsAvailable.CHATLIST
          || currentFragment == FragmentsAvailable.CHAT) {
        Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
        if (fragment2 != null
            && fragment2.isVisible()
            && currentFragment == FragmentsAvailable.CHAT) {
          ChatFragment chatFragment = (ChatFragment) fragment2;
          chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
        } else {
          Bundle extras = new Bundle();
          extras.putString("SipUri", sipUri);
          if (contact != null) {
            extras.putString("DisplayName", displayName);
            extras.putString("PictureUri", pictureUri);
            extras.putString("ThumbnailUri", thumbnailUri);
          }
          changeCurrentFragment(FragmentsAvailable.CHAT, extras);
        }
      } else {
        changeCurrentFragment(FragmentsAvailable.CHATLIST, null);
        displayChat(sipUri);
      }
      if (messageListFragment != null && messageListFragment.isVisible()) {
        ((ChatListFragment) messageListFragment).refresh();
      }
    } else {
      Intent intent = new Intent(this, ChatActivity.class);
      intent.putExtra("SipUri", sipUri);
      if (contact != null) {
        intent.putExtra("DisplayName", contact.getName());
        intent.putExtra("PictureUri", pictureUri);
        intent.putExtra("ThumbnailUri", thumbnailUri);
      }
      startOrientationSensor();
      startActivityForResult(intent, CHAT_ACTIVITY);
    }

    LinphoneService.instance().resetMessageNotifCount();
    LinphoneService.instance().removeMessageNotification();
    displayMissedChats(getChatStorage().getUnreadMessageCount());
  }
    /**
     * 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);
    }
예제 #15
0
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = null;

      if (convertView != null) {
        view = convertView;
      } else {
        view = mInflater.inflate(R.layout.chatlist_cell, parent, false);
      }
      String contact;
      boolean isDraft = false;
      if (position >= mDrafts.size()) {
        contact = mConversations.get(position - mDrafts.size());
      } else {
        contact = mDrafts.get(position);
        isDraft = true;
      }
      view.setTag(contact);
      int unreadMessagesCount =
          LinphoneActivity.instance().getChatStorage().getUnreadMessageCount(contact);

      LinphoneAddress address;
      try {
        address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
      } catch (LinphoneCoreException e) {
        Log.e("Chat view cannot parse address", e);
        return view;
      }
      LinphoneUtils.findUriPictureOfContactAndSetDisplayName(
          address, view.getContext().getContentResolver());

      String message = "";
      if (useNativeAPI) {
        LinphoneChatRoom chatRoom = LinphoneManager.getLc().getOrCreateChatRoom(contact);
        LinphoneChatMessage[] history = chatRoom.getHistory(20);
        if (history != null && history.length > 0) {
          for (int i = history.length - 1; i >= 0; i--) {
            LinphoneChatMessage msg = history[i];
            if (msg.getText() != null && msg.getText().length() > 0) {
              message = msg.getText();
              break;
            }
          }
        }
      } else {
        List<ChatMessage> messages = LinphoneActivity.instance().getChatMessages(contact);
        if (messages != null && messages.size() > 0) {
          int iterator = messages.size() - 1;
          ChatMessage lastMessage = null;

          while (iterator >= 0) {
            lastMessage = messages.get(iterator);
            if (lastMessage.getMessage() == null) {
              iterator--;
            } else {
              iterator = -1;
            }
          }
          message =
              (lastMessage == null || lastMessage.getMessage() == null)
                  ? ""
                  : lastMessage.getMessage();
        }
      }
      TextView lastMessageView = (TextView) view.findViewById(R.id.lastMessage);
      lastMessageView.setText(message);

      TextView sipUri = (TextView) view.findViewById(R.id.sipUri);
      sipUri.setSelected(true); // For animation

      if (getResources().getBoolean(R.bool.only_display_username_if_unknown)
          && address.getDisplayName() != null
          && LinphoneUtils.isSipAddress(address.getDisplayName())) {
        address.setDisplayName(LinphoneUtils.getUsernameFromAddress(address.getDisplayName()));
      } else if (getResources().getBoolean(R.bool.only_display_username_if_unknown)
          && LinphoneUtils.isSipAddress(contact)) {
        contact = LinphoneUtils.getUsernameFromAddress(contact);
      }

      sipUri.setText(address.getDisplayName() == null ? contact : address.getDisplayName());
      if (isDraft) {
        view.findViewById(R.id.draft).setVisibility(View.VISIBLE);
      }

      ImageView delete = (ImageView) view.findViewById(R.id.delete);
      TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages);

      if (unreadMessagesCount > 0) {
        unreadMessages.setVisibility(View.VISIBLE);
        unreadMessages.setText(String.valueOf(unreadMessagesCount));
      } else {
        unreadMessages.setVisibility(View.GONE);
      }

      if (isEditMode) {
        delete.setVisibility(View.VISIBLE);
      } else {
        delete.setVisibility(View.INVISIBLE);
      }

      return view;
    }
예제 #16
0
  @Override
  protected void runTest() throws Throwable {
    // multicast begin
    mCore.enableAudioMulticast(true);
    Assert.assertEquals(true, mCore.audioMulticastEnabled());
    mCore.enableAudioMulticast(false);
    Assert.assertEquals(false, mCore.audioMulticastEnabled());

    mCore.enableVideoMulticast(true);
    Assert.assertEquals(true, mCore.videoMulticastEnabled());
    mCore.enableVideoMulticast(false);
    Assert.assertEquals(false, mCore.videoMulticastEnabled());

    LinphoneCallParams params = mCore.createCallParams(null);
    params.enableAudioMulticast(true);
    Assert.assertEquals(true, params.audioMulticastEnabled());
    params.enableAudioMulticast(false);
    Assert.assertEquals(false, params.audioMulticastEnabled());

    params.enableVideoMulticast(true);
    Assert.assertEquals(true, params.videoMulticastEnabled());
    params.enableVideoMulticast(false);
    Assert.assertEquals(false, params.videoMulticastEnabled());

    String ip = "224.3.2.1";
    mCore.setAudioMulticastAddr(ip);
    Assert.assertEquals(ip, mCore.getAudioMulticastAddr());

    ip = "224.3.2.3";
    mCore.setVideoMulticastAddr(ip);
    Assert.assertEquals(ip, mCore.getVideoMulticastAddr());

    mCore.setAudioMulticastTtl(3);
    Assert.assertEquals(3, mCore.getAudioMulticastTtl());

    mCore.setVideoMulticastTtl(4);
    Assert.assertEquals(4, mCore.getVideoMulticastTtl());
    // multicast end

    // Test setPrimaryContact
    String address = "Linphone Android <sip:linphone.android@unknown-host>";
    mCore.setPrimaryContact(address);
    Assert.assertEquals(
        LinphoneCoreFactory.instance().createLinphoneAddress(address).getDisplayName(),
        LinphoneCoreFactory.instance()
            .createLinphoneAddress(mCore.getPrimaryContact())
            .getDisplayName());
    Assert.assertEquals(
        LinphoneCoreFactory.instance().createLinphoneAddress(address).getUserName(),
        LinphoneCoreFactory.instance()
            .createLinphoneAddress(mCore.getPrimaryContact())
            .getUserName());

    // Test setPayloadTypeNumber
    mCore.setPayloadTypeNumber(mCore.findPayloadType("PCMU"), 12);
    Assert.assertEquals(mCore.getPayloadTypeNumber(mCore.findPayloadType("PCMU")), 12);

    PayloadType[] audioCodecs = mCore.getAudioCodecs();
    int audioCodecsNb = audioCodecs.length;
    if (audioCodecsNb >= 1) {
      PayloadType[] newAudioCodecs = new PayloadType[audioCodecsNb - 1];
      System.arraycopy(audioCodecs, 1, newAudioCodecs, 0, audioCodecsNb - 1);
      mCore.setAudioCodecs(newAudioCodecs);
      audioCodecs = mCore.getAudioCodecs();
      Assert.assertEquals(audioCodecs.length, audioCodecsNb - 1);
    }

    // Test LinphoneFriend ref key
    String key = "12";
    LinphoneFriend friend =
        LinphoneCoreFactory.instance().createLinphoneFriend("sip:[email protected]");
    friend.setRefKey(key);
    Assert.assertEquals(friend.getRefKey(), key);

    MediastreamerAndroidContext.enableFilterFromName("MSUlawEnc", false);
    Assert.assertFalse(MediastreamerAndroidContext.filterFromNameEnabled("MSUlawEnc"));
    MediastreamerAndroidContext.enableFilterFromName("MSUlawEnc", true);
  }
예제 #17
0
 @Override
 protected void setUp() throws Exception {
   // TODO Auto-generated method stub
   super.setUp();
   mCore = LinphoneCoreFactory.instance().createLinphoneCore(new LinphoneCoreListenerBase(), null);
 }
 // Advanced settings
 public void setDebugEnabled(boolean enabled) {
   getConfig().setBool("app", "debug", enabled);
   LinphoneCoreFactory.instance().enableLogCollection(enabled);
   LinphoneCoreFactory.instance().setDebugMode(enabled, getString(R.string.app_name));
 }
예제 #19
0
  public void saveCreatedAccount(String username, String password, String domain) {
    if (accountCreated) return;

    String identity = "sip:" + username + "@" + domain;
    try {
      address = LinphoneCoreFactory.instance().createLinphoneAddress(identity);
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }

    boolean isMainAccountLinphoneDotOrg =
        !getResources().getBoolean(R.bool.use_register_verify_user_webservice);
    boolean useLinphoneDotOrgCustomPorts =
        getResources().getBoolean(R.bool.use_linphone_server_ports);
    AccountBuilder builder =
        new AccountBuilder(LinphoneManager.getLc())
            .setUsername(username)
            .setDomain(domain)
            .setPassword(password);

    if (isMainAccountLinphoneDotOrg && useLinphoneDotOrgCustomPorts) {
      if (getResources().getBoolean(R.bool.disable_all_security_features_for_markets)) {
        builder.setProxy(domain + ":5228").setTransport(TransportType.LinphoneTransportTcp);
      } else {
        builder.setProxy(domain + ":5223").setTransport(TransportType.LinphoneTransportTls);
      }

      builder
          .setExpires("604800")
          .setOutboundProxyEnabled(true)
          .setAvpfEnabled(true)
          .setAvpfRRInterval(3)
          .setQualityReportingCollector("sip:[email protected]")
          .setQualityReportingEnabled(true)
          .setQualityReportingInterval(180)
          .setRealm("sip.linphone.org");

      mPrefs.setStunServer(getString(R.string.default_stun));
      mPrefs.setIceEnabled(true);
    } else {
      String forcedProxy = getResources().getString(R.string.setup_forced_proxy);
      if (!TextUtils.isEmpty(forcedProxy)) {
        builder.setProxy(forcedProxy).setOutboundProxyEnabled(true).setAvpfRRInterval(5);
      }
    }

    if (getResources().getBoolean(R.bool.enable_push_id)) {
      String regId = mPrefs.getPushNotificationRegistrationID();
      String appId = getString(R.string.push_sender_id);
      if (regId != null && mPrefs.isPushNotificationEnabled()) {
        String contactInfos = "app-id=" + appId + ";pn-type=google;pn-tok=" + regId;
        builder.setContactParameters(contactInfos);
      }
    }

    try {
      builder.saveNewAccount();
      accountCreated = true;
    } catch (LinphoneCoreException e) {
      e.printStackTrace();
    }
  }