// very dirty public static String GetValidPhoneNumber(String uri) { if (uri != null && (uri.StartsWith("sip:") || uri.StartsWith("sip:") || uri.StartsWith("tel:"))) { SipUri sipUri = new SipUri(uri); #if WINDOWS_PHONE if (sipUri.isValid_()) #else if (sipUri.isValid()) #endif { String userName = sipUri.getUserName(); if (userName != null) { try { String scheme = sipUri.getScheme(); if (scheme != null && scheme.Equals("tel")) { userName = userName.Replace("-", ""); } long result = Convert.ToInt64(userName.StartsWith("+") ? userName.Substring(1) : userName); if (result < UriUtils.MAX_PHONE_NUMBER) { return(userName); } } catch (FormatException) { } catch (Exception e) { LOG.Error(e); } } } sipUri.Dispose(); } else { try { uri = uri.Replace("-", ""); long result = Convert.ToInt64(uri.StartsWith("+") ? uri.Substring(1) : uri); if (result < UriUtils.MAX_PHONE_NUMBER) { return(uri); } } catch (FormatException) { } catch (Exception e) { LOG.Error(e); } } return(null); }
public static String GetUserName(String uri) { String userName = null; if (!String.IsNullOrEmpty(uri)) { SipUri sipUri = new SipUri(uri); #if WINDOWS_PHONE if (sipUri.isValid_()) #else if (sipUri.isValid()) #endif { userName = sipUri.getUserName(); } sipUri.Dispose(); } return(userName == null ? uri : userName); }
// very dirty public static String GetValidPhoneNumber(String uri) { if (uri != null && (uri.StartsWith("sip:") || uri.StartsWith("sip:") || uri.StartsWith("tel:"))) { SipUri sipUri = new SipUri(uri); #if WINDOWS_PHONE if (sipUri.isValid_()) #else if (sipUri.isValid()) #endif { String userName = sipUri.getUserName(); if (userName != null) { try { String scheme = sipUri.getScheme(); if (scheme != null && scheme.Equals("tel")) { userName = userName.Replace("-", ""); } long result = Convert.ToInt64(userName.StartsWith("+") ? userName.Substring(1) : userName); if (result < UriUtils.MAX_PHONE_NUMBER) { return userName; } } catch (FormatException ) { } catch (Exception e) { LOG.Error(e); } } } sipUri.Dispose(); } else { try { uri = uri.Replace("-", ""); long result = Convert.ToInt64(uri.StartsWith("+") ? uri.Substring(1) : uri); if (result < UriUtils.MAX_PHONE_NUMBER) { return uri; } } catch (FormatException ) { } catch (Exception e) { LOG.Error(e); } } return null; }
public static String GetUserName(String uri) { String userName = null; if (!String.IsNullOrEmpty(uri)) { SipUri sipUri = new SipUri(uri); #if WINDOWS_PHONE if (sipUri.isValid_()) #else if (sipUri.isValid()) #endif { userName = sipUri.getUserName(); } sipUri.Dispose(); } return (userName == null ? uri : userName); }