PECengine/ListLibrary2/AuthSrc/CPEngAuthorizationManager.h
changeset 0 094583676ce7
equal deleted inserted replaced
-1:000000000000 0:094583676ce7
       
     1 /*
       
     2 * Copyright (c) 2005 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:  Reactive authorization manager.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGAUTHORIZATIONMANAGER_H__
       
    19 #define __CPENGAUTHORIZATIONMANAGER_H__
       
    20 
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "CPEngAuthorizationEngine.h"
       
    25 #include "MPEngAuthorizationManager.h"
       
    26 #include "MPEngAuthorizationManagerSet.h"
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class   CPEngAuthorizationRequest;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 /**
       
    34  * Reactive authorization manager.
       
    35  * Provides interface to access all active authorizations.
       
    36  *
       
    37  * @lib PEngListLib2
       
    38  * @since 3.0
       
    39  */
       
    40 class CPEngAuthorizationManager : public CPEngAuthorizationEngine,
       
    41             public MPEngAuthorizationManager,
       
    42             public MPEngAuthorizationManagerSet
       
    43 
       
    44     {
       
    45     public:  // Constructors and destructor
       
    46 
       
    47         /**
       
    48          * Two-phased constructor,
       
    49          */
       
    50         static CPEngAuthorizationManager* NewLC( MPEngListLibFactory& aFactory,
       
    51                                                  const CPEngSessionSlotId& aSessionId );
       
    52 
       
    53         /**
       
    54          * Destructor.
       
    55          */
       
    56         virtual ~CPEngAuthorizationManager();
       
    57 
       
    58 
       
    59     public:  // From MPEngAuthorizationManager
       
    60 
       
    61         /**
       
    62          * Close reference
       
    63          * @see <MPEngAuthorizationManager.h>
       
    64          */
       
    65         void Close();
       
    66 
       
    67 
       
    68         /**
       
    69          * Count all authorizations
       
    70          * @see <MPEngAuthorizationManager.h>
       
    71          */
       
    72         TInt AuthorizationsCount() const;
       
    73 
       
    74 
       
    75         /**
       
    76          * Get authorization request
       
    77          * @see <MPEngAuthorizationManager.h>
       
    78          */
       
    79         MPEngAuthorizationRequest& Authorization( TInt aIndex );
       
    80 
       
    81 
       
    82         /**
       
    83          * Count pending authorizations request
       
    84          * @see <MPEngAuthorizationManager.h>
       
    85          */
       
    86         TInt PendingAuthorizationsCount()  const;
       
    87 
       
    88 
       
    89         /**
       
    90          * Get pending authorizations request
       
    91          * @see <MPEngAuthorizationManager.h>
       
    92          */
       
    93         MPEngAuthorizationRequest& PendingAuthorization( TInt aIndex );
       
    94 
       
    95 
       
    96         /**
       
    97          * Issued authorization status count
       
    98          * @see <MPEngAuthorizationManager.h>
       
    99          */
       
   100         TInt RespondedAuthorizationsCount() const;
       
   101 
       
   102 
       
   103         /**
       
   104          * Issued authorization status
       
   105          * @see <MPEngAuthorizationManager.h>
       
   106          */
       
   107         const MPEngAuthorizationStatus& RespondedAuthorization(
       
   108             TInt aIndex ) const;
       
   109 
       
   110 
       
   111         /**
       
   112          * Server denied authorizations count
       
   113          * @see <MPEngAuthorizationManager.h>
       
   114          */
       
   115         TInt ServerDeniedAuthorizationsCount() const;
       
   116 
       
   117         /**
       
   118          * Server denied authorization
       
   119          * @see <MPEngAuthorizationManager.h>
       
   120          */
       
   121         const MPEngAuthorizationStatus& ServerDeniedAuthorization(
       
   122             TInt aIndex ) const;
       
   123 
       
   124         /**
       
   125          * Remove all Authorization responses
       
   126          * @see <MPEngAuthorizationManager.h>
       
   127          */
       
   128         void RemoveAllAuthorizationResponses();
       
   129 
       
   130 
       
   131         /**
       
   132          * Buffer with all packed authorization responses.
       
   133          * @see <MPEngAuthorizationManager.h>
       
   134          */
       
   135         HBufC16* BufferedTransactionsLC();
       
   136 
       
   137 
       
   138         /**
       
   139          * Register authorization observer.
       
   140          * @see <MPEngAuthorizationManager.h>
       
   141          */
       
   142         void RegisterAuthorizationObserverL(
       
   143             MPEngAuthorizationObserver& aObserver );
       
   144 
       
   145         /**
       
   146          * Unregister authorization observer.
       
   147          * @see <MPEngAuthorizationManager.h>
       
   148          */
       
   149         void UnRegisterAuthorizationObserver(
       
   150             MPEngAuthorizationObserver& aObserver );
       
   151 
       
   152 
       
   153 
       
   154     protected:  // From MPEngAuthorizationManagerSet
       
   155 
       
   156         /**
       
   157          * Set authorization response
       
   158          *
       
   159          * @see <MPEngAuthorizationManagerSet.h>
       
   160          */
       
   161         void SetAuthorizedAttributesL(
       
   162             const CPEngAuthorizationRequest& aAuthRequest,
       
   163             TArray<TUint32>& aAttributes,
       
   164             TBool aKeepOldAuthorization );
       
   165 
       
   166         void DenyAuthorizationL( const TDesC& aUserId );
       
   167         void CancelAuthorizationL( const TDesC& aUserId );
       
   168 
       
   169 
       
   170         /**
       
   171          * Removes buffered authorization response
       
   172          * @see <MPEngAuthorizationManagerSet.h>
       
   173          */
       
   174         void RemoveAuthorizationResponse( const TDesC& aUserId );
       
   175 
       
   176 
       
   177     private: //From CPEngStoreEntry / MPEngSIDChangeObserver
       
   178 
       
   179         /**
       
   180          * Handle change of the Storage IDs
       
   181          * @see <MPEngSIDChangeObserver.h>
       
   182          */
       
   183         void HandleSIDsChangeL( CPtrCArray& aChangedSIDs );
       
   184 
       
   185         /**
       
   186          * Called when SIDs notifier fails
       
   187          * @see <MPEngSIDChangeObserver.h>
       
   188          */
       
   189         void HandleSIDNotifyError( TInt aError );
       
   190 
       
   191 
       
   192     private: // new functions
       
   193 
       
   194         /**
       
   195          * Rebuild array of pending and denied authorizations
       
   196          *
       
   197          * @since 3.0
       
   198          */
       
   199         void RebuildSupportingArraysL();
       
   200 
       
   201 
       
   202         /**
       
   203          * Notify observers about events
       
   204          *
       
   205          * @since 3.0
       
   206          */
       
   207         void NotifyAllChangesToObservers();
       
   208 
       
   209 
       
   210         /**
       
   211          * Notify observers about events
       
   212          *
       
   213          * @since 3.0
       
   214          */
       
   215         template <class NotifyItem>
       
   216         void NotifyChangeToObservers(
       
   217             void ( MPEngAuthorizationObserver:: *aNotifFunc )( NotifyItem& ),
       
   218             NotifyItem& aArgument );
       
   219 
       
   220         /**
       
   221          * Set all flags as to be notified
       
   222          *
       
   223          * @since 3.0
       
   224          */
       
   225         void UpdateAllFlags();
       
   226 
       
   227 
       
   228         /**
       
   229          * Get Authorization response.
       
   230          *
       
   231          * @since 3.0
       
   232          * @param aUserId user id of the Authorization response
       
   233          * @return authorization response
       
   234          */
       
   235         CPEngAuthorizationResponse& AuthorizationResponseL(
       
   236             const TDesC& aUserId );
       
   237 
       
   238 
       
   239         /**
       
   240          * Enable lock
       
   241          *
       
   242          * @since 3.0
       
   243          * @return ETrue if lock is put to clean up stack
       
   244          */
       
   245         TBool EnableLockLC();
       
   246 
       
   247 
       
   248         /**
       
   249          * Release lock
       
   250          *
       
   251          * @since 3.0
       
   252          */
       
   253         void ReleaseLock();
       
   254 
       
   255 
       
   256     public: // Lock clean up support
       
   257 
       
   258         /**
       
   259          * Handle release event
       
   260          * Used for Lock clean up stack support
       
   261          *
       
   262          * @since 3.0
       
   263          */
       
   264         void Release();
       
   265 
       
   266 
       
   267     private:
       
   268 
       
   269         /**
       
   270          * C++ constructor.
       
   271          */
       
   272         CPEngAuthorizationManager( MPEngListLibFactory& aFactory );
       
   273 
       
   274         /**
       
   275          * Symbian constructor
       
   276          */
       
   277         void ConstructL( const CPEngSessionSlotId& aSessionSlot );
       
   278 
       
   279 
       
   280     private: // Data
       
   281 
       
   282         /// OWN: Buffered authorization responses
       
   283         ///      Elements OWN
       
   284         RPointerArray<CPEngAuthorizationResponse>        iResponses;
       
   285 
       
   286         /// OWN: Pending authorizations,
       
   287         //       Elements REFerenced
       
   288         RPointerArray<CPEngAuthorizationRequest>         iPendingAuth;
       
   289 
       
   290         /// OWN: Denied authorization
       
   291         ///      Elements REFerenced
       
   292         RPointerArray<CPEngAuthorizationResponse>        iDeniedAuth;
       
   293 
       
   294 
       
   295         /// REF: Authorization Observers
       
   296         RPointerArray<MPEngAuthorizationObserver>        iObservers;
       
   297 
       
   298 
       
   299         /// OWN: Size of the buffered responses
       
   300         TInt                                             iBufRespSize;
       
   301 
       
   302     };
       
   303 
       
   304 #endif      //  __CPENGAUTHORIZATIONMANAGER_H__
       
   305 
       
   306 //  End of File
       
   307 
       
   308 
       
   309 
       
   310 
       
   311 
       
   312 
       
   313 
       
   314 
       
   315 
       
   316 
       
   317 
       
   318 
       
   319 
       
   320 
       
   321 
       
   322 
       
   323 
       
   324 
       
   325 
       
   326 
       
   327 
       
   328