Beispiel #1
0
        private void UniquelyAddFolder(NavigationNodeFolder nodeToAdd, int currentGroupIndex)
        {
            bool flag = true;

            if (nodeToAdd.IsValid)
            {
                int i = 0;
                while (i < base.Count)
                {
                    int num = base[i].FindEquivalentNode(nodeToAdd);
                    if (num >= 0)
                    {
                        NavigationNode navigationNode = base[i].Children[num];
                        flag = this.CheckLatestNodes(nodeToAdd, navigationNode);
                        this.AddDuplicateNode(flag ? navigationNode : nodeToAdd);
                        if (flag)
                        {
                            base[i].Children.RemoveAt(num);
                            break;
                        }
                        break;
                    }
                    else
                    {
                        i++;
                    }
                }
            }
            if (flag)
            {
                base[currentGroupIndex].Children.Add(nodeToAdd);
            }
        }
Beispiel #2
0
        private NavigationNodeFolder AddFolderToGroup(int groupIndex, int nodeIndex, Folder folder, bool isMyFolder, string subject, NavigationNodeType nodeType)
        {
            NavigationNodeFolder navigationNodeFolder = new NavigationNodeFolder(folder, isMyFolder, subject, nodeType, base[groupIndex].NavigationNodeGroupClassId, this.navigationNodeGroupSection, base[groupIndex].Subject);
            NavigationNodeGroup  navigationNodeGroup  = base[groupIndex];

            navigationNodeGroup.Children.Insert(nodeIndex, navigationNodeFolder);
            return(navigationNodeFolder);
        }
 public int FindEquivalentNode(NavigationNodeFolder nodeFolder)
 {
     for (int i = 0; i < this.children.Count; i++)
     {
         if (nodeFolder.Equals(this.children[i]))
         {
             return(i);
         }
     }
     return(-1);
 }
Beispiel #4
0
        internal static void AddGSCalendarToSharedFoldersGroup(UserContext userContext, ExchangePrincipal exchangePrincipal)
        {
            NavigationNodeCollection navigationNodeCollection = NavigationNodeCollection.TryCreateNavigationNodeCollection(userContext, userContext.MailboxSession, NavigationNodeGroupSection.Calendar);

            if (navigationNodeCollection.FindGSCalendarsByLegacyDN(exchangePrincipal.LegacyDn).Length == 0)
            {
                int defaultGroup = navigationNodeCollection.GetDefaultGroup(NavigationNodeGroupType.SharedFoldersGroup);
                NavigationNodeGroup  navigationNodeGroup = navigationNodeCollection[defaultGroup];
                NavigationNodeFolder node = NavigationNodeFolder.CreateGSNode(exchangePrincipal, navigationNodeGroup.NavigationNodeGroupClassId, navigationNodeGroup.Subject, exchangePrincipal.MailboxInfo.DisplayName, navigationNodeGroup.NavigationNodeGroupSection);
                navigationNodeGroup.Children.Insert(navigationNodeGroup.Children.Count, node);
                navigationNodeCollection.Save(userContext.MailboxSession);
            }
        }
        public override bool Equals(object obj)
        {
            if (!(obj is NavigationNodeFolder))
            {
                return(false);
            }
            NavigationNodeFolder navigationNodeFolder = obj as NavigationNodeFolder;

            if (!this.IsValid || !navigationNodeFolder.IsValid)
            {
                return(false);
            }
            if (base.NavigationNodeGroupSection != navigationNodeFolder.NavigationNodeGroupSection)
            {
                return(false);
            }
            if (!string.Equals(this.MailboxLegacyDN, navigationNodeFolder.MailboxLegacyDN, StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }
            if (base.IsFavorites)
            {
                Guid associatedSearchFolderId  = this.AssociatedSearchFolderId;
                Guid associatedSearchFolderId2 = navigationNodeFolder.AssociatedSearchFolderId;
                if (associatedSearchFolderId.Equals(Guid.Empty) && associatedSearchFolderId2.Equals(Guid.Empty))
                {
                    return(this.FolderId.Equals(navigationNodeFolder.FolderId));
                }
                return(!associatedSearchFolderId.Equals(Guid.Empty) && !associatedSearchFolderId2.Equals(Guid.Empty) && associatedSearchFolderId.Equals(associatedSearchFolderId2));
            }
            else
            {
                if (this.IsGSCalendar && navigationNodeFolder.IsGSCalendar)
                {
                    return(this.NavigationNodeParentGroupClassId.Equals(navigationNodeFolder.NavigationNodeParentGroupClassId));
                }
                return(this.FolderId != null && navigationNodeFolder.FolderId != null && this.FolderId.Equals(navigationNodeFolder.FolderId) && base.NavigationNodeType == navigationNodeFolder.NavigationNodeType);
            }
        }
Beispiel #6
0
        internal NavigationNodeFolder AddMyFolderToGroup(UserContext userContext, MailboxSession mailboxSession, object[] folderPropertyValues, Dictionary <PropertyDefinition, int> folderPropertyMap)
        {
            this.ThrowIfSaved();
            this.ThrowIfNonMailGroupSectionNotSupported();
            Utilities.CheckAndThrowForRequiredProperty(folderPropertyMap, new PropertyDefinition[]
            {
                FolderSchema.Id,
                FolderSchema.DisplayName,
                StoreObjectSchema.ContainerClass,
                FolderSchema.ExtendedFolderFlags
            });
            NavigationNodeCollection.ThrowIfGroupSectionNotMatchFolderClass(this.navigationNodeGroupSection, folderPropertyValues[folderPropertyMap[StoreObjectSchema.ContainerClass]] as string);
            bool flag = Utilities.IsOneOfTheFolderFlagsSet(folderPropertyValues[folderPropertyMap[FolderSchema.ExtendedFolderFlags]], new ExtendedFolderFlags[]
            {
                ExtendedFolderFlags.SharedIn,
                ExtendedFolderFlags.ExchangeCrossOrgShareFolder
            });
            bool flag2 = Utilities.IsOneOfTheFolderFlagsSet(folderPropertyValues[folderPropertyMap[FolderSchema.ExtendedFolderFlags]], new ExtendedFolderFlags[]
            {
                ExtendedFolderFlags.WebCalFolder
            });
            NavigationNodeGroupType groupType = NavigationNodeGroupType.MyFoldersGroup;

            if (flag2)
            {
                groupType = NavigationNodeGroupType.OtherFoldersGroup;
            }
            else if (flag)
            {
                groupType = NavigationNodeGroupType.SharedFoldersGroup;
            }
            int defaultGroup = this.GetDefaultGroup(groupType);
            NavigationNodeFolder navigationNodeFolder = new NavigationNodeFolder(mailboxSession, userContext.IsMyMailbox(mailboxSession), folderPropertyValues, folderPropertyMap, (folderPropertyValues[folderPropertyMap[FolderSchema.DisplayName]] as string) ?? string.Empty, base[defaultGroup].NavigationNodeGroupClassId, this.navigationNodeGroupSection, base[defaultGroup].Subject);

            base[defaultGroup].Children.Add(navigationNodeFolder);
            return(navigationNodeFolder);
        }
        internal static NavigationNodeFolder CreateGSNode(ExchangePrincipal exchangePrincipal, Guid groupClassId, string groupName, string subject, NavigationNodeGroupSection navigationNodeGroupSection)
        {
            NavigationNodeFolder navigationNodeFolder = new NavigationNodeFolder(subject, navigationNodeGroupSection);

            navigationNodeFolder.GSCalendarSharerAddressBookEntryId = AddressBookEntryId.MakeAddressBookEntryID(exchangePrincipal);
            UserContext userContext = OwaContext.Current.UserContext;

            navigationNodeFolder.GSCalendarShareeStoreEntryId = StoreEntryId.ToProviderStoreEntryId(userContext.ExchangePrincipal);
            try
            {
                using (OwaStoreObjectIdSessionHandle owaStoreObjectIdSessionHandle = new OwaStoreObjectIdSessionHandle(exchangePrincipal, userContext))
                {
                    try
                    {
                        using (Folder folder = Folder.Bind(owaStoreObjectIdSessionHandle.Session as MailboxSession, DefaultFolderType.Calendar, new PropertyDefinition[]
                        {
                            StoreObjectSchema.EffectiveRights
                        }))
                        {
                            if (CalendarUtilities.UserHasRightToLoad(folder))
                            {
                                navigationNodeFolder.NavigationNodeEntryId      = folder.StoreObjectId.ProviderLevelItemId;
                                navigationNodeFolder.NavigationNodeStoreEntryId = StoreEntryId.ToProviderStoreEntryId(exchangePrincipal);
                            }
                        }
                    }
                    catch (ObjectNotFoundException)
                    {
                    }
                }
            }
            catch (OwaSharedFromOlderVersionException)
            {
            }
            navigationNodeFolder.ClearDirty();
            return(navigationNodeFolder);
        }
        public static OwaStoreObjectId CreateFromNavigationNodeFolder(UserContext userContext, NavigationNodeFolder nodeFolder)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (nodeFolder == null)
            {
                throw new ArgumentNullException("nodeFolder");
            }
            if (!nodeFolder.IsValid)
            {
                throw new ArgumentException("Not valid navigation node folder.");
            }
            if (!nodeFolder.IsGSCalendar && nodeFolder.FolderId == null)
            {
                throw new NotSupportedException("Doesn't support this kind of node folder");
            }
            if (nodeFolder.IsFolderInSpecificMailboxSession(userContext.MailboxSession))
            {
                return(OwaStoreObjectId.CreateFromMailboxFolderId(nodeFolder.FolderId));
            }
            if (nodeFolder.IsGSCalendar)
            {
                return(OwaStoreObjectId.CreateFromGSCalendarLegacyDN(nodeFolder.MailboxLegacyDN));
            }
            ExchangePrincipal exchangePrincipal;

            if (userContext.DelegateSessionManager.TryGetExchangePrincipal(nodeFolder.MailboxLegacyDN, out exchangePrincipal) && exchangePrincipal.MailboxInfo.IsArchive)
            {
                return(OwaStoreObjectId.CreateFromArchiveMailboxFolderId(nodeFolder.FolderId, nodeFolder.MailboxLegacyDN));
            }
            return(OwaStoreObjectId.CreateFromOtherUserMailboxFolderId(nodeFolder.FolderId, nodeFolder.MailboxLegacyDN));
        }
Beispiel #9
0
        private void Load(UserContext userContext, MailboxSession session, object[][] rows)
        {
            int num = 0;

            while (num < rows.Length && !NavigationNodeCollection.CheckItemClassAndSection(this.navigationNodeGroupSection, rows[num]))
            {
                num++;
            }
            if (this.IsFavorites)
            {
                base.Clear();
                base.Add(NavigationNodeCollection.CreateFavoritesGroup());
            }
            else
            {
                int num2 = num;
                while (num2 < rows.Length && NavigationNodeCollection.CheckItemClassAndSection(this.navigationNodeGroupSection, rows[num2]))
                {
                    if (NavigationNodeCollection.CheckNodeTypes(rows[num2], new NavigationNodeType[]
                    {
                        NavigationNodeType.Header
                    }))
                    {
                        this.UniquelyAddGroup(new NavigationNodeGroup(rows[num2], NavigationNodeCollection.PropertyMap));
                    }
                    num2++;
                }
            }
            Dictionary <Guid, int> dictionary = new Dictionary <Guid, int>(base.Count);

            for (int i = 0; i < base.Count; i++)
            {
                dictionary.Add(base[i].NavigationNodeGroupClassId, i);
            }
            while (num < rows.Length && NavigationNodeCollection.CheckItemClassAndSection(this.navigationNodeGroupSection, rows[num]))
            {
                if (NavigationNodeCollection.CheckNodeTypes(rows[num], new NavigationNodeType[]
                {
                    NavigationNodeType.NormalFolder,
                    NavigationNodeType.SharedFolder,
                    NavigationNodeType.SmartFolder,
                    NavigationNodeType.GSCalendar
                }))
                {
                    bool includeArchive = this.GroupSection == NavigationNodeGroupSection.First;
                    NavigationNodeFolder navigationNodeFolder = new NavigationNodeFolder(userContext, session, includeArchive, rows[num], NavigationNodeCollection.PropertyMap);
                    if (navigationNodeFolder.IsValid)
                    {
                        int num3 = -1;
                        if (this.IsFavorites)
                        {
                            num3 = 0;
                        }
                        else
                        {
                            Guid guid = navigationNodeFolder.NavigationNodeParentGroupClassId;
                            if (!guid.Equals(Guid.Empty) && dictionary.ContainsKey(guid))
                            {
                                num3 = dictionary[guid];
                            }
                            else
                            {
                                NavigationNodeGroup node = null;
                                if (!guid.Equals(Guid.Empty) && !string.IsNullOrEmpty(navigationNodeFolder.NavigationNodeGroupName))
                                {
                                    node = NavigationNodeCollection.CreateCustomizedGroup(this.navigationNodeGroupSection, navigationNodeFolder.NavigationNodeGroupName, guid);
                                }
                                else
                                {
                                    NavigationNodeGroupType navigationNodeGroupType = NavigationNodeGroupType.OtherFoldersGroup;
                                    switch (navigationNodeFolder.NavigationNodeType)
                                    {
                                    case NavigationNodeType.NormalFolder:
                                        navigationNodeGroupType = NavigationNodeGroupType.MyFoldersGroup;
                                        break;

                                    case NavigationNodeType.SharedFolder:
                                        navigationNodeGroupType = NavigationNodeGroupType.SharedFoldersGroup;
                                        break;
                                    }
                                    guid = NavigationNodeCollection.GetDefaultGroupClassId(navigationNodeGroupType);
                                    if (dictionary.ContainsKey(guid))
                                    {
                                        num3 = dictionary[guid];
                                    }
                                    else
                                    {
                                        node = NavigationNodeCollection.CreateDefaultGroup(navigationNodeGroupType, this.navigationNodeGroupSection);
                                    }
                                }
                                if (num3 < 0)
                                {
                                    base.Add(node);
                                    num3             = base.Count - 1;
                                    dictionary[guid] = num3;
                                }
                            }
                        }
                        this.UniquelyAddFolder(navigationNodeFolder, num3);
                    }
                }
                num++;
            }
            this.serverCollection = new NavigationNodeList <NavigationNodeGroup>();
            base.CopyToList(this.serverCollection);
            foreach (NavigationNodeGroup navigationNodeGroup in this)
            {
                foreach (NavigationNodeFolder navigationNodeFolder2 in navigationNodeGroup.Children)
                {
                    if (navigationNodeFolder2.FolderId != null && !navigationNodeFolder2.IsFlagSet(NavigationNodeFlags.PublicFolderFavorite))
                    {
                        navigationNodeFolder2.FixLegacyDNRelatedFlag(session);
                    }
                }
            }
        }