omadrm/drmengine/server/src/drmparentstorage.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
child 84 b09186059647
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include "drmparentstorage.h"
    20 #include "drmparentstorage.h"
    21 #include "drmpermission.h"
    21 #include "DrmPermission.h"
    22 #include "drmlog.h"
    22 #include "drmlog.h"
    23 
    23 
    24 
    24 
    25 // EXTERNAL DATA STRUCTURES
    25 // EXTERNAL DATA STRUCTURES
    26 
    26 
    27 // EXTERNAL FUNCTION PROTOTYPES  
    27 // EXTERNAL FUNCTION PROTOTYPES
    28 
    28 
    29 // CONSTANTS
    29 // CONSTANTS
    30 
    30 
    31 // MACROS
    31 // MACROS
    32 
    32 
    40 // FORWARD DECLARATIONS
    40 // FORWARD DECLARATIONS
    41 
    41 
    42 
    42 
    43 // ============================= LOCAL FUNCTIONS ===============================
    43 // ============================= LOCAL FUNCTIONS ===============================
    44 
    44 
    45     
    45 
    46 // ============================ MEMBER FUNCTIONS ===============================
    46 // ============================ MEMBER FUNCTIONS ===============================
    47 
    47 
    48 // -----------------------------------------------------------------------------
    48 // -----------------------------------------------------------------------------
    49 // CDRMParentStorage::CDRMParentStorage
    49 // CDRMParentStorage::CDRMParentStorage
    50 //
    50 //
    51 // Default constructor 
    51 // Default constructor
    52 // -----------------------------------------------------------------------------
    52 // -----------------------------------------------------------------------------
    53 //
    53 //
    54 CDRMParentStorage::CDRMParentStorage():
    54 CDRMParentStorage::CDRMParentStorage():
    55 iParents( 1 )
    55 iParents( 1 )
    56     {
    56     {
    57     }
    57     }
    58     
    58 
    59 // -----------------------------------------------------------------------------
    59 // -----------------------------------------------------------------------------
    60 // CDRMParentStorage::~CDRMParentStorage
    60 // CDRMParentStorage::~CDRMParentStorage
    61 //
    61 //
    62 // Desetructor.
    62 // Desetructor.
    63 // -----------------------------------------------------------------------------
    63 // -----------------------------------------------------------------------------
    67     if ( iParentIDs )
    67     if ( iParentIDs )
    68         {
    68         {
    69         iParentIDs->Reset();
    69         iParentIDs->Reset();
    70         delete iParentIDs;
    70         delete iParentIDs;
    71         }
    71         }
    72         
    72 
    73     // The lists inside are autocleaning, so deletion causes
    73     // The lists inside are autocleaning, so deletion causes
    74     // the contents to also be deleted    
    74     // the contents to also be deleted
    75     iParents.ResetAndDestroy();
    75     iParents.ResetAndDestroy();
    76     }
    76     }
    77     
    77 
    78 // -----------------------------------------------------------------------------
    78 // -----------------------------------------------------------------------------
    79 // CDRMParentStorage::NewLC
    79 // CDRMParentStorage::NewLC
    80 //
    80 //
    81 // Two-phase constructor
    81 // Two-phase constructor
    82 // -----------------------------------------------------------------------------
    82 // -----------------------------------------------------------------------------
    83 //
    83 //
    84 CDRMParentStorage* CDRMParentStorage::NewLC()
    84 CDRMParentStorage* CDRMParentStorage::NewLC()
    85     {
    85     {
    86     CDRMParentStorage* self = new( ELeave ) CDRMParentStorage;
    86     CDRMParentStorage* self = new( ELeave ) CDRMParentStorage;
    87     CleanupStack::PushL( self );
    87     CleanupStack::PushL( self );
    88     
    88 
    89     self->ConstructL();
    89     self->ConstructL();
    90     
    90 
    91     return self;
    91     return self;
    92     }
    92     }
    93     
    93 
    94 // -----------------------------------------------------------------------------
    94 // -----------------------------------------------------------------------------
    95 // CDRMParentStorage::NewL
    95 // CDRMParentStorage::NewL
    96 //
    96 //
    97 // Two-phase constructor
    97 // Two-phase constructor
    98 // -----------------------------------------------------------------------------
    98 // -----------------------------------------------------------------------------
    99 //    
    99 //
   100 CDRMParentStorage* CDRMParentStorage::NewL()
   100 CDRMParentStorage* CDRMParentStorage::NewL()
   101     {
   101     {
   102     CDRMParentStorage* self = CDRMParentStorage::NewLC();
   102     CDRMParentStorage* self = CDRMParentStorage::NewLC();
   103     CleanupStack::Pop(); // sefl
   103     CleanupStack::Pop(); // sefl
   104     
   104 
   105     return self;
   105     return self;
   106     }
   106     }
   107     
   107 
   108 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   109 // CDRMParentStorage::ConstructL
   109 // CDRMParentStorage::ConstructL
   110 //
   110 //
   111 // 2nd phase constructor
   111 // 2nd phase constructor
   112 // -----------------------------------------------------------------------------
   112 // -----------------------------------------------------------------------------
   113 //
   113 //
   114 void CDRMParentStorage::ConstructL()
   114 void CDRMParentStorage::ConstructL()
   115     {
   115     {
   116     iParentIDs = new( ELeave ) CDesC8ArraySeg( KDefaultGranularity );
   116     iParentIDs = new( ELeave ) CDesC8ArraySeg( KDefaultGranularity );
   117     }
   117     }
   118     
   118 
   119 // -----------------------------------------------------------------------------
   119 // -----------------------------------------------------------------------------
   120 // CDRMParentStorage::NewListL
   120 // CDRMParentStorage::NewListL
   121 //
   121 //
   122 // Insert a new list to the storage, and return a handle to it.
   122 // Insert a new list to the storage, and return a handle to it.
   123 // -----------------------------------------------------------------------------
   123 // -----------------------------------------------------------------------------
   124 //    
   124 //
   125 CDRMPermissionList& CDRMParentStorage::NewListL()
   125 CDRMPermissionList& CDRMParentStorage::NewListL()
   126     {
   126     {
   127     __ASSERT_DEBUG( iParents.Count() >= iParentIDs->Count(), User::Invariant() );
   127     __ASSERT_DEBUG( iParents.Count() >= iParentIDs->Count(), User::Invariant() );
   128         
   128 
   129     if ( iParents.Count() == iParentIDs->Count() )
   129     if ( iParents.Count() == iParentIDs->Count() )
   130         {
   130         {
   131         // Balanced lists.
   131         // Balanced lists.
   132         CDRMPermissionList* newList = CDRMPermissionList::NewLC();
   132         CDRMPermissionList* newList = CDRMPermissionList::NewLC();
   133         newList->SetAutoCleanup( ETrue );
   133         newList->SetAutoCleanup( ETrue );
   134         
   134 
   135         iParents.AppendL( newList );
   135         iParents.AppendL( newList );
   136         CleanupStack::Pop();
   136         CleanupStack::Pop();
   137         }
   137         }
   138         
   138 
   139     return *( iParents[ iParents.Count() - 1 ] );
   139     return *( iParents[ iParents.Count() - 1 ] );
   140     }
   140     }
   141     
   141 
   142 // -----------------------------------------------------------------------------
   142 // -----------------------------------------------------------------------------
   143 // CDRMParentStorage::AddL
   143 // CDRMParentStorage::AddL
   144 //
   144 //
   145 // Add an entry to the ID table.
   145 // Add an entry to the ID table.
   146 // -----------------------------------------------------------------------------
   146 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   160 // -----------------------------------------------------------------------------
   161 // CDRMParentStorage::HasPermissions
   161 // CDRMParentStorage::HasPermissions
   162 //
   162 //
   163 // Check the count of the stored permissions for an id
   163 // Check the count of the stored permissions for an id
   164 // -----------------------------------------------------------------------------
   164 // -----------------------------------------------------------------------------
   165 //    
   165 //
   166 TBool CDRMParentStorage::HasPermissions( const TDesC8& aCID )
   166 TBool CDRMParentStorage::HasPermissions( const TDesC8& aCID )
   167     {
   167     {
   168     TBool r = EFalse;
   168     TBool r = EFalse;
   169     TInt pos;
   169     TInt pos;
   170     
   170 
   171     if ( iParentIDs->FindIsq( aCID, pos ) == KErrNone )
   171     if ( iParentIDs->FindIsq( aCID, pos ) == KErrNone )
   172         {
   172         {
   173         r = ETrue;
   173         r = ETrue;
   174         }
   174         }
   175     return r;
   175     return r;
   178 // -----------------------------------------------------------------------------
   178 // -----------------------------------------------------------------------------
   179 // CDRMParentStorage::operator[]
   179 // CDRMParentStorage::operator[]
   180 //
   180 //
   181 // Operator.
   181 // Operator.
   182 // -----------------------------------------------------------------------------
   182 // -----------------------------------------------------------------------------
   183 //    
   183 //
   184 CDRMPermissionList& CDRMParentStorage::operator[]( const TDesC8& aCID )
   184 CDRMPermissionList& CDRMParentStorage::operator[]( const TDesC8& aCID )
   185     {
   185     {
   186     TInt pos;
   186     TInt pos;
   187     
   187 
   188     iParentIDs->FindIsq( aCID, pos );
   188     iParentIDs->FindIsq( aCID, pos );
   189     return *( iParents[ pos ] );
   189     return *( iParents[ pos ] );
   190     }
   190     }
   191     
   191 
   192 // End of File
   192 // End of File