appinstaller/AppMngr2/inc/appmngr2infoarray.h
changeset 80 9dcba1ee99f7
parent 77 d1838696558c
equal deleted inserted replaced
77:d1838696558c 80:9dcba1ee99f7
     1 /*
       
     2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Base class for AppInfo and PackageInfo arrays
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_APPMNGR2INFOARRAY_H
       
    20 #define C_APPMNGR2INFOARRAY_H
       
    21 
       
    22 #include <e32base.h>                    // CBase
       
    23 #include <appmngr2infobase.h>           // CAppMngr2InfoBase
       
    24 #include "appmngr2infoarrayobserver.h"  // MAppMngr2InfoArrayObserver
       
    25 
       
    26 
       
    27 /**
       
    28  * CAppMngr2InfoArray contains list of installation files or installed apps.
       
    29  * CAppMngr2Model uses these arrays to hold data received from scanning
       
    30  * installation directories or application registeries. Application UI uses
       
    31  * these arrays (via CAppMngr2Model) to get info about displayed items.
       
    32  * Functions At() and Count() are used for this purpose. Changes in array
       
    33  * content are notified using interface MAppMngr2InfoArrayObserver, and
       
    34  * makes the Application UI to refresh displayed lists.
       
    35  *
       
    36  * A "cache" buffer is used to maintain old data while new data is collected. 
       
    37  * For example, new installation files found in scanning are stored in iArray,
       
    38  * and old content is used from iCache while the scanning is on-going and more
       
    39  * items are added to iArray. When the scanning completes, new content in
       
    40  * iArray is taken in use (old content in iCache is discarded) and UI is
       
    41  * notified about the change.
       
    42  * 
       
    43  * Notifications can be disabled temporarily, which means that cache is
       
    44  * locked in use temporarily. When notifications are disabled, new content
       
    45  * may be received to iArray as usual, but no notifications are sent to
       
    46  * observer until notifications are enabled again. CAppMngr2Model disables
       
    47  * the notifications while a plugin specific command is running, as it needs
       
    48  * to call CommandComplete() when the running command completes. Plugin
       
    49  * specific commands (like delete or uninstall) may launch new scanning that
       
    50  * change the array content. CAppMngr2Model maintains pointer iActiveItem
       
    51  * to the item that is running the plugin specific command, and this item
       
    52  * is actually stored in iArray or iCache. If array content could change
       
    53  * while the command is run, iActiveItem might not be valid any more after
       
    54  * the command is complete and calling iActiveItem->CommandComplete()
       
    55  * might raise a KERN-EXEC panic. 
       
    56  */
       
    57 
       
    58 class CAppMngr2InfoArray : public CBase
       
    59     {
       
    60 public:     // constructor and destructor
       
    61     CAppMngr2InfoArray( MAppMngr2InfoArrayObserver& aObserver );
       
    62     ~CAppMngr2InfoArray();
       
    63 
       
    64 public:     // new functions
       
    65     CAppMngr2InfoBase* At( TInt aIndex ) const;
       
    66     TInt Count() const;
       
    67     void IncrementCacheUseL();
       
    68     void IncrementCacheUseStartingNewRoundL();
       
    69     void DecrementCacheUse();
       
    70     void DisableRefreshNotificationsL();
       
    71     void EnableRefreshNotificationsL();
       
    72     void AddItemInOrderL( CAppMngr2InfoBase* aInfo );
       
    73     void ImmediateDelete( CAppMngr2InfoBase* aInfo );
       
    74 
       
    75 private:    // new functions
       
    76     void MoveItemsToCacheMaintainingOrderL();
       
    77     void MoveCachedItemsToArrayInOrderL();
       
    78     void NotifyObserver();
       
    79     TBool IsCacheUsed() const;
       
    80 
       
    81 protected:  // data
       
    82     MAppMngr2InfoArrayObserver& iObserver;
       
    83     RPointerArray<CAppMngr2InfoBase> iArray;
       
    84     RPointerArray<CAppMngr2InfoBase> iCache;
       
    85     TLinearOrder<CAppMngr2InfoBase> iAlphabeticalOrder;
       
    86     TBool iForceCacheUse;
       
    87     TBool iForceCacheUseWhenAddingComplete;
       
    88     TBool iQuickRefreshes;
       
    89     TBool iArrayChangedObserverNeedsNotification;
       
    90     TInt iUseCache;
       
    91     };
       
    92 
       
    93 #endif  // C_APPMNGR2INFOARRAY_H
       
    94