commondrm/drmutility/src/DrmAutomatedUsage.cpp
changeset 0 95b198f216e5
child 18 8a03a285ab14
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2007 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:  DRM Automated Usage handling
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    <caf/caftypes.h>
       
    22 #include    <caf/data.h>
       
    23 #include    <drmautomatedusage.h>
       
    24 
       
    25 #include    "drmautomatedusageimpl.h"
       
    26 #include    "drmautomatedusageerrorhandling.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // DRM::CDrmAutomatedUsage::CDrmAutomatedUsage
       
    32 // C++ default constructor can NOT contain any code, that might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 DRM::CDrmAutomatedUsage::CDrmAutomatedUsage()
       
    36     {
       
    37     }
       
    38 
       
    39 // -----------------------------------------------------------------------------
       
    40 // DRM::CDrmAutomatedUsage::ConstructL
       
    41 // Symbian 2nd phase constructor can leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 void DRM::CDrmAutomatedUsage::ConstructL( CCoeEnv* aCoeEnv )
       
    45     {
       
    46     // Create the utility instance
       
    47     iUtility = DRM::CDrmUtility::NewL();
       
    48 
       
    49     // Create the implementation class instance
       
    50     iImplementation = DRM::CDrmAutomatedUsageImpl::NewL( aCoeEnv, iUtility );
       
    51 
       
    52     // Create the error handler
       
    53     iErrorHandler = DRM::CDrmAutomatedUsageErrorHandling::NewL(
       
    54         iImplementation );
       
    55     }
       
    56 
       
    57 // -----------------------------------------------------------------------------
       
    58 // DRM::CDrmAutomatedUsage::NewL
       
    59 // Two-phased constructor
       
    60 // -----------------------------------------------------------------------------
       
    61 //
       
    62 EXPORT_C DRM::CDrmAutomatedUsage* DRM::CDrmAutomatedUsage::NewL(
       
    63     CCoeEnv* aCoeEnv )
       
    64     {
       
    65     DRM::CDrmAutomatedUsage* self( DRM::CDrmAutomatedUsage::NewLC( aCoeEnv ) );
       
    66 
       
    67     CleanupStack::Pop( self );
       
    68 
       
    69     return self;
       
    70     }
       
    71 
       
    72 
       
    73 // -----------------------------------------------------------------------------
       
    74 // DRM::CDrmAutomatedUsage::NewLC
       
    75 // Two-phased constructor
       
    76 // -----------------------------------------------------------------------------
       
    77 //
       
    78 EXPORT_C DRM::CDrmAutomatedUsage* DRM::CDrmAutomatedUsage::NewLC(
       
    79     CCoeEnv* aCoeEnv )
       
    80     {
       
    81     DRM::CDrmAutomatedUsage* self( new( ELeave ) DRM::CDrmAutomatedUsage );
       
    82 
       
    83     CleanupStack::PushL( self );
       
    84     self->ConstructL( aCoeEnv );
       
    85 
       
    86     return self;
       
    87     }
       
    88 
       
    89 
       
    90 // -----------------------------------------------------------------------------
       
    91 // DRM::CDrmAutomatedUsage::~CDrmAutomatedUsage
       
    92 // Destructor
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 DRM::CDrmAutomatedUsage::~CDrmAutomatedUsage()
       
    96     {
       
    97     delete static_cast< DRM::CDrmAutomatedUsageErrorHandling* >(
       
    98         iErrorHandler );
       
    99     delete iImplementation;
       
   100     delete iUtility;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // DRM::CDrmAutomatedUsage::GetUtility
       
   105 // (more comments in header file)
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C DRM::CDrmUtility& DRM::CDrmAutomatedUsage::GetUtility() const
       
   109     {
       
   110     return *iUtility;
       
   111     }
       
   112 
       
   113 
       
   114 // -----------------------------------------------------------------------------
       
   115 // DRM::CDrmAutomatedUsage::GetErrorHandler
       
   116 // (more comments in header file)
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 EXPORT_C DRM::MDrmErrorHandling& DRM::CDrmAutomatedUsage::GetErrorHandler()
       
   120     const
       
   121     {
       
   122     return *iErrorHandler;
       
   123     }
       
   124 
       
   125 // -----------------------------------------------------------------------------
       
   126 // DRM::CDrmAutomatedUsage::CanSetAutomatedL
       
   127 // Checks whether given content can be set as automated.
       
   128 // (more comments in header file)
       
   129 // -----------------------------------------------------------------------------
       
   130 //
       
   131 EXPORT_C TBool DRM::CDrmAutomatedUsage::CanSetAutomatedL(
       
   132     RFile& aFile,
       
   133     const ContentAccess::TIntent aIntent,
       
   134     const DRM::TDrmAutomatedType aAutomatedType )
       
   135     {
       
   136     iUtility->CheckFileHandleL( aFile );
       
   137     return iImplementation->CanSetAutomatedL( aFile, aIntent, aAutomatedType );
       
   138     }
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // DRM::CDrmAutomatedUsage::CanSetAutomatedL
       
   142 // Checks whether given content can be set as automated.
       
   143 // (more comments in header file)
       
   144 // -----------------------------------------------------------------------------
       
   145 //
       
   146 EXPORT_C TBool DRM::CDrmAutomatedUsage::CanSetAutomatedL(
       
   147     const ContentAccess::CData& aData,
       
   148     const ContentAccess::TIntent aIntent,
       
   149     const DRM::TDrmAutomatedType aAutomatedType )
       
   150     {
       
   151     return iImplementation->CanSetAutomatedL( aData, aIntent, aAutomatedType );
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // DRM::CDrmAutomatedUsage::SetAutomatedL
       
   156 // Sets given content as automated.
       
   157 // (more comments in header file)
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 EXPORT_C void DRM::CDrmAutomatedUsage::SetAutomatedL(
       
   161     RFile& aFile,
       
   162     const ContentAccess::TIntent aIntent,
       
   163     const DRM::TDrmAutomatedType aAutomatedType,
       
   164     const DRM::TDrmAutomatedServiceType aServiceType )
       
   165     {
       
   166     iUtility->CheckFileHandleL( aFile );
       
   167     iImplementation->SetAutomatedL( aFile, 
       
   168                                     aIntent, 
       
   169                                     aAutomatedType, 
       
   170                                     aServiceType );
       
   171     }
       
   172 
       
   173 // -----------------------------------------------------------------------------
       
   174 // DRM::CDrmAutomatedUsage::SetAutomatedAsyncL
       
   175 // Sets given content asynchronously as automated.
       
   176 // (more comments in header file)
       
   177 // -----------------------------------------------------------------------------
       
   178 //
       
   179 EXPORT_C TInt DRM::CDrmAutomatedUsage::SetAutomatedAsyncL(
       
   180     RFile& aFile,
       
   181     const ContentAccess::TIntent aIntent,
       
   182     const DRM::TDrmAutomatedType aAutomatedType,
       
   183     DRM::MDrmAsyncObserver& aObserver,
       
   184     const DRM::TDrmAutomatedServiceType aServiceType )
       
   185     {
       
   186     iUtility->CheckFileHandleL( aFile );
       
   187     return iImplementation->SetAutomatedAsyncL( aFile, 
       
   188                                                 aIntent, 
       
   189                                                 aAutomatedType, 
       
   190                                                 aObserver, 
       
   191                                                 aServiceType );
       
   192     }
       
   193 
       
   194 // -----------------------------------------------------------------------------
       
   195 // DRM::CDrmAutomatedUsage::SetAutomatedL
       
   196 // Sets given content as automated.
       
   197 // (more comments in header file)
       
   198 // -----------------------------------------------------------------------------
       
   199 //
       
   200 EXPORT_C void DRM::CDrmAutomatedUsage::SetAutomatedL(
       
   201     const ContentAccess::CData& aData,
       
   202     const ContentAccess::TIntent aIntent,
       
   203     const DRM::TDrmAutomatedType aAutomatedType,
       
   204     const DRM::TDrmAutomatedServiceType aServiceType )
       
   205     {
       
   206     iImplementation->SetAutomatedL( aData, 
       
   207                                     aIntent, 
       
   208                                     aAutomatedType,
       
   209                                     aServiceType );
       
   210     }
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // DRM::CDrmAutomatedUsage::SetAutomatedAsyncL
       
   214 // Sets given content asynchronously as automated.
       
   215 // (more comments in header file)
       
   216 // -----------------------------------------------------------------------------
       
   217 //
       
   218 EXPORT_C TInt DRM::CDrmAutomatedUsage::SetAutomatedAsyncL(
       
   219     const ContentAccess::CData& aData,
       
   220     const ContentAccess::TIntent aIntent,
       
   221     const DRM::TDrmAutomatedType aAutomatedType,
       
   222     DRM::MDrmAsyncObserver& aObserver,
       
   223     const DRM::TDrmAutomatedServiceType aServiceType )
       
   224     {
       
   225     return iImplementation->SetAutomatedAsyncL( aData, 
       
   226                                                 aIntent, 
       
   227                                                 aAutomatedType, 
       
   228                                                 aObserver, 
       
   229                                                 aServiceType );
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // DRM::CDrmAutomatedUsage::RemoveAutomatedL
       
   234 // Removes content from automated use.
       
   235 // (more comments in header file)
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void DRM::CDrmAutomatedUsage::RemoveAutomatedL(
       
   239     RFile& aFile,
       
   240     const ContentAccess::TIntent aIntent,
       
   241     const DRM::TDrmAutomatedType aAutomatedType,
       
   242     const DRM::TDrmAutomatedServiceType aServiceType )
       
   243     {
       
   244     iUtility->CheckFileHandleL( aFile );
       
   245     iImplementation->RemoveAutomatedL( aFile, 
       
   246                                        aIntent, 
       
   247                                        aAutomatedType, 
       
   248                                        aServiceType );
       
   249     }
       
   250 
       
   251 // -----------------------------------------------------------------------------
       
   252 // DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL
       
   253 // Removes content from automated use
       
   254 // (more comments in header file)
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 EXPORT_C TInt DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(
       
   258     RFile& aFile,
       
   259     const ContentAccess::TIntent aIntent,
       
   260     const DRM::TDrmAutomatedType aAutomatedType,
       
   261     DRM::MDrmAsyncObserver& aObserver,
       
   262     const DRM::TDrmAutomatedServiceType aServiceType )
       
   263     {
       
   264     iUtility->CheckFileHandleL( aFile );
       
   265     return iImplementation->RemoveAutomatedAsyncL( aFile, 
       
   266                                                    aIntent, 
       
   267                                                    aAutomatedType, 
       
   268                                                    aObserver, 
       
   269                                                    aServiceType );
       
   270     }
       
   271 
       
   272 // -----------------------------------------------------------------------------
       
   273 // DRM::CDrmAutomatedUsage::RemoveAutomatedL
       
   274 // Removes content from automated use
       
   275 // (more comments in header file)
       
   276 // -----------------------------------------------------------------------------
       
   277 //
       
   278 EXPORT_C void DRM::CDrmAutomatedUsage::RemoveAutomatedL(
       
   279     const ContentAccess::CData& aData,
       
   280     const ContentAccess::TIntent aIntent,
       
   281     const DRM::TDrmAutomatedType aAutomatedType,
       
   282     const DRM::TDrmAutomatedServiceType aServiceType )
       
   283     {
       
   284     iImplementation->RemoveAutomatedL( aData, 
       
   285                                        aIntent, 
       
   286                                        aAutomatedType, 
       
   287                                        aServiceType );
       
   288     }
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL
       
   292 // Removes content from automated use
       
   293 // (more comments in header file)
       
   294 // -----------------------------------------------------------------------------
       
   295 //
       
   296 EXPORT_C TInt DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(
       
   297     const ContentAccess::CData& aData,
       
   298     const ContentAccess::TIntent aIntent,
       
   299     const DRM::TDrmAutomatedType aAutomatedType,
       
   300     DRM::MDrmAsyncObserver& aObserver,
       
   301     const DRM::TDrmAutomatedServiceType aServiceType )
       
   302     {
       
   303     return iImplementation->RemoveAutomatedAsyncL( aData, 
       
   304                                                    aIntent, 
       
   305                                                    aAutomatedType, 
       
   306                                                    aObserver, 
       
   307                                                    aServiceType );
       
   308     }
       
   309 
       
   310 // -----------------------------------------------------------------------------
       
   311 // DRM::CDrmAutomatedUsage::RemoveAutomatedL
       
   312 // Removes content from automated use
       
   313 // (more comments in header file)
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 EXPORT_C void DRM::CDrmAutomatedUsage::RemoveAutomatedL(
       
   317     const TDesC& aUniqueId,
       
   318     const ContentAccess::TIntent aIntent,
       
   319     const DRM::TDrmAutomatedType aAutomatedType,
       
   320     const DRM::TDrmAutomatedServiceType aServiceType )
       
   321     {
       
   322     iImplementation->RemoveAutomatedL( aUniqueId, 
       
   323                                        aIntent, 
       
   324                                        aAutomatedType, 
       
   325                                        aServiceType );
       
   326     }
       
   327 
       
   328 // -----------------------------------------------------------------------------
       
   329 // DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL
       
   330 // Removes content from automated use
       
   331 // (more comments in header file)
       
   332 // -----------------------------------------------------------------------------
       
   333 //
       
   334 EXPORT_C TInt DRM::CDrmAutomatedUsage::RemoveAutomatedAsyncL(
       
   335     const TDesC& aUniqueId,
       
   336     const ContentAccess::TIntent aIntent,
       
   337     const DRM::TDrmAutomatedType aAutomatedType,
       
   338     DRM::MDrmAsyncObserver& aObserver,
       
   339     const DRM::TDrmAutomatedServiceType aServiceType )
       
   340     {
       
   341     return iImplementation->RemoveAutomatedAsyncL( aUniqueId, 
       
   342                                                    aIntent, 
       
   343                                                    aAutomatedType, 
       
   344                                                    aObserver, 
       
   345                                                    aServiceType );
       
   346     }
       
   347 
       
   348 // -----------------------------------------------------------------------------
       
   349 // DRM::CDrmAutomatedUsage::RegisterEventObserverL
       
   350 // Registers the client to listen for automated usage events
       
   351 // (more comments in header file)
       
   352 // -----------------------------------------------------------------------------
       
   353 //
       
   354 EXPORT_C void DRM::CDrmAutomatedUsage::RegisterEventObserverL(
       
   355     DRM::MDrmAutomatedUsageObserver& aObserver )
       
   356     {
       
   357     iImplementation->RegisterEventObserverL( aObserver );
       
   358     }
       
   359 
       
   360 // -----------------------------------------------------------------------------
       
   361 // DRM::CDrmAutomatedUsage::UnregisterEventObserverL
       
   362 // Unregisters the client not to listen for automated usage events
       
   363 // (more comments in header file)
       
   364 // -----------------------------------------------------------------------------
       
   365 //
       
   366 EXPORT_C void DRM::CDrmAutomatedUsage::UnregisterEventObserverL(
       
   367     DRM::MDrmAutomatedUsageObserver& aObserver )
       
   368     {
       
   369     iImplementation->UnregisterEventObserverL( aObserver );
       
   370     }
       
   371 
       
   372 // -----------------------------------------------------------------------------
       
   373 // DRM::CDrmAutomatedUsage::CancelOperation
       
   374 // Cancels the operation
       
   375 // (more comments in header file)
       
   376 // -----------------------------------------------------------------------------
       
   377 //
       
   378 EXPORT_C TInt DRM::CDrmAutomatedUsage::CancelOperation( TInt aOperationId )
       
   379     {
       
   380     return iImplementation->CancelOperation( aOperationId );
       
   381     }
       
   382 
       
   383 //  End of File