drm_plat/drm_utility_api/inc/drmautomatedusage.h
changeset 0 95b198f216e5
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:  Provides operations for automated usage of DRM content
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CDRMAUTOMATEDUSAGE_H
       
    20 #define CDRMAUTOMATEDUSAGE_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 
       
    25 #include <caf/caftypes.h>
       
    26 #include <caf/data.h>
       
    27 
       
    28 #include <drmutilitytypes.h>
       
    29 #include <drmautomatedusageobserver.h>
       
    30 #include <drmutility.h>
       
    31 #include <drmerrorhandling.h>
       
    32 
       
    33 
       
    34 
       
    35 class CCoeEnv;
       
    36 
       
    37 namespace DRM
       
    38 {
       
    39 class CDrmAutomatedUsageImpl;
       
    40 
       
    41 /**
       
    42 *  Utility class for DRM related automated usage handling
       
    43 *
       
    44 *  Usage:
       
    45 *  @code
       
    46 *      #include <drmautomatedusage.h>
       
    47 *      // Instantiate class CDrmAutomatedUsage
       
    48 *      DRM::CDrmAutomatedUsage* iAutomatedUsage =
       
    49 *          DRM::CDrmAutomatedUsage::NewLC();
       
    50 *      // ...
       
    51 *      // RFile myRingToneFile;
       
    52 *      // open my Ringtone for reading
       
    53 *      // ...
       
    54 *      ContentAccess::CData* myDataObject = ContentAccess::CData::NewL(
       
    55 *          myRingToneFile,
       
    56 *          ContentAccess::KDefaultContentObject,
       
    57 *          ContentAccess::EPeek );
       
    58 *      // check if content can be set as automated
       
    59 *      if ( iAutomatedUsage->CanSetAutomatedL(
       
    60 *          myDataObject,
       
    61 *          ContentAccess::EPlay,
       
    62 *          DRM::EAUAutomatedTypeRingingTone ) )
       
    63 *          {
       
    64 *          // automated usage allowed
       
    65 *
       
    66 *          // we register content as ringing tone in this example
       
    67 *          iAutomatedUsage->SetAutomated(
       
    68 *              myDataObject,
       
    69 *              ContentAccess::EPlay,
       
    70 *              DRM::EAUAutomatedTypeRingingTone,
       
    71 *              DRM::EAUPassive );
       
    72 *
       
    73 *          }
       
    74 *          else
       
    75 *          {
       
    76 *          // automated usage not allowed
       
    77 *          }
       
    78 *  @endcode
       
    79 *
       
    80 *  @lib drmautomatedusage.lib
       
    81 *  @since S60 5.0
       
    82 */
       
    83 NONSHARABLE_CLASS( CDrmAutomatedUsage ) : public CBase
       
    84     {
       
    85 public:
       
    86 
       
    87     /**
       
    88     * Creates a new CDrmAutomatedUsage object and returns a pointer to it
       
    89     *
       
    90     * @since S60 5.0
       
    91     *
       
    92     * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
       
    93     *                  parameter is not provided the global instance
       
    94     *                  will be used. In the case of a server process
       
    95     *                  where the global instance is not available,
       
    96     *                  global notes will be used.
       
    97     *
       
    98     *                  If no CCoeEnv instance is available, applications
       
    99     *                  launched will be launched as standalone
       
   100     *                  applications.
       
   101     *
       
   102     * @return A functional CDrmAutomatedUsage -object
       
   103     *
       
   104     * @leave System wide error code
       
   105     *
       
   106     * @see CCoeEnv
       
   107     *
       
   108     */
       
   109     IMPORT_C static CDrmAutomatedUsage* NewL( CCoeEnv* aCoeEnv = NULL );
       
   110 
       
   111 
       
   112     /**
       
   113     * Creates a new CDrmAutomatedUsage object and returns a pointer to it
       
   114     * Leaves the pointer to the cleanup stack
       
   115     *
       
   116     * @since S60 5.0
       
   117     *
       
   118     * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
       
   119     *                  parameter is not provided the global instance
       
   120     *                  will be used. In the case of a server process
       
   121     *                  where the global instance is not available,
       
   122     *                  global notes will be used.
       
   123     *
       
   124     *                  If no CCoeEnv instance is available, applications
       
   125     *                  launched will be launched as standalone
       
   126     *                  applications.
       
   127     *
       
   128     * @return A functional CDrmAutomatedUsage -object
       
   129     *
       
   130     * @leave System wide error code
       
   131     *
       
   132     * @see CCoeEnv
       
   133     *
       
   134     */
       
   135     IMPORT_C static CDrmAutomatedUsage* NewLC( CCoeEnv* aCoeEnv = NULL );
       
   136 
       
   137 
       
   138     /**
       
   139     * Destructor
       
   140     */
       
   141     virtual ~CDrmAutomatedUsage();
       
   142 
       
   143 
       
   144     /**
       
   145     * Returns a reference to a CDrmUtility instance. The ownership
       
   146     * of the instance stays with the CDrmAutomatedUsage -class
       
   147     *
       
   148     * @since S60 5.0
       
   149     *
       
   150     * @return A reference to a functional CDrmUtility instance
       
   151     *
       
   152     * @see DRM::CDrmUtility
       
   153     */
       
   154     IMPORT_C CDrmUtility& GetUtility() const;
       
   155 
       
   156 
       
   157     /**
       
   158     * Returns a reference to a class which implements the
       
   159     * MDrmErrorHandling interface. The ownership
       
   160     * of the instance stays with the CDrmAutomatedUsage -class
       
   161     *
       
   162     * @since S60 5.0
       
   163     *
       
   164     * @return A reference to a functional object implementing the
       
   165     *         MDrmErrorHandling interface
       
   166     *
       
   167     * @see DRM::MDrmErrorHandling
       
   168     */
       
   169     IMPORT_C MDrmErrorHandling& GetErrorHandler() const;
       
   170 
       
   171 
       
   172     /**
       
   173     * Checks if given content can be set as an automated content.
       
   174     *
       
   175     * @since  S60 5.0
       
   176     *
       
   177     * @param[in]   aFile           file handle to the file
       
   178     * @param[in]   aIntent         See ContentAccess::Intent
       
   179     * @param[in]   AutomatedType   Usage intention of the automated content
       
   180     *
       
   181     * @return ETrue if the content can be set as automated content
       
   182     *         EFalse if the content can't be set as automated content
       
   183     *
       
   184     * @leave System wide or DRM specific error code.
       
   185     *
       
   186     * @see RFile
       
   187     * @see ContentAccess::TIntent
       
   188     * @see DRM::TDrmAutomatedType
       
   189     */
       
   190     IMPORT_C TBool CanSetAutomatedL(
       
   191         RFile& aFile,
       
   192         const ContentAccess::TIntent aIntent,
       
   193         const TDrmAutomatedType aAutomatedType );
       
   194 
       
   195 
       
   196     /**
       
   197     * Checks if given content can be set as an automated content.
       
   198     *
       
   199     * @since  S60 5.0
       
   200     *
       
   201     * @param[in]   aData           CData object to the protected content
       
   202     * @param[in]   aIntent         See ContentAccess::Intent
       
   203     * @param[in]   AutomatedType   Usage intention of the automated content
       
   204     *
       
   205     * @return ETrue if the content can be set as automated content
       
   206     *         EFalse if the content can't be set as automated content
       
   207     *
       
   208     * @leave System wide or DRM specific error code.
       
   209     *
       
   210     * @see ContentAccess::CData
       
   211     * @see ContentAccess::TIntent
       
   212     * @see DRM::TDrmAutomatedType
       
   213     */
       
   214     IMPORT_C TBool CanSetAutomatedL(
       
   215         const ContentAccess::CData& aData,
       
   216         const ContentAccess::TIntent aIntent,
       
   217         const TDrmAutomatedType aAutomatedType );
       
   218 
       
   219 
       
   220     /**
       
   221     * Registers given content to be used as an automated content.
       
   222     *
       
   223     * @since S60 5.0
       
   224     *
       
   225     * @param[in]   aFile           file handle to the file
       
   226     * @param[in]   aIntent         See ContentAccess::Intent
       
   227     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   228     * @param[in]   aServiceType    default: EAUActive
       
   229     *
       
   230     * @leave System wide or DRM specific error code.
       
   231     *
       
   232     * @see RFile
       
   233     * @see ContentAccess::TIntent
       
   234     * @see DRM::TDrmAutomatedType
       
   235     * @see DRM::TDrmAutomatedServiceType
       
   236     */
       
   237     IMPORT_C void SetAutomatedL(
       
   238         RFile& aFile,
       
   239         const ContentAccess::TIntent aIntent,
       
   240         const TDrmAutomatedType aAutomatedType,
       
   241         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   242 
       
   243 
       
   244     /**
       
   245     * Registers given content to be used as an automated content.
       
   246     *
       
   247     * @since S60 5.0
       
   248     *
       
   249     * @param[in]   aFile           file handle to the file
       
   250     * @param[in]   aIntent         See ContentAccess::Intent
       
   251     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   252     * @param[in]   aObserver       Async callback observer
       
   253     * @param[in]   aServiceType    default: EAUActive
       
   254     *
       
   255     * @return Operation Identifier for the async request
       
   256     *         required for cancelling an operation and
       
   257     *         identifying which request has been completed
       
   258     *
       
   259     * @leave System wide or DRM specific error code.
       
   260     *
       
   261     * @see RFile
       
   262     * @see ContentAccess::TIntent
       
   263     * @see DRM::TDrmAutomatedType
       
   264     * @see DRM::MDrmAsyncObserver
       
   265     * @see DRM::TDrmAutomatedServiceType
       
   266     *
       
   267     */
       
   268     IMPORT_C TInt SetAutomatedAsyncL(
       
   269         RFile& aFile,
       
   270         const ContentAccess::TIntent aIntent,
       
   271         const TDrmAutomatedType aAutomatedType,
       
   272         MDrmAsyncObserver& aObserver,
       
   273         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   274 
       
   275 
       
   276     /**
       
   277     * Registers given content to be used as an automated content.
       
   278     *
       
   279     * @since S60 5.0
       
   280     *
       
   281     * @param[in]   aData           CData object to the protected content
       
   282     * @param[in]   aIntent         See ContentAccess::Intent
       
   283     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   284     * @param[in]   aServiceType    default: EAUActive
       
   285     *
       
   286     * @leave System wide or DRM specific error code.
       
   287     *
       
   288     * @see ContentAccess::CData
       
   289     * @see ContentAccess::TIntent
       
   290     * @see DRM::TDrmAutomatedType
       
   291     * @see DRM::TDrmAutomatedServiceType
       
   292     */
       
   293     IMPORT_C void SetAutomatedL(
       
   294         const ContentAccess::CData& aData,
       
   295         const ContentAccess::TIntent aIntent,
       
   296         const TDrmAutomatedType aAutomatedType,
       
   297         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   298 
       
   299 
       
   300     /**
       
   301     * Registers given content to be used as an automated content.
       
   302     *
       
   303     * @since S60 5.0
       
   304     *
       
   305     * @param[in]   aData           CData object to the protected content
       
   306     * @param[in]   aIntent         See ContentAccess::Intent
       
   307     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   308     * @param[in]   aObserver       Async callback observer
       
   309     * @param[in]   aServiceType    default: EAUActive
       
   310     *
       
   311     * @return Operation Identifier for the async request
       
   312     *         required for cancelling an operation and
       
   313     *         identifying which request has been completed
       
   314     *
       
   315     * @leave System wide or DRM specific error code.
       
   316     *
       
   317     * @see ContentAccess::CData
       
   318     * @see ContentAccess::TIntent
       
   319     * @see DRM::TDrmAutomatedType
       
   320     * @see DRM::MDrmAsyncObserver
       
   321     * @see DRM::TDrmAutomatedServiceType
       
   322     */
       
   323     IMPORT_C TInt SetAutomatedAsyncL(
       
   324         const ContentAccess::CData& aData,
       
   325         const ContentAccess::TIntent aIntent,
       
   326         const TDrmAutomatedType aAutomatedType,
       
   327         MDrmAsyncObserver& aObserver,
       
   328         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   329 
       
   330 
       
   331     /**
       
   332     * Unregisters given content from being used as an automated content.
       
   333     *
       
   334     * @since S60 5.0
       
   335     *
       
   336     * @param[in]   aFile           file handle to the file
       
   337     * @param[in]   aIntent         See ContentAccess::Intent
       
   338     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   339     * @param[in]   aServiceType    default: EAUActive
       
   340     *
       
   341     * @leave System wide or DRM specific error code.
       
   342     *
       
   343     * @see RFile
       
   344     * @see ContentAccess::TIntent
       
   345     * @see DRM::TDrmAutomatedType
       
   346     * @see DRM::TDrmAutomatedServiceType
       
   347     */
       
   348     IMPORT_C void RemoveAutomatedL(
       
   349         RFile& aFile,
       
   350         const ContentAccess::TIntent aIntent,
       
   351         const TDrmAutomatedType aAutomatedType,
       
   352         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   353 
       
   354 
       
   355     /**
       
   356     * Unregisters given content from being used as an automated content.
       
   357     *
       
   358     * @since S60 5.0
       
   359     *
       
   360     * @param[in]   aFile           file handle to the file
       
   361     * @param[in]   aIntent         See ContentAccess::Intent
       
   362     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   363     * @param[in]  aObserver       Async callback observer
       
   364     * @param[in]   aServiceType    default: EAUActive
       
   365     *
       
   366     * @return Operation Identifier for the async request
       
   367     *         required for cancelling an operation and
       
   368     *         identifying which request has been completed
       
   369     *
       
   370     * @leave System wide or DRM specific error code.
       
   371     *
       
   372     * @see RFile
       
   373     * @see ContentAccess::TIntent
       
   374     * @see DRM::TDrmAutomatedType
       
   375     * @see DRM::MDrmAsyncObserver
       
   376     * @see DRM::TDrmAutomatedServiceType
       
   377     */
       
   378     IMPORT_C TInt RemoveAutomatedAsyncL(
       
   379         RFile& aFile,
       
   380         const ContentAccess::TIntent aIntent,
       
   381         const TDrmAutomatedType aAutomatedType,
       
   382         MDrmAsyncObserver& aObserver,
       
   383         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   384 
       
   385 
       
   386     /**
       
   387     * Unregisters given content from being used as an automated content.
       
   388     *
       
   389     * @since S60 5.0
       
   390     *
       
   391     * @param[in]   aData           CData object to the protected content
       
   392     * @param[in]   aIntent         See ContentAccess::Intent
       
   393     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   394     * @param[in]   aServiceType    default: EAUActive
       
   395     *
       
   396     * @leave System wide or DRM specific error code.
       
   397     *
       
   398     * @see ContentAccess::CData
       
   399     * @see ContentAccess::TIntent
       
   400     * @see DRM::TDrmAutomatedType
       
   401     * @see DRM::TDrmAutomatedServiceType
       
   402     */
       
   403     IMPORT_C void RemoveAutomatedL(
       
   404         const ContentAccess::CData& aData,
       
   405         const ContentAccess::TIntent aIntent,
       
   406         const TDrmAutomatedType aAutomatedType,
       
   407         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   408 
       
   409 
       
   410     /**
       
   411     * Unregisters given content from being used as an automated content.
       
   412     *
       
   413     * @since S60 5.0
       
   414     *
       
   415     * @param[in]   aData           CData object to the protected content
       
   416     * @param[in]   aIntent         See ContentAccess::Intent
       
   417     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   418     * @param[in]   aObserver       Async callback observer
       
   419     * @param[in]   aServiceType    default: EAUActive
       
   420     *
       
   421     * @return Operation Identifier for the async request
       
   422     *         required for cancelling an operation and
       
   423     *         identifying which request has been completed
       
   424     *
       
   425     * @leave System wide or DRM specific error code.
       
   426     *
       
   427     * @see ContentAccess::CData
       
   428     * @see ContentAccess::TIntent
       
   429     * @see DRM::TDrmAutomatedType
       
   430     * @see DRM::MDrmAsyncObserver
       
   431     * @see DRM::TDrmAutomatedServiceType
       
   432     */
       
   433     IMPORT_C TInt RemoveAutomatedAsyncL(
       
   434         const ContentAccess::CData& aData,
       
   435         const ContentAccess::TIntent aIntent,
       
   436         const TDrmAutomatedType aAutomatedType,
       
   437         MDrmAsyncObserver& aObserver,
       
   438         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   439 
       
   440 
       
   441     /**
       
   442     * Unregisters given content from being used as an automated content.
       
   443     *
       
   444     * @since S60 5.0
       
   445     *
       
   446     * @param[in]   aUniqueId       unique content id
       
   447     * @param[in]   aIntent         See ContentAccess::Intent
       
   448     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   449     * @param[in]   aServiceType    default: EAUActive
       
   450     *
       
   451     * @leave System wide or DRM specific error code.
       
   452     *
       
   453     * @see ContentAccess::TIntent
       
   454     *
       
   455     * @see ContentAccess::CData::GetStringAttribute()
       
   456     * @see ContentAccess::TStringAttribute
       
   457     * @see ContentAccess::TIntent
       
   458     * @see DRM::TDrmAutomatedType
       
   459     * @see DRM::TDrmAutomatedServiceType
       
   460     */
       
   461     IMPORT_C void RemoveAutomatedL(
       
   462         const TDesC& aUniqueId,
       
   463         const ContentAccess::TIntent aIntent,
       
   464         const TDrmAutomatedType aAutomatedType,
       
   465         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   466 
       
   467 
       
   468     /**
       
   469     * Unregisters given content from being used as an automated content.
       
   470     *
       
   471     * @since S60 5.0
       
   472     *
       
   473     * @param[in]   aUniqueId       unique content id
       
   474     * @param[in]   aIntent         See ContentAccess::Intent
       
   475     * @param[in]   aAutomatedType  Usage intention of the automated content
       
   476     * @param[in]   aObserver       Async callback observer
       
   477     * @param[in]   aServiceType    default: EAUActive
       
   478     *
       
   479     * @return Operation Identifier for the async request
       
   480     *         required for cancelling an operation and
       
   481     *         identifying which request has been completed
       
   482     *
       
   483     * @leave System wide or DRM specific error code.
       
   484     *
       
   485     * @see ContentAccess::CData::GetStringAttribute()
       
   486     * @see ContentAccess::TStringAttribute
       
   487     * @see ContentAccess::TIntent
       
   488     * @see DRM::TDrmAutomatedType
       
   489     * @see DRM::MDrmAsyncObserver
       
   490     * @see DRM::TDrmAutomatedServiceType
       
   491     */
       
   492     IMPORT_C TInt RemoveAutomatedAsyncL(
       
   493         const TDesC& aUniqueId,
       
   494         const ContentAccess::TIntent aIntent,
       
   495         const TDrmAutomatedType aAutomatedType,
       
   496         MDrmAsyncObserver& aObserver,
       
   497         const TDrmAutomatedServiceType aServiceType = EAUActive );
       
   498 
       
   499 
       
   500     /**
       
   501     * Registers client to listen events related to automated usage. If
       
   502     * the client doesn't do this, all the events are handled automatically
       
   503     * according to the S60 style.
       
   504     *
       
   505     * The observer registered with this function needs to be unregistered
       
   506     * before it is deleted.
       
   507     *
       
   508     * @since S60 5.0
       
   509     *
       
   510     * @param[in]    aObserver
       
   511     *
       
   512     * @leave System wide or DRM specific error code.
       
   513     *
       
   514     * @see DRM::MDrmAutomatedUsageObserver
       
   515     */
       
   516     IMPORT_C void RegisterEventObserverL(
       
   517         MDrmAutomatedUsageObserver& aObserver );
       
   518 
       
   519 
       
   520     /**
       
   521     * Unregisters client from listening to events related to automated usage.
       
   522     *
       
   523     * If register event observer has been called, it must be unregistered
       
   524     * before the observer object is deleted.
       
   525     *
       
   526     * @since S60 5.0
       
   527     *
       
   528     * @param[in]    aObserver
       
   529     *
       
   530     * @leave System wide or DRM specific error code.
       
   531     *
       
   532     * @see DRM::MDrmAutomatedUsageObserver
       
   533     */
       
   534     IMPORT_C void UnregisterEventObserverL(
       
   535         MDrmAutomatedUsageObserver& aObserver );
       
   536 
       
   537 
       
   538     /**
       
   539     * Cancel an asyncronous operation
       
   540     *
       
   541     * @since S60 5.0
       
   542     *
       
   543     * @param[in]   aOperationId    identifier of the async operation
       
   544     *                              to be cancelled
       
   545     * @return KErrNotFound if the operation has already been executed
       
   546     *         or it does not exist
       
   547     */
       
   548     IMPORT_C TInt CancelOperation( TInt aOperationId );
       
   549 
       
   550 
       
   551 private: // member functions
       
   552 
       
   553     /**
       
   554     *  Default constructor
       
   555     */
       
   556     CDrmAutomatedUsage();
       
   557 
       
   558 
       
   559     /**
       
   560     *  Second phase constructor
       
   561     */
       
   562     void ConstructL( CCoeEnv* aCoeEnv );
       
   563 
       
   564 
       
   565 private: // data members
       
   566     /**
       
   567     * Implementation class pointer
       
   568     * Owned
       
   569     */
       
   570     CDrmAutomatedUsageImpl* iImplementation;
       
   571 
       
   572     /**
       
   573     * Implementation class pointer
       
   574     * Owned
       
   575     */
       
   576     MDrmErrorHandling* iErrorHandler;
       
   577 
       
   578     /**
       
   579     * Implementation class pointer
       
   580     * Owned
       
   581     */
       
   582     CDrmUtility* iUtility;
       
   583     };
       
   584 }
       
   585 
       
   586 
       
   587 #endif // CDRMAUTOMATEDUSAGE_H