CString FormatNumber(CString number) { CString numberFormated = number; pjsua_acc_id acc_id; pj_str_t pj_uri; bool isLocal = SelectSIPAccount(number,acc_id,pj_uri) && acc_id == account_local; if (!isLocal) { BOOL isDigits = TRUE; for (int i=0;i<number.GetLength();i++) { if ( (number[i]>'9' || number[i]<'0') && number[i]!='*' && number[i]!='#' && number[i]!='.' && number[i]!='-' && number[i]!='(' && number[i]!=')' && number[i]!=' ' && number[0]!='+') { isDigits = FALSE; break; } } if (isDigits) { numberFormated.Remove('.'); numberFormated.Remove('-'); numberFormated.Remove('('); numberFormated.Remove(')'); numberFormated.Remove(' '); } } return GetSIPURI(numberFormated,true,isLocal); }
void Transfer::OnBnClickedOk() { MessagesContact* messagesContactSelected = microsipDlg->messagesDlg->GetMessageContact(); if (messagesContactSelected->callId!=-1) { CString number; GetDlgItem(IDC_NUMBER)->GetWindowText(number); number.Trim(); if (!number.IsEmpty()) { pj_str_t pj_uri = StrToPjStr ( GetSIPURI(number, true) ); pjsua_call_xfer(messagesContactSelected->callId, &pj_uri, NULL); OnClose(); } } }
bool SelectSIPAccount(CString number, pjsua_acc_id &acc_id, pj_str_t &pj_uri) { SIPURI sipuri; ParseSIPURI(number, &sipuri); if (pjsua_acc_is_valid(account) && pjsua_acc_is_valid(account_local)) { acc_id = account; if (accountSettings.account.domain != sipuri.domain) { int pos = sipuri.domain.Find(_T(":")); CString domainWithoutPort = RemovePort(sipuri.domain); if (domainWithoutPort.CompareNoCase(_T("localhost"))==0 || IsIP(domainWithoutPort)) { acc_id = account_local; } } } else if (pjsua_acc_is_valid(account)) { acc_id = account; } else if (pjsua_acc_is_valid(account_local)) { acc_id = account_local; } else { return false; } pj_uri = StrToPjStr ( GetSIPURI(number, acc_id == account_local, acc_id == account_local) ); return true; }