示例#1
0
        public static string GenerateMailListForAdl(Contact contact, RoleLists lists, bool initial)
        {
            Dictionary <string, RoleLists> hashlist = new Dictionary <string, RoleLists>(1);

            hashlist.Add(contact.Hash, lists);
            return(GenerateMailListForAdl(hashlist, initial)[0]);
        }
        public HtmlGrid <RoleLists> GetRoleLists(GridParam roleDetails)
        {
            List <RoleLists> roleLists = new List <RoleLists>();
            var details = _roleManagementRepository.GetRoleLists(roleDetails, StoredProcedureName);

            foreach (RoleLists role in details)
            {
                var detail = new RoleLists()
                {
                    Name        = role.Name,
                    FilterCount = role.FilterCount
                };
                var           roleId        = _encryptionService.EncryptString(role.Id);
                StringBuilder actionDetails = new StringBuilder();
                if (_roleExtension.HasPermission(PermissionValueLists.EditRole))
                {
                    actionDetails.Append("<a href='" + _configuration["ApplicationData:RootUrl"] + "/CoreSetup/Role/EditRole/" + roleId + "' class='btn btn-sm btn-link btn-round' title='Edit Role'><i class=\"fas fa-user-edit\"></i></a>");
                }
                detail.Action = actionDetails.ToString();
                roleLists.Add(detail);
            }
            _log.Information("role list get list response as {0}", JsonConvert.SerializeObject(roleLists));
            var roleList = new HtmlGrid <RoleLists>();

            roleList.aaData = roleLists;
            var firstDefault = roleLists.FirstOrDefault();

            if (firstDefault != null)
            {
                roleList.iTotalDisplayRecords = Convert.ToInt32(firstDefault.FilterCount);
                roleList.iTotalRecords        = Convert.ToInt32(firstDefault.FilterCount);
            }
            return(roleList);
        }
示例#3
0
        private bool hasBlockList(RoleLists list)
        {
            if ((list & RoleLists.Hide) != RoleLists.None)
            {
                return(true);
            }

            return(false);
        }
示例#4
0
        internal override void SetList(RoleLists msnLists)
        {
            if (hasBlockList(msnLists))
            {
                throw new MSNPSharpException("Cannot add a ShellContact to Hide/Block list.");
            }

            base.SetList(msnLists);
        }
示例#5
0
        internal override void AddToList(RoleLists list)
        {
            if (hasBlockList(list))
            {
                throw new MSNPSharpException("Cannot add a ShellContact to Hide/Block list.");
            }

            base.AddToList(list);
        }
示例#6
0
        public static RoleId GetMemberRole(RoleLists list)
        {
            switch (list)
            {
            case RoleLists.Allow:
                return(RoleId.Allow);

            case RoleLists.Pending:
                return(RoleId.Pending);

            case RoleLists.Hide:
                return(RoleId.Hide);
            }
            return(RoleId.None);
        }
示例#7
0
        private void AddMemberAsync(Contact contact, ServiceName serviceName, RoleLists list, AddMemberCompletedEventHandler callback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("AddMember", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            // check whether the update is necessary
            if (contact.HasLists(list))
            {
                return;
            }

            RoleId memberRole = ContactList.GetMemberRole(list);

            if (memberRole == RoleId.None)
            {
                return;
            }

            Service service = AddressBook.SelectTargetService(serviceName);

            if (service == null)
            {
                AddServiceAsync(serviceName,
                                delegate
                {
                    // RESURSIVE CALL
                    AddMemberAsync(contact, serviceName, list, callback);
                });
                return;
            }


            AddMemberRequestType addMemberRequest = new AddMemberRequestType();

            addMemberRequest.serviceHandle      = new HandleType();
            addMemberRequest.serviceHandle.Id   = service.Id.ToString();
            addMemberRequest.serviceHandle.Type = serviceName;

            Membership memberShip = new Membership();

            memberShip.MemberRole = memberRole;
            BaseMember member = null; // Abstract

            if (contact.ClientType == IMAddressInfoType.WindowsLive)
            {
                member = new PassportMember();
                PassportMember passportMember = member as PassportMember;
                passportMember.PassportName = contact.Account;
                passportMember.State        = MemberState.Accepted;
                passportMember.Type         = MembershipType.Passport;
            }
            else if (contact.ClientType == IMAddressInfoType.Yahoo ||
                     contact.ClientType == IMAddressInfoType.OfficeCommunicator)
            {
                member = new EmailMember();
                EmailMember emailMember = member as EmailMember;
                emailMember.State                = MemberState.Accepted;
                emailMember.Type                 = MembershipType.Email;
                emailMember.Email                = contact.Account;
                emailMember.Annotations          = new Annotation[] { new Annotation() };
                emailMember.Annotations[0].Name  = AnnotationNames.MSN_IM_BuddyType;
                emailMember.Annotations[0].Value = (contact.ClientType == IMAddressInfoType.Yahoo) ?
                                                   "32:" : "02:";
            }
            else if (contact.ClientType == IMAddressInfoType.Telephone)
            {
                member = new PhoneMember();
                PhoneMember phoneMember = member as PhoneMember;
                phoneMember.State       = MemberState.Accepted;
                phoneMember.Type        = MembershipType.Phone;
                phoneMember.PhoneNumber = contact.Account;
            }
            else if (contact.ClientType == IMAddressInfoType.Circle)
            {
                member = new CircleMember();
                CircleMember circleMember = member as CircleMember;
                circleMember.Type     = MembershipType.Circle;
                circleMember.State    = MemberState.Accepted;
                circleMember.CircleId = contact.AddressBookId.ToString("D").ToLowerInvariant();
            }

            if (member == null)
            {
                return;
            }

            memberShip.Members           = new BaseMember[] { member };
            addMemberRequest.memberships = new Membership[] { memberShip };

            MsnServiceState       AddMemberObject = new MsnServiceState(PartnerScenario.ContactMsgrAPI, "AddMember", true);
            SharingServiceBinding sharingService  = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, AddMemberObject);

            sharingService.AddMemberCompleted += delegate(object srv, AddMemberCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(sharingService, MsnServiceType.Sharing, e));

                if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                {
                    return;
                }

                // Update AB
                AddressBook.AddMemberhip(serviceName, contact.Account, contact.ClientType, memberRole, member);

                if (callback != null)
                {
                    callback(srv, e);
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(sharingService, MsnServiceType.Sharing, AddMemberObject, addMemberRequest));
        }
示例#8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="contact"></param>
 /// <param name="affectedList"></param>
 public ListMutateEventArgs(Contact contact, RoleLists affectedList)
     : base(contact)
 {
     AffectedList = affectedList;
 }
示例#9
0
 /// <summary>
 /// Constructory.
 /// </summary>
 /// <param name="affectedList"></param>
 public ListReceivedEventArgs(RoleLists affectedList)
 {
     AffectedList = affectedList;
 }
示例#10
0
        private bool hasBlockList(RoleLists list)
        {
            if ((list & RoleLists.Hide) != RoleLists.None)
            {
                return true;
            }

            return false;
        }
示例#11
0
 public CircleListEnumerator(Dictionary <string, Contact> .Enumerator listEnum, RoleLists filter)
     : base(listEnum, filter)
 {
 }
示例#12
0
        private void DeleteMemberAsync(Contact contact, ServiceName serviceName, RoleLists list, DeleteMemberCompletedEventHandler callback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("DeleteMember", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            // check whether the update is necessary
            if (!contact.HasLists(list))
                return;

            RoleId memberRole = ContactList.GetMemberRole(list);
            if (memberRole == RoleId.None)
                return;

            Service service = AddressBook.SelectTargetService(serviceName);

            if (service == null)
            {
                AddServiceAsync(serviceName,
                    delegate
                    {
                        // RESURSIVE CALL
                        DeleteMemberAsync(contact, serviceName, list, callback);
                    });
                return;
            }

            DeleteMemberRequestType deleteMemberRequest = new DeleteMemberRequestType();
            deleteMemberRequest.serviceHandle = new HandleType();
            deleteMemberRequest.serviceHandle.Id = service.Id.ToString();
            deleteMemberRequest.serviceHandle.Type = serviceName;

            Membership memberShip = new Membership();
            memberShip.MemberRole = memberRole;

            BaseMember deleteMember = null; // BaseMember is an abstract type, so we cannot create a new instance.
            // If we have a MembershipId different from 0, just use it. Otherwise, use email or phone number.
            BaseMember baseMember = AddressBook.SelectBaseMember(serviceName, contact.Account, contact.ClientType, memberRole);
            int membershipId = (baseMember == null) ? 0 : baseMember.MembershipId;

            switch (contact.ClientType)
            {
                case IMAddressInfoType.WindowsLive:

                    deleteMember = new PassportMember();
                    deleteMember.Type = (baseMember == null) ? MembershipType.Passport : baseMember.Type;
                    deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                    if (membershipId == 0)
                    {
                        (deleteMember as PassportMember).PassportName = contact.Account;
                    }
                    else
                    {
                        deleteMember.MembershipId = membershipId;
                        deleteMember.MembershipIdSpecified = true;
                    }
                    break;

                case IMAddressInfoType.Yahoo:
                case IMAddressInfoType.OfficeCommunicator:

                    deleteMember = new EmailMember();
                    deleteMember.Type = MembershipType.Email;
                    deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                    if (membershipId == 0)
                    {
                        (deleteMember as EmailMember).Email = contact.Account;
                    }
                    else
                    {
                        deleteMember.MembershipId = membershipId;
                        deleteMember.MembershipIdSpecified = true;
                    }
                    break;

                case IMAddressInfoType.Telephone:

                    deleteMember = new PhoneMember();
                    deleteMember.Type = MembershipType.Phone;
                    deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                    if (membershipId == 0)
                    {
                        (deleteMember as PhoneMember).PhoneNumber = contact.Account;
                    }
                    else
                    {
                        deleteMember.MembershipId = membershipId;
                        deleteMember.MembershipIdSpecified = true;
                    }
                    break;

                case IMAddressInfoType.Circle:
                    deleteMember = new CircleMember();
                    deleteMember.Type = MembershipType.Circle;
                    deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                    (deleteMember as CircleMember).CircleId = contact.AddressBookId.ToString("D").ToLowerInvariant();
                    break;
            }

            memberShip.Members = new BaseMember[] { deleteMember };
            deleteMemberRequest.memberships = new Membership[] { memberShip };

            MsnServiceState DeleteMemberObject = new MsnServiceState(PartnerScenario.ContactMsgrAPI, "DeleteMember", true);
            SharingServiceBinding sharingService = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, DeleteMemberObject);
            sharingService.DeleteMemberCompleted += delegate(object srv, DeleteMemberCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(sharingService, MsnServiceType.Sharing, e));

                if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                    return;

                // Update AB
                AddressBook.RemoveMemberhip(serviceName, contact.Account, contact.ClientType, memberRole);

                if (callback != null)
                {
                    callback(srv, e);
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(sharingService, MsnServiceType.Sharing, DeleteMemberObject, deleteMemberRequest));
        }
示例#13
0
 internal virtual void SetList(RoleLists msnLists)
 {
     lists = msnLists;
     NotifyManager();
 }
示例#14
0
 internal bool HasLists(RoleLists msnlists)
 {
     return ((lists & msnlists) == msnlists);
 }
示例#15
0
        private void DeleteMemberAsync(Contact contact, ServiceName serviceName, RoleLists list, DeleteMemberCompletedEventHandler callback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("DeleteMember", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            // check whether the update is necessary
            if (!contact.HasLists(list))
            {
                return;
            }

            RoleId memberRole = ContactList.GetMemberRole(list);

            if (memberRole == RoleId.None)
            {
                return;
            }

            Service service = AddressBook.SelectTargetService(serviceName);

            if (service == null)
            {
                AddServiceAsync(serviceName,
                                delegate
                {
                    // RESURSIVE CALL
                    DeleteMemberAsync(contact, serviceName, list, callback);
                });
                return;
            }


            DeleteMemberRequestType deleteMemberRequest = new DeleteMemberRequestType();

            deleteMemberRequest.serviceHandle      = new HandleType();
            deleteMemberRequest.serviceHandle.Id   = service.Id.ToString();
            deleteMemberRequest.serviceHandle.Type = serviceName;

            Membership memberShip = new Membership();

            memberShip.MemberRole = memberRole;

            BaseMember deleteMember = null; // BaseMember is an abstract type, so we cannot create a new instance.
            // If we have a MembershipId different from 0, just use it. Otherwise, use email or phone number.
            BaseMember baseMember   = AddressBook.SelectBaseMember(serviceName, contact.Account, contact.ClientType, memberRole);
            int        membershipId = (baseMember == null) ? 0 : baseMember.MembershipId;

            switch (contact.ClientType)
            {
            case IMAddressInfoType.WindowsLive:

                deleteMember       = new PassportMember();
                deleteMember.Type  = (baseMember == null) ? MembershipType.Passport : baseMember.Type;
                deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                if (membershipId == 0)
                {
                    (deleteMember as PassportMember).PassportName = contact.Account;
                }
                else
                {
                    deleteMember.MembershipId          = membershipId;
                    deleteMember.MembershipIdSpecified = true;
                }
                break;

            case IMAddressInfoType.Yahoo:
            case IMAddressInfoType.OfficeCommunicator:

                deleteMember       = new EmailMember();
                deleteMember.Type  = MembershipType.Email;
                deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                if (membershipId == 0)
                {
                    (deleteMember as EmailMember).Email = contact.Account;
                }
                else
                {
                    deleteMember.MembershipId          = membershipId;
                    deleteMember.MembershipIdSpecified = true;
                }
                break;

            case IMAddressInfoType.Telephone:

                deleteMember       = new PhoneMember();
                deleteMember.Type  = MembershipType.Phone;
                deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                if (membershipId == 0)
                {
                    (deleteMember as PhoneMember).PhoneNumber = contact.Account;
                }
                else
                {
                    deleteMember.MembershipId          = membershipId;
                    deleteMember.MembershipIdSpecified = true;
                }
                break;

            case IMAddressInfoType.Circle:
                deleteMember       = new CircleMember();
                deleteMember.Type  = MembershipType.Circle;
                deleteMember.State = (baseMember == null) ? MemberState.Accepted : baseMember.State;
                (deleteMember as CircleMember).CircleId = contact.AddressBookId.ToString("D").ToLowerInvariant();
                break;
            }

            memberShip.Members = new BaseMember[] { deleteMember };
            deleteMemberRequest.memberships = new Membership[] { memberShip };

            MsnServiceState       DeleteMemberObject = new MsnServiceState(PartnerScenario.ContactMsgrAPI, "DeleteMember", true);
            SharingServiceBinding sharingService     = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, DeleteMemberObject);

            sharingService.DeleteMemberCompleted += delegate(object srv, DeleteMemberCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(sharingService, MsnServiceType.Sharing, e));

                if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                {
                    return;
                }

                // Update AB
                AddressBook.RemoveMemberhip(serviceName, contact.Account, contact.ClientType, memberRole);

                if (callback != null)
                {
                    callback(srv, e);
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(sharingService, MsnServiceType.Sharing, DeleteMemberObject, deleteMemberRequest));
        }
示例#16
0
 public ListEnumerator(Dictionary <string, Contact> .Enumerator listEnum, RoleLists filter)
 {
     baseEnum   = listEnum;
     listFilter = filter;
 }
示例#17
0
        public static string[] GenerateMailListForAdl(Dictionary <string, RoleLists> contacts, bool initial)
        {
            List <string> mls       = new List <string>();
            XmlDocument   xmlDoc    = new XmlDocument();
            XmlElement    mlElement = xmlDoc.CreateElement("ml");

            if (initial)
            {
                mlElement.SetAttribute("l", "1");
            }

            if (contacts == null || contacts.Count == 0)
            {
                mls.Add(mlElement.OuterXml);
                return(mls.ToArray());
            }

            List <string> sortedContacts = new List <string>(contacts.Keys);

            sortedContacts.Sort(CompareContactsHash);

            int        domaincontactcount = 0;
            string     currentDomain      = null;
            XmlElement domtelElement      = null;

            foreach (string contact_hash in sortedContacts)
            {
                String   name;
                String   domain;
                string[] arr  = contact_hash.Split(new string[] { ":", ";via=" }, StringSplitOptions.RemoveEmptyEntries);
                String   type = IMAddressInfoType.Yahoo.ToString();
                if (arr.Length > 0)
                {
                    type = arr[0];
                }

                IMAddressInfoType clitype = (IMAddressInfoType)Enum.Parse(typeof(IMAddressInfoType), type);
                type = ((int)clitype).ToString();
                RoleLists imlist = contacts[contact_hash];
                RoleLists pelist = imlist;
                pelist &= ~RoleLists.Hide; // Remove Hide role from PE service

                if (clitype == IMAddressInfoType.Telephone)
                {
                    if (!arr[1].StartsWith("+"))
                    {
                        continue;
                    }

                    domain = String.Empty;
                    name   = "tel:" + arr[1];
                }
                else if (clitype == IMAddressInfoType.RemoteNetwork)
                {
                    domain = String.Empty;
                    name   = arr[1];
                }
                else
                {
                    String[] usernameanddomain = arr[1].Split('@');
                    domain = usernameanddomain[1];
                    name   = usernameanddomain[0];
                }

                if (imlist != RoleLists.None)
                {
                    if (currentDomain != domain)
                    {
                        currentDomain      = domain;
                        domaincontactcount = 0;

                        if (clitype == IMAddressInfoType.Telephone)
                        {
                            domtelElement = xmlDoc.CreateElement("t");
                        }
                        else if (clitype == IMAddressInfoType.RemoteNetwork)
                        {
                            domtelElement = xmlDoc.CreateElement("n");
                        }
                        else
                        {
                            domtelElement = xmlDoc.CreateElement("d");
                            domtelElement.SetAttribute("n", currentDomain);
                        }
                        mlElement.AppendChild(domtelElement);
                    }

                    XmlElement contactElement = xmlDoc.CreateElement("c");
                    contactElement.SetAttribute("n", name);

                    if (clitype != IMAddressInfoType.Telephone && clitype != IMAddressInfoType.RemoteNetwork)
                    {
                        contactElement.SetAttribute("t", type);
                    }

                    // IM
                    XmlElement IMservice = xmlDoc.CreateElement("s");
                    IMservice.SetAttribute("l", ((int)imlist).ToString());
                    IMservice.SetAttribute("n", ServiceShortNames.IM.ToString());
                    contactElement.AppendChild(IMservice);

                    // PE
                    if (pelist != RoleLists.None)
                    {
                        XmlElement PEservice = xmlDoc.CreateElement("s");
                        PEservice.SetAttribute("l", ((int)pelist).ToString());
                        PEservice.SetAttribute("n", ServiceShortNames.PE.ToString());
                        contactElement.AppendChild(PEservice);
                    }

                    domtelElement.AppendChild(contactElement);
                    domaincontactcount++;
                }

                if (mlElement.OuterXml.Length > 7300)
                {
                    mlElement.AppendChild(domtelElement);
                    mls.Add(mlElement.OuterXml);

                    mlElement = xmlDoc.CreateElement("ml");
                    if (initial)
                    {
                        mlElement.SetAttribute("l", "1");
                    }

                    currentDomain      = null;
                    domaincontactcount = 0;
                }
            }

            if (domaincontactcount > 0 && domtelElement != null)
            {
                mlElement.AppendChild(domtelElement);
            }

            mls.Add(mlElement.OuterXml);
            return(mls.ToArray());
        }
示例#18
0
        /// <summary>
        /// Add a membership list for this contact.
        /// </summary>
        /// <param name="list"></param>
        /// <remarks>Since AllowList and BlockList are mutally exclusive, adding a member to AllowList will lead to the remove of BlockList, revese is as the same.</remarks>
        internal virtual void AddToList(RoleLists list)
        {
            if ((lists & list) == RoleLists.None)
            {
                lists |= list;

                NotifyManager();
            }
        }
示例#19
0
        /// <summary>
        /// Send a request to the server to remove a contact from a specific list.
        /// </summary> 
        /// <param name="contact">The affected contact</param>
        /// <param name="serviceName">Service name</param>
        /// <param name="list">The list to remove the contact from</param>
        /// <param name="onSuccess"></param>
        internal void RemoveContactFromList(Contact contact, ServiceName serviceName, RoleLists list, EventHandler onSuccess)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("DeleteMember", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            // check whether the update is necessary
            if (!contact.HasLists(list))
                return;

            string payload = ContactList.GenerateMailListForAdl(contact, list, false);

            if (list == RoleLists.Forward)
            {
                NSMessageHandler.MessageProcessor.SendMessage(new NSPayLoadMessage("RML", payload));
                contact.RemoveFromList(list);

                if (onSuccess != null)
                {
                    onSuccess(this, EventArgs.Empty);
                }
                return;
            }

            DeleteMemberAsync(contact, serviceName, list,
                delegate(object service, DeleteMemberCompletedEventArgs e)
                {
                    if (null != e.Error && false == e.Error.Message.Contains("Member does not exist"))
                    {
                        return;
                    }

                    contact.RemoveFromList(list);
                    NSMessageHandler.ContactService.OnContactRemoved(new ListMutateEventArgs(contact, list));

                    if (((list & RoleLists.Allow) == RoleLists.Allow) || ((list & RoleLists.Hide) == RoleLists.Hide))
                    {
                        NSMessageHandler.MessageProcessor.SendMessage(new NSPayLoadMessage("RML", payload));
                    }

                    if (onSuccess != null)
                    {
                        onSuccess(this, EventArgs.Empty);
                    }

                    Trace.WriteLineIf(Settings.TraceSwitch.TraceVerbose, "DeleteMember completed: " + list, GetType().Name);

                });
        }
示例#20
0
        internal void RemoveFromList(RoleLists list)
        {
            if ((lists & list) != RoleLists.None)
            {
                lists ^= list;

                // set this contact to offline when it is neither on the allow list or on the forward list
                if (!(OnForwardList || OnAllowedList))
                {
                    status = PresenceStatus.Offline;
                    //also clear the groups, becase msn loose them when removed from the two lists
                    contactGroups.Clear();
                }

                NotifyManager();
            }
        }
示例#21
0
        internal int SendCircleNotifyRML(Guid circleId, string hostDomain, RoleLists lists)
        {
            string payload = "<ml><d n=\""
            + hostDomain + "\"><c n=\"" + circleId.ToString("D") + "\" l=\"" +
            ((int)lists).ToString() + "\" t=\"" +
            ((int)IMAddressInfoType.Circle).ToString() + "\"/></d></ml>";

            NSPayLoadMessage nsMessage = new NSPayLoadMessage("RML", payload);
            MessageProcessor.SendMessage(nsMessage);
            return nsMessage.TransactionID;
        }
示例#22
0
        private void AddMemberAsync(Contact contact, ServiceName serviceName, RoleLists list, AddMemberCompletedEventHandler callback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("AddMember", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            // check whether the update is necessary
            if (contact.HasLists(list))
                return;

            RoleId memberRole = ContactList.GetMemberRole(list);

            if (memberRole == RoleId.None)
                return;

            Service service = AddressBook.SelectTargetService(serviceName);

            if (service == null)
            {
                AddServiceAsync(serviceName,
                    delegate
                    {
                        // RESURSIVE CALL
                        AddMemberAsync(contact, serviceName, list, callback);
                    });
                return;
            }

            AddMemberRequestType addMemberRequest = new AddMemberRequestType();
            addMemberRequest.serviceHandle = new HandleType();
            addMemberRequest.serviceHandle.Id = service.Id.ToString();
            addMemberRequest.serviceHandle.Type = serviceName;

            Membership memberShip = new Membership();
            memberShip.MemberRole = memberRole;
            BaseMember member = null; // Abstract

            if (contact.ClientType == IMAddressInfoType.WindowsLive)
            {
                member = new PassportMember();
                PassportMember passportMember = member as PassportMember;
                passportMember.PassportName = contact.Account;
                passportMember.State = MemberState.Accepted;
                passportMember.Type = MembershipType.Passport;
            }
            else if (contact.ClientType == IMAddressInfoType.Yahoo ||
                contact.ClientType == IMAddressInfoType.OfficeCommunicator)
            {
                member = new EmailMember();
                EmailMember emailMember = member as EmailMember;
                emailMember.State = MemberState.Accepted;
                emailMember.Type = MembershipType.Email;
                emailMember.Email = contact.Account;
                emailMember.Annotations = new Annotation[] { new Annotation() };
                emailMember.Annotations[0].Name = AnnotationNames.MSN_IM_BuddyType;
                emailMember.Annotations[0].Value = (contact.ClientType == IMAddressInfoType.Yahoo) ?
                    "32:" : "02:";
            }
            else if (contact.ClientType == IMAddressInfoType.Telephone)
            {
                member = new PhoneMember();
                PhoneMember phoneMember = member as PhoneMember;
                phoneMember.State = MemberState.Accepted;
                phoneMember.Type = MembershipType.Phone;
                phoneMember.PhoneNumber = contact.Account;
            }
            else if (contact.ClientType == IMAddressInfoType.Circle)
            {
                member = new CircleMember();
                CircleMember circleMember = member as CircleMember;
                circleMember.Type = MembershipType.Circle;
                circleMember.State = MemberState.Accepted;
                circleMember.CircleId = contact.AddressBookId.ToString("D").ToLowerInvariant();
            }

            if (member == null)
                return;

            memberShip.Members = new BaseMember[] { member };
            addMemberRequest.memberships = new Membership[] { memberShip };

            MsnServiceState AddMemberObject = new MsnServiceState(PartnerScenario.ContactMsgrAPI, "AddMember", true);
            SharingServiceBinding sharingService = (SharingServiceBinding)CreateService(MsnServiceType.Sharing, AddMemberObject);
            sharingService.AddMemberCompleted += delegate(object srv, AddMemberCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(sharingService, MsnServiceType.Sharing, e));

                if (e.Cancelled || NSMessageHandler.MSNTicket == MSNTicket.Empty)
                    return;

                // Update AB
                AddressBook.AddMemberhip(serviceName, contact.Account, contact.ClientType, memberRole, member);

                if (callback != null)
                {
                    callback(srv, e);
                }
            };

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(sharingService, MsnServiceType.Sharing, AddMemberObject, addMemberRequest));
        }
示例#23
0
        internal override void AddToList(RoleLists list)
        {
            if (hasBlockList(list))
            {
                throw new MSNPSharpException("Cannot add a ShellContact to Hide/Block list.");
            }

            base.AddToList(list);
        }
示例#24
0
        internal override void SetList(RoleLists msnLists)
        {
            if (hasBlockList(msnLists))
            {
                throw new MSNPSharpException("Cannot add a ShellContact to Hide/Block list.");
            }

            base.SetList(msnLists);
        }
示例#25
0
 public ContactList.ListEnumerator FilterByRoles(RoleLists roles)
 {
     return(new ContactList.ListEnumerator(baseEnum, roles));
 }