Exemplo n.º 1
0
        public bool FoldersExtras(bool wantRights, bool wantQuota)
        {
            data.UpdateExtras(wantRights, wantQuota);
            if(!application.EnableRights) wantRights = false;
            if(!application.EnableQuota)  wantQuota  = false;
            if(!wantRights && !wantQuota) return true;
            MBoxRef boxes = data.Folders;
            uint ucnt = boxes.Count;
            if(ucnt == 0) return true;

            // progress report setup ...
            uint upro = ucnt;
            if(wantRights && wantQuota) upro += ucnt;
            progress.Update(0);
            MBoxRef mout = new MBoxRef(boxes.Array);

            // get rights ...
            uint ures = 0; boxes.Reset();
            if(wantRights)
                using(ZIMapFactory.Bulk rights = factory.CreateBulk("MyRights", 3, false))
                {   ZIMapCommand.Generic current = null;
                    while(ures < ucnt)
                    {   if(rights.NextCommand(ref current))
                        {   mout.Next((uint)current.UserData);
                            mout.ExtraRights = ((ZIMapCommand.MyRights)current).Rights;
                            current.Reset(); ures++;
                            progress.Update(ures, upro);
                        }
                        if(boxes.Next())
                        {   if(boxes.ExtraRights != null) ures++;
                            else
                            {   ((ZIMapCommand.MyRights)current).Queue(boxes.Name);
                                current.UserData = boxes.Index;
                            }
                        }
                    }
                }

            // get quota info ...
            ures = 0; boxes.Reset();
            if(wantQuota)
                using(ZIMapFactory.Bulk rights = factory.CreateBulk("GetQuotaRoot", 3, false))
                {   ZIMapCommand.Generic current = null;
                    while(ures < ucnt)
                    {   if(rights.NextCommand(ref current))
                        {   ZIMapApplication.QuotaInfo info;
                            application.QuotaInfos((ZIMapCommand.GetQuotaRoot)current, out info);
                            mout.Next((uint)current.UserData);
                            mout.ExtraSetQuota(info);               // also save on failure
                            current.Reset(); ures++;
                            progress.Update(ures, upro);
                        }
                        if(boxes.Next())
                        {   if(boxes.ExtraQuotaRoot != null) ures++;
                            else
                            {   ((ZIMapCommand.GetQuotaRoot)current).Queue(boxes.Name);
                                current.UserData = boxes.Index;
                            }
                        }
                    }
                }
            return true;
        }
Exemplo n.º 2
0
            /// <summary>Iterator to enumerate a mailbox and it's descendents.</summary>
            /// <param name="position">
            /// Set on return, must initially be <see cref="MBoxRef.Nothing"/>.
            /// </param>
            /// <param name="server">
            /// Used for namespace support <see cref="ZIMapServer.FriendlyName"/>.
            /// </param>
            /// <returns>On success <c>true</c> is returned.</returns>
            /// <remarks>
            /// The returned <paramref name="position"/> should be used to access the
            /// data.<para/>
            /// <example><code lang="C#">
            /// uint udel = 0;
            /// CacheData.MBoxRef root = ...;
            /// CacheData.MBoxRef position = CacheData.MBoxRef.Nothing;
            /// while(umbx.Recurse(ref positioin, Server))
            /// {    if(position.Messages > 0) udel++
            /// }
            /// </code></example> 
            /// </remarks>
            public bool Recurse(ref MBoxRef position, ZIMapServer server)
            {
                if(!IsValid) return false;
                if(!position.IsValid)                       // start the iteration
                {   position = this;
                    return true;
                }

                // get the friendly root name and append a hierarchie delimiter
                uint rnsi;
                string root = boxes[index].Name;
                root = server.FriendlyName(root, out rnsi);
                root += server[rnsi].Delimiter;

                // now scan the list of mailboxes ...
                while(position.Next())
                {   if(position.index == index) continue;   // Reset() called?
                    uint cnsi;
                    string name = server.FriendlyName(position.Name, out cnsi);
                    if(rnsi == cnsi && name.StartsWith(root)) return true;
                }
                position = MBoxRef.Nothing;
                return false;
            }