PECengine/ListLibrary2/AuthSrc/CPEngAuthorizationEngine.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 engine.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __CPENGAUTHORIZATIONENGINE_H__
       
    19 #define __CPENGAUTHORIZATIONENGINE_H__
       
    20 
       
    21 
       
    22 //  INCLUDES
       
    23 #include <e32base.h>
       
    24 #include "CPEngStoreEntry.h"
       
    25 #include "MPEngAuthorizationEngine.h"
       
    26 
       
    27 
       
    28 
       
    29 // FORWARD DECLARATIONS
       
    30 class CPEngSessionSlotId;
       
    31 class CPEngAuthorizationResponse;
       
    32 class CPEngAuthorizationRequest;
       
    33 class CPEngAuthorizationItem;
       
    34 class MPEngListLibFactory;
       
    35 
       
    36 
       
    37 
       
    38 // CLASS DECLARATION
       
    39 /**
       
    40  * Reactive authorization engine base class.
       
    41  *
       
    42  * @lib PEngListLib2
       
    43  * @since 3.0
       
    44  */
       
    45 class CPEngAuthorizationEngine : protected CPEngStoreEntry,
       
    46             protected MPEngAuthorizationEngine
       
    47     {
       
    48     public:  // Two-phased constructors and destructor
       
    49 
       
    50         /**
       
    51          * Destructor.
       
    52          */
       
    53         virtual ~CPEngAuthorizationEngine();
       
    54 
       
    55     public: // Session recognize functions
       
    56 
       
    57         /**
       
    58          * Session Id
       
    59          * @since 3.0
       
    60          * @return session Id
       
    61          */
       
    62         const CPEngSessionSlotId& SessionId( ) const;
       
    63 
       
    64 
       
    65         /**
       
    66          * Increase ref count
       
    67          *
       
    68          * @since 3.0
       
    69          * @return server address
       
    70          */
       
    71         void Open( );
       
    72 
       
    73 
       
    74     protected: // From MPEngReactAuthEngine
       
    75 
       
    76         /**
       
    77          * Update authorization request state
       
    78          *
       
    79          * @see <MPEngReactAuthEngine.h>
       
    80          */
       
    81         void UpdateAuthorizationStateL(
       
    82             CPEngAuthorizationResponse& aAuthResponse,
       
    83             TBool aPartialAcceptance );
       
    84 
       
    85         /**
       
    86          * Remove authorization request, User id is invalide
       
    87          *
       
    88          * @see <MPEngReactAuthEngine.h>
       
    89          */
       
    90         void RemoveAuthorizationRequestL(
       
    91             CPEngAuthorizationResponse& aAuthResponse );
       
    92 
       
    93         /**
       
    94          * Add Authorization request
       
    95          *
       
    96          * @see <MPEngReactAuthEngine.h>
       
    97          */
       
    98         void AddAuthRequestLX( CPEngAuthorizationRequest* aAuthRequest );
       
    99 
       
   100 
       
   101         /**
       
   102          * Add Authorization status
       
   103          * @see <MPEngReactAuthEngine.h>
       
   104          */
       
   105         void AddAuthStatusLX( CPEngAuthorizationResponse* aAuthStatus );
       
   106 
       
   107 
       
   108         /**
       
   109          * Engine store size counter
       
   110          * @see <MPEngReactAuthEngine.h>
       
   111          */
       
   112         TInt& SizeCounter();
       
   113 
       
   114 
       
   115         /**
       
   116          * Lock for Network publishing
       
   117          * @see <MPEngReactAuthEngine.h>
       
   118          */
       
   119         void LockForNetworkPublishing();
       
   120 
       
   121 
       
   122         /**
       
   123          * Unlock from Network publishing
       
   124          * @see <MPEngReactAuthEngine.h>
       
   125          */
       
   126         void UnLockForNetworkPublishing();
       
   127 
       
   128 
       
   129     protected: // Functions from CPEngStoreEntry
       
   130 
       
   131         /**
       
   132          * Externalize to the given stream
       
   133          * @see <MPEngStoreEntry.h>
       
   134          */
       
   135         void ExternalizeL( RWriteStream& aStream,
       
   136                            TPEngStorageType aStorageType ) const;
       
   137 
       
   138         /**
       
   139          * Internalize from the given stream
       
   140          * @see <MPEngStoreEntry.h>
       
   141          */
       
   142         void InternalizeL( RReadStream& aStream,
       
   143                            TPEngStorageType aStorageType );
       
   144 
       
   145         /**
       
   146          * This method is used to retrieve ID for storing.
       
   147          * @see <MPEngStoreEntry.h>
       
   148          */
       
   149         const TDesC& StorageId() const;
       
   150 
       
   151 
       
   152         /**
       
   153          * This method is used to ask entry size in bytes.
       
   154          * @see <MPEngStoreEntry.h>
       
   155          */
       
   156         TUint32 EntrySize() const;
       
   157 
       
   158 
       
   159         /**
       
   160          * Handle change of the Storage IDs
       
   161          * @see <MPEngSIDChangeObserver.h>
       
   162          */
       
   163         void HandleSIDsChangeL( CPtrCArray& aChangedSIDs );
       
   164 
       
   165 
       
   166         /**
       
   167          * Called when SIDs notifier fails
       
   168          * @see <MPEngSIDChangeObserver.h>
       
   169          */
       
   170         void HandleSIDNotifyError( TInt aError );
       
   171 
       
   172 
       
   173     protected: // New functions
       
   174 
       
   175         /**
       
   176          * Authorization requests count
       
   177          *
       
   178          * @since 3.0
       
   179          * @return count of authorization requests
       
   180          */
       
   181         TInt AuthorizationRequestCount() const;
       
   182 
       
   183 
       
   184         /**
       
   185          * Get Authorization request from the store
       
   186          *
       
   187          * @since 3.0
       
   188          * @param aIndex index of the authorization request
       
   189          * @return authorization request
       
   190          */
       
   191         CPEngAuthorizationRequest& AuthorizationRequest( TInt aIndex );
       
   192 
       
   193 
       
   194         /**
       
   195          * Authorizations statuses count
       
   196          *
       
   197          * @since 3.0
       
   198          * @return count of authorization statuses
       
   199          */
       
   200         TInt AuthorizationStatusCount() const;
       
   201 
       
   202 
       
   203         /**
       
   204          * Get Authorization status from the store
       
   205          *
       
   206          * @since 3.0
       
   207          * @param aIndex index of the authorization status
       
   208          * @return authorization status
       
   209          */
       
   210         CPEngAuthorizationResponse& AuthorizationStatus( TInt aIndex );
       
   211 
       
   212 
       
   213         /**
       
   214          * Find authorization request
       
   215          *
       
   216          * @since 3.0
       
   217          * @param aUserId user id to look by
       
   218          * @return authorization request
       
   219          */
       
   220         CPEngAuthorizationRequest& AuthorizationRequestL( const TDesC& aUserId );
       
   221 
       
   222 
       
   223         /**
       
   224          * Find authorization response in passed array
       
   225          *
       
   226          * @since 3.0
       
   227          * @param aArray array to look in
       
   228          * @param aUserId user id to look by
       
   229          * @return index in array or KErrNotFound
       
   230          */
       
   231         static TInt FindAuthResponse(
       
   232             const RPointerArray<CPEngAuthorizationResponse>& aArray,
       
   233             const TDesC& aUserId  );
       
   234 
       
   235 
       
   236     private: // New helpers
       
   237 
       
   238         /**
       
   239          * Find authorization item in array
       
   240          *
       
   241          * @since 3.0
       
   242          * @param aArray array to look in
       
   243          * @param aUserId user id to look for item
       
   244          * @return index of item in array or KErrNotFound
       
   245          */
       
   246         template <class T>
       
   247         static TInt FindUserIdItem( const RPointerArray<T>& aArray,
       
   248                                     const TDesC& aUserId );
       
   249 
       
   250         /**
       
   251          * Adopt local flag and clean up old array
       
   252          *
       
   253          * @since 3.0
       
   254          * @param aArray Array to clean.
       
   255          * @param aNewItem Entry for which to adopt local flag,
       
   256          */
       
   257         template <class T>
       
   258         static void AdoptAndClean( RPointerArray<T>& aArray,
       
   259                                    T& aNewItem );
       
   260 
       
   261 
       
   262         /**
       
   263          * Moves elements from one array to another.
       
   264          *
       
   265          * @since 3.0
       
   266          * @param aTarget Target for move.
       
   267          * @param aSource Source to move from.
       
   268          */
       
   269         template <class T>
       
   270         static void AppendRemoveL( RPointerArray<T>& aTarget,
       
   271                                    RPointerArray<T>& aSource );
       
   272 
       
   273 
       
   274     protected: // protected that they can be called from derived classes
       
   275 
       
   276         /**
       
   277          * C++ constructor.
       
   278          */
       
   279         CPEngAuthorizationEngine( MPEngListLibFactory& aFactory );
       
   280 
       
   281         /**
       
   282          * Symbian constructor
       
   283          */
       
   284         void ConstructL( const CPEngSessionSlotId& aSessionSlot );
       
   285 
       
   286 
       
   287     protected: //Data
       
   288         /// REF: List lib factory
       
   289         MPEngListLibFactory&                            iFactory;
       
   290 
       
   291         /// Access count
       
   292         TInt                                            iAccessCount;
       
   293 
       
   294 
       
   295     private:  //Data
       
   296 
       
   297         /// OWN: Authorization requests
       
   298         RPointerArray<CPEngAuthorizationRequest>        iAuthRequests;
       
   299 
       
   300         /// OWN: Responded Authorizations
       
   301         RPointerArray<CPEngAuthorizationResponse>       iAuthStatuses;
       
   302 
       
   303         /// OWN: Session Id
       
   304         CPEngSessionSlotId*                             iSessionId;
       
   305     };
       
   306 
       
   307 #endif      //  __CPENGAUTHORIZATIONENGINE_H__
       
   308 
       
   309 //  End of File
       
   310 
       
   311 
       
   312 
       
   313 
       
   314 
       
   315 
       
   316 
       
   317 
       
   318 
       
   319 
       
   320 
       
   321 
       
   322 
       
   323 
       
   324 
       
   325 
       
   326 
       
   327 
       
   328 
       
   329 
       
   330 
       
   331