📄 useraccounts.cs
字号:
{
_persistentMgr = mgr;
}
public static void TrySaveLastestAccount(bool success)
{
if (_lastestAccount != null)
{
AddUpdateAccountElement(_lastestAccount);
if (!success)
{
_lastestAccount.AutoLogin = false;
_lastestAccount.Password = string.Empty;
}
LatestId = _lastestAccount.Id;
SaveToLocal();
}
}
public static bool UpdateLatestAccountElement(string id)
{
XmlHelper.SetNodeAttribute(XmlNodeLatest, "id", id);
_modified = true;
return true;
}
public static bool AutoLoginEnabled
{
get
{
string id = LatestId;
if (id.Length > 0)
{
AccountData account = GetAccount(id);
if (account != null)
{
return (account.Password.Length > 0);
}
}
return false;
}
}
public static AccountData LastestAccount
{
get
{
return _lastestAccount;
}
set
{
_lastestAccount = value;
}
}
public static string LaststAccountNewPassword
{
set
{
string id = LatestId;
if (id.Length > 0)
{
AccountData ad = GetAccount(id);
if ((ad != null) && (ad.Password != value))
{
ad.Password = value;
AddUpdateAccountElement(ad);
}
}
}
}
public static bool LatestAccountAutoLogin
{
get
{
string id = LatestId;
if (id.Length > 0)
{
AccountData account = GetAccount(id);
if (account != null)
{
return account.AutoLogin;
}
}
return false;
}
set
{
string id = LatestId;
if (id.Length > 0)
{
AccountData ad = GetAccount(id);
if ((ad != null) && (ad.AutoLogin != value))
{
ad.AutoLogin = value;
AddUpdateAccountElement(ad);
}
}
}
}
public static string LatestId
{
get
{
long nbr;
string s = XmlHelper.ReadXmlAttributeString(XmlNodeLatest, "id");
if (ImpsHelper.TryParseSidOrCmccMobileNo(s, out nbr))
{
return s;
}
return string.Empty;
}
set
{
UpdateLatestAccountElement(value);
}
}
private static XmlNode XmlNodeAccounts
{
get
{
XmlNode xmlNodeRoot = XmlNodeRoot;
XmlNode node2 = xmlNodeRoot.SelectSingleNode("Accounts");
if (node2 == null)
{
node2 = XmlHelper.AppendChildElement(xmlNodeRoot, "Accounts");
}
return node2;
}
}
private static XmlNode XmlNodeLatest
{
get
{
XmlNode xmlNodeRoot = XmlNodeRoot;
XmlNode node2 = xmlNodeRoot.SelectSingleNode("LatestAccount");
if (node2 == null)
{
node2 = XmlHelper.AppendChildElement(xmlNodeRoot, "LatestAccount");
}
return node2;
}
}
private static XmlNode XmlNodeMappings
{
get
{
XmlNode xmlNodeRoot = XmlNodeRoot;
XmlNode node2 = xmlNodeRoot.SelectSingleNode("Mappings");
if (node2 == null)
{
node2 = XmlHelper.AppendChildElement(xmlNodeRoot, "Mappings");
}
return node2;
}
}
private static XmlNode XmlNodeRoot
{
get
{
if (_acccountsNode == null)
{
XmlDocument node = new XmlDocument();
_acccountsNode = XmlHelper.AppendChildElement(node, "AccountsData");
}
return _acccountsNode;
}
}
public class AccountData
{
private Imps.Client.Core.UserAccounts.AccountType _accountType;
private bool _autoLogin;
private readonly RandomEncryptor _encryptor;
private string _id;
private string _password;
private int _presence;
public AccountData(string id) : this(id, string.Empty, false)
{
}
public AccountData(string id, string pass, bool autoLogin) : this(id, pass, autoLogin, MainPresence.Online)
{
}
public AccountData(string id, string pass, bool autoLogin, MainPresence mp)
{
this._presence = 400;
this._accountType = Imps.Client.Core.UserAccounts.AccountType.Unknown;
this._encryptor = new RandomEncryptor();
this._id = id;
this.Password = pass;
this._autoLogin = autoLogin;
this._presence = (int) mp;
try
{
long mobileNo;
long.TryParse(id, ref mobileNo);
if (ImpsHelper.IsCmccMobileNo(mobileNo))
{
this._accountType = Imps.Client.Core.UserAccounts.AccountType.MobileNo;
}
else
{
this._accountType = Imps.Client.Core.UserAccounts.AccountType.SID;
}
}
catch
{
}
}
private string DecodePassword()
{
try
{
return this._encryptor.Decrypt(this._password);
}
catch
{
return this._password;
}
}
private void EncodePassword(string password)
{
try
{
this._password = this._encryptor.Encrypt(password);
}
catch
{
this._password = password;
}
}
public Imps.Client.Core.UserAccounts.AccountType AccountType
{
get
{
return this._accountType;
}
}
public bool AutoLogin
{
get
{
return this._autoLogin;
}
internal set
{
this._autoLogin = value;
}
}
public string Id
{
get
{
return this._id;
}
internal set
{
this._id = value;
}
}
public string Password
{
get
{
return this.DecodePassword();
}
internal set
{
this.EncodePassword(value);
}
}
public int PresenceValue
{
get
{
return this._presence;
}
internal set
{
this._presence = value;
}
}
}
public enum AccountType
{
SID,
MobileNo,
Unknown
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -