⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialog.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
                    {
                        return participant;
                    }
                }
            }
            return null;
        }

        public ShareContent FindShareContentByID(string id)
        {
            using (IEnumerator<ShareContent> enumerator = this.ShareContents.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ShareContent content = enumerator.get_Current();
                    if (content.Id == id)
                    {
                        return content;
                    }
                }
            }
            return null;
        }

        public ShareContent FindShareContentByUrl(string url)
        {
            using (IEnumerator<ShareContent> enumerator = this.ShareContents.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    ShareContent content = enumerator.get_Current();
                    if (content.DownLoadUrl == url)
                    {
                        return content;
                    }
                }
            }
            return null;
        }

        private void GenerateaShareContentInfo(string md5, int size, string fileName, DownLoadShareContent download)
        {
            try
            {
                if ((download.OtherSideSharedContentOption != null) && (download.OtherSideSharedContentOption.SupportRelayV2 || download.OtherSideSharedContentOption.SupportP2PV2))
                {
                    Peer remotePeer = download.RemotePeer;
                    if (remotePeer == null)
                    {
                        remotePeer = new Peer(this.Participants[0].Contact.Uri.Sid);
                    }
                    using (TransportingFile file = new TransportingFile(string.Empty, (long) size, fileName, (long) 0, md5, remotePeer))
                    {
                        download.LastTimeCompleteSize = file.CompletedSize;
                        download.FilePath = file.LocalFilePath;
                        download.First100MMd5 = file.First100MMd5;
                    }
                }
            }
            catch (Exception)
            {
            }
        }

        private string GetInviteSDP()
        {
            string text = "";
            string text2 = "";
            if (base.Owner.SipConnection.LocalEndPoint != null)
            {
                text = base.Owner.SipConnection.LocalEndPoint.ToString();
                text2 = base.Owner.SipConnection.LocalEndPoint.Port.ToString();
            }
            StringBuilder builder = new StringBuilder();
            builder.AppendLine("v=0");
            builder.AppendLine("o=-0 0 IN " + text);
            builder.AppendLine("s=session");
            builder.AppendLine("c=IN IP4 " + text);
            builder.AppendLine("t=0 0");
            builder.AppendLine("m=message " + text2 + " sip " + base.Owner.Uri.Raw);
            return builder.ToString();
        }

        protected virtual Imps.Client.Core.Contact GetMessageContact(SipRequest req)
        {
            string uri = this.To;
            if (req.Message.SourceHeader != null)
            {
                uri = req.Message.SourceHeader.RawValue;
            }
            return base.Owner.ContactList.FindOrCreateContact(uri, this.BizOperation);
        }

        private Message GetReceiveMsg(SipRequest req, Imps.Client.Core.Contact contact)
        {
            string source = req.Message.Body;
            if ((req.Message.ContentType == null) || (req.Message.ContentType.Value != "text/html-fragment"))
            {
                if (contact.Type == ContactType.Vodafone)
                {
                    source = source.Replace(":>", ":D").Replace(":->", ":D");
                }
                if ((req.Message.ContentType == null) && (contact.Presence.ClientTypeType == ClientType.PC))
                {
                    source = Imps.Utils.TagParser.TagParser.Create(source, true).Text;
                }
                source = StringHelper.EncodString(source);
            }
            Message message = new IMMessage(this, source, contact.DisplayName, contact.Uri.Raw, true);
            message.FromSid = contact.Uri.Sid.ToString();
            if (req.Message.DateHeader != null)
            {
                DateTime now = DateTime.Now;
                try
                {
                    if (DateTime.TryParse(req.Message.DateHeader.Value, ref now))
                    {
                        message.Time = now;
                    }
                }
                catch
                {
                }
            }
            if (req.Message.MessageIDHeader != null)
            {
                message.MessageId = req.Message.MessageIDHeader.Value;
            }
            return message;
        }

        internal Message GetSendMessage(string content)
        {
            Message message = new IMMessage(this, content, this.MyDisplayName, base.Owner.Uri.Raw, false);
            message.FromSid = base.Owner.Uri.Sid.ToString();
            return message;
        }

        internal void InnerAddParticipants(params Imps.Client.Core.Contact[] contacts)
        {
            foreach (Imps.Client.Core.Contact contact in contacts)
            {
                this.Participants.Add(new ConversationParticipant(contact, this));
            }
        }

        internal SipRequest InnerCreateSipRequest(string method, long callId, int cSeq)
        {
            SipcRequest sipcRequest = new SipcRequest(method, base.Owner.Domain);
            sipcRequest.AddHeader(new SipcFromHeader(base.Owner.Sid.ToString()));
            sipcRequest.AddHeader(new SipcCallIdHeader(callId));
            sipcRequest.AddHeader(new SipcCSeqHeader(cSeq, method));
            return new SipRequest(sipcRequest);
        }

        private void InnerSendIm(Message msg)
        {
            if (this.Status != DialogStatus.Inviting)
            {
                this.AsyncSendMessage(msg);
            }
            else
            {
                if (this._temporaryMessages == null)
                {
                    this._temporaryMessages = new List<Message>();
                }
                this._temporaryMessages.Add(msg);
            }
        }

        private void invite_req_FinalResponseReceived(object sender, SipResponseReceivedEventArgs e)
        {
            SipResponse response = e.Response;
            switch (response.Message.StatusCode)
            {
                case 0x193:
                    this.Status = DialogStatus.None;
                    this.BizOperation.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.Conversation.MsgAcceptContactNotFound));
                    return;

                case 480:
                    this.Status = DialogStatus.None;
                    return;

                case 0x1f8:
                    this.Status = DialogStatus.None;
                    return;

                case 100:
                    break;

                case 200:
                {
                    foreach (SipcHeader header in response.Message.GetHeaders("K"))
                    {
                        if (header.Value == "text/html-fragment")
                        {
                            this.ContentType = MessageContentType.HtmlFragment;
                        }
                        else if (header.Value == "multiparty")
                        {
                            this.AllowMultiparty = true;
                        }
                        else if (header.Value == "nudge")
                        {
                            this.OtherSupportNudge = true;
                        }
                    }
                    SipAckRequest msg = new SipAckRequest(e.Response as SipInviteResponse, base.Owner.Domain);
                    msg.Message.AddHeader(new SipcToHeader(this.To));
                    msg.Message.AddHeader(new SipcFromHeader(base.Owner.Sid.ToString()));
                    base.SendSipMessage(msg);
                    this.Status = DialogStatus.Invited;
                    return;
                }
                default:
                    this.Status = DialogStatus.None;
                    break;
            }
        }

        private void Owner_SipNotifyReceived(object sender, SipRequestReceivedEventArgs e)
        {
            string text;
            if (((((e.Request.Message.CallId.CallId == this.CallId) && (((e.Request.Message.From == null) || (e.Request.Message.From.Value == this.To)) || (e.Request.Message.From.Value == base.Owner.Uri.Raw))) && (((e.Request.Message.To == null) || (e.Request.Message.To.Value == this.To)) || (e.Request.Message.To.Value == base.Owner.Uri.Raw))) && ((e.Request.Message.Event != null) && ((text = e.Request.Message.Event.Value.ToLower()) != null))) && (text == "group"))
            {
                this.DoReceiveTempGroupNotify(e.Request);
            }
        }

        private void Owner_SipRequestReceived(object sender, SipRequestReceivedEventArgs e)
        {
            try
            {
                if (((e.Request.Message.CallId.CallId == this.CallId) && (((e.Request.Message.From == null) || (e.Request.Message.From.Value == this.To)) || (e.Request.Message.From.Value == base.Owner.Uri.Raw))) && (((e.Request.Message.To == null) || (e.Request.Message.To.Value == this.To)) || (e.Request.Message.To.Value == base.Owner.Uri.Raw)))
                {
                    this.DoReceiveMessageRequest(e.Request);
                }
            }
            catch (Exception exception)
            {
                LogHelper.LogException(exception);
            }
        }

        internal ShareContent.OtherSideOption ParserEndPoints(string body)
        {
            try
            {
                XmlDocument document = new XmlDocument();
                document.LoadXml(body);
                XmlNode documentElement = document.DocumentElement;
                XmlNode node2 = documentElement.SelectSingleNode("caps");
                XmlNode node = documentElement.SelectSingleNode("client");
                ShareContent.OtherSideOption option = new ShareContent.OtherSideOption();
                if (documentElement.Attributes["id"] != null)
                {
                    option.Id = documentElement.Attributes["id"].Value;
                }
                if (node2 != null)
                {
                    option.Modes = node2.Attributes["modes"].Value;
                    try
                    {
                        option.MaxSize = new int?(int.Parse(node2.Attributes["max-size"].Value) * 0x400);
                    }
                    catch (OverflowException)
                    {
                        option.MaxSize = 0x7fffffff;
                    }
                }
                if (node != null)
                {
                    string text = XmlHelper.ReadXmlAttributeString(node, "outer-ip");
                    string text2 = XmlHelper.ReadXmlAttributeString(node, "inner-ip");
                    option.Port = XmlHelper.ReadXmlAttributeString(node, "port");
                    AllEndPoints points = new AllEndPoints();
                    if (text.IndexOf(":") > -1)
                    {
                        points.OuterEndPoint = new IPEndPoint(IPAddress.Parse(text.Split(new char[] { ':' })[0]), Convert.ToInt32(text.Split(new char[] { ':' })[1]));
                    }
                    if (text2.IndexOf(";") > -1)
                    {
                        string[] textArray = text2.Split(new char[] { ';' });
                        points.InnerEndPoints = new List<IPEndPoint>();
                        foreach (string text3 in textArray)
                        {
                            if (!string.IsNullOrEmpty(text3.Trim()) && (text3.IndexOf(":") > -1))
                            {
                                points.InnerEndPoints.Add(new IPEndPoint(IPAddress.Parse(text3.Split(new char[] { ':' })[0]), Convert.ToInt32(text3.Split(new char[] { ':' })[1])));
                            }
                        }
                    }
                    option.EndPorints = points;
                }
                return option;
            }
            catch (Exception exception)
            {
                ClientLogger.WriteException(exception);
                return null;
            }
        }

        private static void ProcessTcpOption(ShareContent.OtherSideOption option, P2PSessionFinder finder)
        {
            int port;
            if ((int.TryParse(option.Port, ref port) && (port > 0)) && (option.EndPorints != null))
            {
                if (option.EndPorints.InnerEndPoi

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -