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

📄 loginaction.cs

📁 破解的飞信源代码
💻 CS
字号:
namespace Imps.Client.Core
{
    using Imps.Client;
    using Imps.Client.Core.Login;
    using Imps.Common;
    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.IO;
    using System.Net;
    using System.Text;
    using System.Xml;

    public abstract class LoginAction : IDisposable, IComparable<LoginAction>
    {
        private static readonly ReadOnlyCollection<Imps.Client.Core.LoginStage> _postActionPriorityList = CreatePostActionPriorityList();
        private Imps.Client.Core.User _user;
        private const int DEFAULT_TIMEOUT = 0x15f90;
        private ILoginListner listener;
        private const int MAX_GROUP_COUNT = 0x10;
        protected const int SipcTransActionTimeout = 90;
        protected const int SubscribeTimeOut = 0x2bf20;
        protected int tryTimes = 2;

        public LoginAction(Imps.Client.Core.User user, ILoginListner listener)
        {
            if (user == null)
            {
                throw new ArgumentNullException("user should not be null reference!");
            }
            this._user = user;
            this.listener = listener;
        }

        public abstract void Cancel();
        public abstract void Clear();
        protected void ClearUri()
        {
            try
            {
                if (UserAccounts.EraseMappedSid(this.User.MobileNo))
                {
                    UserAccounts.SaveToLocal();
                }
                this.User.Uri = new IicUri(string.Empty);
                this.User.Sid = 0;
            }
            catch (Exception exception)
            {
                this.NotifyException(string.Empty, exception);
            }
        }

        public int CompareTo(LoginAction other)
        {
            return (_postActionPriorityList.IndexOf(this.LoginStage) - _postActionPriorityList.IndexOf(other.LoginStage));
        }

        private static ReadOnlyCollection<Imps.Client.Core.LoginStage> CreatePostActionPriorityList()
        {
            List<Imps.Client.Core.LoginStage> list = new List<Imps.Client.Core.LoginStage>();
            list.Add(Imps.Client.Core.LoginStage.GetContactsList);
            list.Add(Imps.Client.Core.LoginStage.GetPermission);
            list.Add(Imps.Client.Core.LoginStage.SubscribePresence);
            list.Add(Imps.Client.Core.LoginStage.RetrivePersonalInfo);
            list.Add(Imps.Client.Core.LoginStage.GetContactsInfo);
            list.Add(Imps.Client.Core.LoginStage.GetOfflineMessage);
            list.Add(Imps.Client.Core.LoginStage.RetriveSystemConfig);
            list.Add(Imps.Client.Core.LoginStage.RetriveUri);
            list.Add(Imps.Client.Core.LoginStage.DownloadPortrait);
            list.Add(Imps.Client.Core.LoginStage.GetMobilEmailInfo);
            list.Add(Imps.Client.Core.LoginStage.GetScore);
            return list.AsReadOnly();
        }

        public abstract void Dispose();
        public abstract bool Execute();
        protected MainPresence GetCurrentLoginPresence()
        {
            MainPresence initPresence = this.User.InitPresence;
            if ((this.User._lastPresence != null) && this.User._lastPresence.IsForCurrentUser(this.User))
            {
                initPresence = this.User._lastPresence._presence;
            }
            return initPresence;
        }

        protected static XmlDocument GetResponseDOM(HttpWebResponse response)
        {
            try
            {
                string xml;
                using (Stream stream = response.GetResponseStream())
                {
                    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                    {
                        xml = reader.ReadToEnd();
                    }
                }
                XmlDocument document = new XmlDocument();
                document.LoadXml(xml);
                return document;
            }
            catch
            {
                return null;
            }
        }

        protected static string GetResultCode(XmlDocument xmlDocument)
        {
            if (xmlDocument != null)
            {
                XmlNode node = xmlDocument.SelectSingleNode("results/@status-code");
                if (node != null)
                {
                    return node.Value;
                }
            }
            return string.Empty;
        }

        protected void NotifyException(string message, Exception ex)
        {
            try
            {
                if (this.listener != null)
                {
                    this.listener.NotifyException(this.LoginStage, message, ex);
                }
            }
            catch
            {
            }
        }

        protected void NotifyLoginFailed(string message, LoginException ex)
        {
            try
            {
                if (this.User.Status == UserAccountStatus.Loginning)
                {
                    if (this.listener != null)
                    {
                        this.listener.NotifyLoginFailed(this.LoginStage, message, ex);
                    }
                }
                else
                {
                    this.NotifyException(message, ex);
                }
            }
            catch
            {
            }
        }

        protected void NotifyLoginFailed(string message, ExceptionType type, Exception ex)
        {
            LoginException exception = new LoginException(message, ex);
            exception.Stage = this.LoginStage;
            exception.ExType = type;
            this.NotifyLoginFailed(message, exception);
        }

        protected void NotifyMessage(string message)
        {
            try
            {
                if (this.listener != null)
                {
                    this.listener.NotifyMessage(this.LoginStage, message);
                }
            }
            catch
            {
            }
        }

        protected void NotifyWarning(string message, Exception ex)
        {
            try
            {
                if (this.listener != null)
                {
                    this.listener.NotifyWarning(this.LoginStage, message, ex);
                }
            }
            catch
            {
            }
        }

        public virtual bool PostLoginExecute()
        {
            return this.Execute();
        }

        public virtual void Retry(RetryResult result)
        {
            result.IsCompleted = true;
            result.IsSucceed = true;
        }

        protected void SaveUri()
        {
            PersistentDelegate save = null;
            if (this.User.Uri.IsValid)
            {
                if (save == null)
                {
                    save = delegate (XmlNode node) {
                        XmlNode parentNode = node.ParentNode;
                        if (parentNode != null)
                        {
                            if (parentNode.Attributes["uri"] != null)
                            {
                                parentNode.Attributes["uri"].Value = this.User.Uri.ToString();
                            }
                            else
                            {
                                XmlAttribute node = parentNode.OwnerDocument.CreateAttribute("uri");
                                attribute.Value = this.User.Uri.ToString();
                                parentNode.Attributes.SetNamedItem(attribute);
                            }
                        }
                        this.User.PersonalInfo.SaveToXmlNode(node);
                    };
                }
                this.User.PersistentManager.SaveUserInfo(save);
            }
            if (!string.IsNullOrEmpty(this.User.MobileNo) && UserAccounts.AddUpdateAccountMappingElement(this.User.MobileNo, this.User.Sid))
            {
                UserAccounts.SaveToLocal();
            }
        }

        public abstract bool LocalCacheHit { get; }

        public abstract Imps.Client.Core.LoginStage LoginStage { get; }

        public virtual int TimeOut
        {
            get
            {
                return 0x15f90;
            }
        }

        protected Imps.Client.Core.User User
        {
            get
            {
                return this._user;
            }
        }
    }
}

⌨️ 快捷键说明

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