Exemple #1
0
        internal static bool ParseSipAddressEx(string sipAddress, out string displayname, out string username,
                                               out string hostname, out int port)
        {
            displayname = string.Empty;
            username    = string.Empty;
            hostname    = string.Empty;
            port        = 0;

            bool bRetVal = false;

            int posStart = sipAddress.IndexOf("\"", StringComparison.InvariantCulture);

            if (posStart != -1)
            {
                int posEnd = posStart;
                int posTmp = posEnd;
                while ((posTmp = sipAddress.IndexOf("\"", posTmp + 1, StringComparison.InvariantCulture)) != -1)
                {
                    if (sipAddress[posTmp - 1] != '\\')
                    {
                        posEnd = posTmp;
                        break;
                    }
                }

                if (posStart < posEnd)
                {
                    int posFirst = sipAddress.IndexOf("<", posEnd + 1, StringComparison.InvariantCulture);
                    if (posFirst != -1)
                    {
                        int posLast = sipAddress.IndexOf(">", posFirst + 1, StringComparison.InvariantCulture);
                        if (posFirst + 1 < posLast)
                        {
                            displayname = sipAddress.Substring(posStart + 1, posEnd - posStart - 1);

                            string stripped = sipAddress.Substring(posFirst + 1, posLast - posFirst - 1);
                            bRetVal = VATRPCall.ParseSipAddress(stripped, out username, out hostname, out port);
                        }
                    }
                }
            }
            else
            {
                bRetVal = ParseSipAddress(sipAddress, out username, out hostname, out port);
            }

            return(bRetVal);
        }