Beispiel #1
0
        /**
         * Returns the persistent unread counter for the specified resource
         * (the counter which is not view-specific and which is saved in the
         * resource store).
         */

        public int GetPersistentUnreadCount(IResource res)
        {
            if (_defaultUnreadState.IsCounterValid(res))
            {
                return(_defaultUnreadState.GetUnreadCount(res));
            }

            int count = res.GetIntProp(_propUnreadCount);

            _defaultUnreadState.UpdateUnreadCounter(res, count);
            return(count);
        }
Beispiel #2
0
        /// <summary>
        /// Adjusts the unread count for the specified resource stored in the specified
        /// count map by the specified delta value.
        /// </summary>
        private void AdjustUnreadCount(IResource res, int delta, UnreadState state)
        {
            if (!state.IsPersistent && !state.IsCounterValid(res))
            {
                return;
            }

            int count;

            if (state.IsCounterValid(res) || (state.IsPersistent && !_unreadCountProviders.Contains(res.Type)))
            {
                count = state.GetUnreadCount(res) + delta;
            }
            else
            {
                // this will initiate a new count calculation which will already take into account
                // the new unread state of the resource
                count = state.GetUnreadCount(res);
            }
            if (count >= 0)
            {
                state.UpdateUnreadCounter(res, count);
                if (state.IsPersistent && !_unreadCountProviders.Contains(res.Type))
                {
                    MarkUnreadCounterChanged(res);
                }
            }
        }
Beispiel #3
0
        /**
         * Sets the in-memory unread counter for the specified resource.
         */

        public void SetInMemoryUnreadCount(IResource res, int count)
        {
            if (_traceUnreadCounters)
            {
                Trace.WriteLine("Count for " + res + " on " + _curUnreadState + " is " + count);
            }
            _curUnreadState.UpdateUnreadCounter(res, count);
        }
Beispiel #4
0
        /**
         * Returns the unread count for the specified state.
         */

        internal int GetCountForState(UnreadState state, IResource res)
        {
            if (state.IsCounterValid(res) || (state != _curUnreadState && !state.IsPersistent))
            {
                return(state.GetCountFromBuffer(res));
            }

            int count;
            IUnreadCountProvider provider = (IUnreadCountProvider)_unreadCountProviders [res.Type];

            if (provider == null)
            {
                count = state.IsPersistent ? res.GetIntProp(_propUnreadCount) :
                        GetUnreadCountFromLinks(res, state);
            }
            else
            {
                count = GetProviderUnreadCount(res, state, provider);
            }
            state.UpdateUnreadCounter(res, count);
            return(count);
        }