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

📄 contactlist.cs

📁 破解的飞信源代码
💻 CS
📖 第 1 页 / 共 5 页
字号:
namespace Imps.Client.Core
{
    using Imps.Base.Sipc;
    using Imps.Client;
    using Imps.Client.Base;
    using Imps.Client.Core.Login;
    using Imps.Client.Resource;
    using Imps.Client.Utils;
    using Imps.Common;
    using Imps.Utils;
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Threading;
    using System.Xml;

    public class ContactList : UserItemBase, ISuspendable
    {
        private ContactCollection _buddies;
        private bool _canReGetContactList;
        private ContactCollection _chatFriends;
        private List<ContactChangedEventArgs> _contactChangedEventArgsCol;
        private ContactCollection _contacts;
        private int _contactsCountFromLocal;
        private int _expiredSeconds;
        private ContactGroupCollection _groups;
        private bool? _hasLoadLocalStroage;
        private ContactCollection _mobileBuddies;
        private ContactCollection _newContactsAddByMobileNo;
        private List<IicUri> _penddingAddBuddyRequestUri;
        private List<Imps.Client.Core.Contact> _recentBuddies;
        private ContactCollection _strangers;
        private long _subCallId;
        private int _subCSeq;
        private int _suspendCount;
        private string _version;
        private const int GETCONTACTSINFO_COUNT = 20;
        private const int RECENTBUDDIES_MAXCOUNT = 3;
        private const int SUBCOUNT = 100;

        public event EventHandler<AddBuddyApplicationEventArgs> AddBuddyRequest;

        public event EventHandler<AddBuddyResultEventArgs> AddBuddyResult;

        public event EventHandler AddMobileBuddyReply;

        public event EventHandler<ContactListEventArgs> Changed;

        public event EventHandler<ContactGroupChangedEventArgs> ContactGroupChanged;

        public event EventHandler<ContactsChangedEventArgs> ContactsChanged;

        public event EventHandler<ContactTypeChangedEventArgs> ContactTypeChanged;

        public event EventHandler SmsInviteSucceeded;

        public ContactList(Imps.Client.Core.User owner) : base(owner)
        {
            this._canReGetContactList = true;
            this._version = string.Empty;
            this._subCallId = -1;
            this._subCSeq = -1;
            this._groups = new ContactGroupCollection(this);
            this._buddies = new ContactCollection(this);
            this._mobileBuddies = new ContactCollection(this);
            this._chatFriends = new ContactCollection(this);
            this._contacts = new ContactCollection();
            this._strangers = new ContactCollection();
            this._contactChangedEventArgsCol = new List<ContactChangedEventArgs>();
            owner.SipNotifyReceived += new EventHandler<SipRequestReceivedEventArgs>(this, (IntPtr) this.Owner_SipNotifyReceived);
        }

        internal void AddContact(Imps.Client.Core.Contact contact)
        {
            this.AddContact(contact, null);
        }

        internal void AddContact(Imps.Client.Core.Contact contact, IicUri prevUri)
        {
            if ((contact != null) && (contact.Type != ContactType.Stranger))
            {
                this.Contacts.Add(contact);
                if ((contact.Type == ContactType.Buddy) || (contact.Type == ContactType.Vodafone))
                {
                    this.Buddies.Add(contact);
                }
                else if (contact.Type == ContactType.MobileBuddy)
                {
                    this.MobileBuddies.Add(contact);
                }
                else if (contact.Type == ContactType.ChatFriend)
                {
                    if (this.Buddies.FindContact(contact.Uri) == null)
                    {
                        this.ChatFriends.Add(contact);
                    }
                    Imps.Client.Core.ContactGroup item = this.Groups[-1] as Imps.Client.Core.ContactGroup;
                    if (item == null)
                    {
                        item = new Imps.Client.Core.ContactGroup(base.Owner, -1, StringTable.ContactGroup.ChatFriendGroup);
                        this.Groups.Add(item);
                    }
                    item.Contacts.Add(contact);
                }
                base.Owner.Presence.update_buddy_crbttobuddy(contact);
                if (prevUri != null)
                {
                    Stranger oldContactInstance = base.Owner.ContactList.Strangers[prevUri] as Stranger;
                    if (oldContactInstance != null)
                    {
                        ContactTypeChangedEventArgs e = new ContactTypeChangedEventArgs(contact, oldContactInstance);
                        oldContactInstance.InnerOnContactTypeChanged(e);
                        this.InnerOnContactTypeChanged(e);
                        this.Strangers.Remove(oldContactInstance);
                    }
                }
                else
                {
                    Stranger stranger2 = base.Owner.ContactList.Strangers.FindContact(contact.Uri) as Stranger;
                    if (stranger2 != null)
                    {
                        ContactTypeChangedEventArgs args2 = new ContactTypeChangedEventArgs(contact, stranger2);
                        stranger2.InnerOnContactTypeChanged(args2);
                        this.InnerOnContactTypeChanged(args2);
                        this.Strangers.Remove(stranger2);
                    }
                }
            }
        }

        public bool AsyncAddBuddy(bool isByMobileNo, string id, string domain, int? targetGroupId, string localName, AddBuddyExtraData extraData, bool sendRequestAgain, bool copyWhenExist, bool? invite, AsyncBizOperation op)
        {
            <>c__DisplayClass3 class2;
            IicUri uri;
            if (localName.Length > 0x40)
            {
                localName = localName.Substring(0, 0x40);
            }
            if (targetGroupId.get_HasValue() && (this.Groups.FindContactGroup(targetGroupId) == null))
            {
                base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.ContactGroup.MsgNotExist), op);
                return false;
            }
            if (isByMobileNo)
            {
                if ((id[0] != '+') && !ImpsHelper.IsCmccMobileNo(id))
                {
                    base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.Contact.InvalidMobileNo), op);
                    return false;
                }
                if (string.IsNullOrEmpty(domain) || (domain == "fetion"))
                {
                    uri = IicUri.CreateTelUri(id);
                }
                else if (domain == "vodafone")
                {
                    uri = IicUri.CreateTelUri(id, "vodafone");
                }
                else
                {
                    uri = IicUri.CreateTelUri(id);
                }
            }
            else
            {
                long sid;
                if (!long.TryParse(id, ref sid))
                {
                    return false;
                }
                if (string.IsNullOrEmpty(domain) || (domain == "fetion"))
                {
                    uri = IicUri.CreateSidUri(sid);
                }
                else if (domain == "vodafone")
                {
                    uri = IicUri.CreateSidUri(sid, "vodafone");
                }
                else
                {
                    uri = IicUri.CreateSidUri(sid);
                }
                if (!uri.IsValid)
                {
                    base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.MsgAddBuddyFailed), op);
                    return false;
                }
            }
            Imps.Client.Core.Contact contact = this.FindContact(false, uri.Id);
            if (contact != null)
            {
                if (copyWhenExist)
                {
                    AsyncBizOperation operation = new AsyncBizOperation();
                    operation.IsImpsErrorHandled = true;
                    Imps.Client.Core.ContactGroup.AsyncCopyContactTo(base.Owner, contact.Uri, null, targetGroupId, operation);
                }
                int? relationStatus = contact.RelationStatus;
                if ((relationStatus.GetValueOrDefault() == 1) && relationStatus.get_HasValue())
                {
                    if ((localName.Length != 0) && (localName != contact.PersonalInfo.Name.Value))
                    {
                        contact.PersonalInfo.Name.UserSetData.ProposedValue = localName;
                        AsyncBizOperation operation2 = new AsyncBizOperation();
                        contact.PersonalInfo.CommitChanges(operation2);
                    }
                }
                else if (!sendRequestAgain && (contact.Type != ContactType.ChatFriend))
                {
                    return false;
                }
                if (string.IsNullOrEmpty(localName))
                {
                    localName = contact.PersonalInfo.Name.UserSetDataProposedValue;
                }
            }
            if (contact == null)
            {
                if (((this.Buddies.Count + this.MobileBuddies.Count) + this.PenddingAddBuddyRequestUri.get_Count()) >= base.Owner.Configuration.SystemSetting.BuddyListSetting.MaxBuddyNum)
                {
                    base.Owner.FireImpsErrorInUiThread(new ImpsErrorEventArgs(StringTable.MsgAddMobileBuddyLimitExceeded), op);
                    return false;
                }
                if (!this.PenddingAddBuddyRequestUri.Contains(uri))
                {
                    this.PenddingAddBuddyRequestUri.Add(uri);
                }
            }
            SipRequest req = base.CreateSipRequest("S");
            req.Message.AddHeader(new SipcEventHeader("AddBuddy"));
            ParamForBiz biz = new ParamForBiz();
            biz.IicUri = uri;
            biz.Bool1 = invite;
            op.ContextForBiz = biz;
            req.Context = op;
            StringWriter tw = new StringWriter();
            XmlHelper.CreateXmlWriterForSipRequest(tw, null, delegate (XmlWriter writer, object context) {
                writer.WriteStartElement("contacts");
                writer.WriteStartElement("buddies");
                writer.WriteStartElement("buddy");
                writer.WriteAttributeString("uri", uri.Raw);
                if (!string.IsNullOrEmpty(localName))
                {
                    writer.WriteAttributeString("local-name", localName);
                }
                writer.WriteAttributeString("buddy-lists", targetGroupId.get_HasValue() ? targetGroupId.ToString() : string.Empty);
                if (extraData != null)
                {
                    writer.WriteAttributeString("desc", extraData.WhoAmI);
                }
                if (isByMobileNo)
                {
                    writer.WriteAttributeString("expose-mobile-no", "1");
                    writer.WriteAttributeString("expose-name", "1");
                }
                writer.WriteEndElement();
                writer.WriteEndElement();
                writer.WriteEndElement();
            });
            req.Message.Body = tw.ToString();
            ErrorHelper.HandleSendRequestErrorAndTimeout(req);
            req.WaitResponseTimeout += delegate (object sender, EventArgs e) {
                if (this.PenddingAddBuddyRequestUri.Contains(uri))
                {
                    this.PenddingAddBuddyRequestUri.Remove(uri);
                }
                op.FireImpsErrorInUiThread(new ImpsErrorEventArgs(string.Empty));
            };
            req.SendMessageFailed += new EventHandler<FailedEventArgs>(class2, (IntPtr) this.<AsyncAddBuddy>b__2);
            req.FinalResponseReceived += new EventHandler<SipResponseReceivedEventArgs>(this, (IntPtr) this.finalResponseReceived_AddBuddyRequest);
            base.SendSipMessage(req);
            return true;
        }

        internal bool AsyncAddChatFriend(IicUri uri, AsyncBizOperation op)
        {
            if (base.Owner.BlackList.Contains(uri))
            {

⌨️ 快捷键说明

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