コード例 #1
0
  public int getDefaultAccountIndex() {
    LinphoneProxyConfig defaultPrxCfg = getLc().getDefaultProxyConfig();
    if (defaultPrxCfg == null) return -1;

    LinphoneProxyConfig[] prxCfgs = getLc().getProxyConfigList();
    for (int i = 0; i < prxCfgs.length; i++) {
      if (defaultPrxCfg.getIdentity().equals(prxCfgs[i].getIdentity())) {
        return i;
      }
    }
    return -1;
  }
コード例 #2
0
 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();
   }
 }
コード例 #3
0
  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;
  }
コード例 #4
0
  public void setAccountEnabled(int n, boolean enabled) {
    LinphoneProxyConfig prxCfg = getProxyConfig(n);
    prxCfg.edit();
    prxCfg.enableRegister(enabled);
    prxCfg.done();

    // If default proxy config is disabled, try to set another one as default proxy
    if (!enabled && getLc().getDefaultProxyConfig().getIdentity().equals(prxCfg.getIdentity())) {
      int count = getLc().getProxyConfigList().length;
      if (count > 1) {
        for (int i = 0; i < count; i++) {
          if (isAccountEnabled(i)) {
            getLc().setDefaultProxyConfig(getProxyConfig(i));
            break;
          }
        }
      }
    }
  }
コード例 #5
0
  // 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());*/
  }