Пример #1
0
 /// <summary>
 /// Constructor, mostly used internal by the library.
 /// </summary>
 /// <param name="contactGroup"></param>
 public ContactGroupEventArgs(ContactGroup contactGroup)
 {
     ContactGroup = contactGroup;
 }
Пример #2
0
 /// <summary>
 /// Constructor, mostly used internal by the library.
 /// </summary>
 /// <param name="contactGroup"></param>
 public ContactGroupEventArgs(ContactGroup contactGroup)
 {
     ContactGroup = contactGroup;
 }
Пример #3
0
        /// <summary>
        /// Equals two contacgroups based on their ID
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            ContactGroup cg = obj as ContactGroup;

            return(cg != null && cg.Guid == guid);
        }
Пример #4
0
        private void ABGroupDeleteAsync(ContactGroup contactGroup, ABGroupDeleteCompletedEventHandler callback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("ABGroupDelete", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            ABGroupDeleteRequestType request = new ABGroupDeleteRequestType();
            request.abId = WebServiceConstants.MessengerIndividualAddressBookId;
            request.groupFilter = new groupFilterType();
            request.groupFilter.groupIds = new string[] { contactGroup.Guid };

            MsnServiceState ABGroupDeleteObject = new MsnServiceState(PartnerScenario.Timer, "ABGroupDelete", true);
            ABServiceBinding abService = (ABServiceBinding)CreateService(MsnServiceType.AB, ABGroupDeleteObject);
            abService.ABGroupDeleteCompleted += delegate(object service, ABGroupDeleteCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(abService, MsnServiceType.AB, e));

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

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

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abService, MsnServiceType.AB, ABGroupDeleteObject, request));
        }
Пример #5
0
        private void ABGroupUpdateAsync(ContactGroup group, string newGroupName, ABGroupUpdateCompletedEventHandler callback)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("ABGroupUpdate", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            ABGroupUpdateRequestType request = new ABGroupUpdateRequestType();
            request.abId = WebServiceConstants.MessengerIndividualAddressBookId;
            request.groups = new GroupType[1] { new GroupType() };
            request.groups[0].groupId = group.Guid;
            request.groups[0].propertiesChanged = PropertyString.GroupName; //"GroupName";
            request.groups[0].groupInfo = new groupInfoType();
            request.groups[0].groupInfo.name = newGroupName;

            MsnServiceState ABGroupUpdateObject = new MsnServiceState(PartnerScenario.GroupSave, "ABGroupUpdate", true);
            ABServiceBinding abService = (ABServiceBinding)CreateService(MsnServiceType.AB, ABGroupUpdateObject);
            abService.ABGroupUpdateCompleted += delegate(object service, ABGroupUpdateCompletedEventArgs e)
            {
                OnAfterCompleted(new ServiceOperationEventArgs(abService, MsnServiceType.AB, e));

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

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

            RunAsyncMethod(new BeforeRunAsyncMethodEventArgs(abService, MsnServiceType.AB, ABGroupUpdateObject, request));
        }
Пример #6
0
        internal void RemoveContactFromGroup(ContactGroup group)
        {
            if (contactGroups.Contains(group))
            {
                contactGroups.Remove(group);

                OnContactGroupRemoved(group);
            }
        }
Пример #7
0
 protected virtual void OnContactGroupRemoved(ContactGroup group)
 {
     if (ContactGroupRemoved != null)
         ContactGroupRemoved(this, new ContactGroupEventArgs(group));
 }
Пример #8
0
 public bool HasGroup(ContactGroup group)
 {
     return contactGroups.Contains(group);
 }
Пример #9
0
        internal void AddContactToGroup(ContactGroup group)
        {
            if (!contactGroups.Contains(group))
            {
                contactGroups.Add(group);

                OnContactGroupAdded(group);
            }
        }
Пример #10
0
 internal void AddGroup(ContactGroup group)
 {
     if (this[group.Guid] == null)
         list.Add(group);
     else
         this[group.Guid].SetName(group.Name);
 }
Пример #11
0
 internal void RemoveGroup(ContactGroup group)
 {
     list.Remove(group);
 }
Пример #12
0
        public virtual void Remove(ContactGroup group)
        {
            if (nsMessageHandler == null)
                throw new MSNPSharpException("No nameserver handler defined");

            if (this[group.Guid] != null)
                nsMessageHandler.ContactService.RemoveContactGroup(group);
            else
                throw new MSNPSharpException("Contactgroup not defined in this list");
        }
Пример #13
0
 /// <summary>
 /// Set the name of a contact group
 /// </summary>
 /// <param name="group">The contactgroup which name will be set</param>
 /// <param name="newGroupName">The new name</param>
 public void RenameGroup(ContactGroup group, string newGroupName)
 {
     ABGroupUpdateAsync(group, newGroupName,
         delegate(object service, ABGroupUpdateCompletedEventArgs e)
         {
             if (e.Error == null)
             {
                 group.SetName(newGroupName);
             }
         });
 }
Пример #14
0
        /// <summary>
        /// Send a request to the server to remove a contactgroup. Any contacts in the group will also be removed from the forward list.
        /// </summary>
        /// <param name="contactGroup">The group to remove</param>
        public void RemoveContactGroup(ContactGroup contactGroup)
        {
            foreach (Contact cnt in NSMessageHandler.ContactList.All)
            {
                if (cnt.ContactGroups.Contains(contactGroup))
                {
                    throw new InvalidOperationException("Target group not empty, please remove all contacts form the group first.");
                }
            }

            ABGroupDeleteAsync(contactGroup,
                delegate(object service, ABGroupDeleteCompletedEventArgs e)
                {
                    if (e.Error == null)
                    {
                        NSMessageHandler.ContactGroups.RemoveGroup(contactGroup);
                        AddressBook.Groups.Remove(new Guid(contactGroup.Guid));
                        NSMessageHandler.ContactService.OnContactGroupRemoved(new ContactGroupEventArgs(contactGroup));
                    }
                });
        }
Пример #15
0
        public void RemoveContactFromGroup(Contact contact, ContactGroup group)
        {
            if (NSMessageHandler.MSNTicket == MSNTicket.Empty || AddressBook == null)
            {
                OnServiceOperationFailed(this, new ServiceOperationFailedEventArgs("ABGroupContactDelete", new MSNPSharpException("You don't have access right on this action anymore.")));
                return;
            }

            if (contact.Guid == Guid.Empty)
                throw new InvalidOperationException("This is not a valid Messenger contact.");

            ABGroupContactDeleteAsync(contact, group,
                delegate(object service, ABGroupContactDeleteCompletedEventArgs e)
                {
                    if (e.Error == null)
                    {
                        contact.RemoveContactFromGroup(group);
                    }
                });
        }
Пример #16
0
 internal void RemoveGroup(ContactGroup group)
 {
     list.Remove(group);
 }