drm_plat/drm_utility_api/inc/drmuihandling.h
changeset 0 95b198f216e5
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2006-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:  Utility API for DRM related UI
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_CDRMUIHANDLING_H
       
    20 #define C_CDRMUIHANDLING_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <f32file.h>
       
    24 #include <caf/caftypes.h>
       
    25 #include <drmutilitytypes.h>
       
    26 
       
    27 //*** forward declarations go here:
       
    28 namespace ContentAccess
       
    29     {
       
    30     class CData;
       
    31     }
       
    32 
       
    33 class CCoeEnv;
       
    34 
       
    35 namespace DRM
       
    36     {
       
    37 
       
    38     //*** forward declarations go here:
       
    39     class CDrmUtility;
       
    40     class MDrmErrorHandling;
       
    41     class MDrmAsyncObserver;
       
    42     class MDrmHandleErrorObserver;
       
    43     class MDrmUiCheckRightsObserver;
       
    44     class CDrmUiHandlingImpl;
       
    45 
       
    46     /**
       
    47      *  Utility class for DRM related UI
       
    48      *
       
    49      *  By using this class an application can resolve situation where there is
       
    50      *  no valid rights for the content, check status of rights and display
       
    51      *  an embedded rights details view.
       
    52      *
       
    53      *  Usage:
       
    54      *  @code
       
    55      *      #include <DrmUiHandling.h>
       
    56      *
       
    57      *      using namespace DRM;
       
    58      *
       
    59      *      // Call NewLC() to create an instance of CDrmUiHandling.
       
    60      *      CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC();
       
    61      *
       
    62      *      // Handling the error got when tried to read the file
       
    63      *      drmHandlerError = drmUiHandler->HandleErrorL( file, error, NULL );
       
    64      *
       
    65      *      // checking the status of the rights
       
    66      *      drmHandlerError = drmUiHandler->CheckRightsAmountL( file, NULL );
       
    67      *
       
    68      *      // opening embedded details view
       
    69      *      drmHandlerError = drmUiHandler->ShowDetailsViewL( file );
       
    70      *
       
    71      *      // delete the created instance of CDrmUiHandling
       
    72      *      CleanupStack::PopAndDestroy( drmUiHandler );
       
    73      *  @endcode
       
    74      *
       
    75      *  @lib drmutilityuihandling.lib
       
    76      *  @since S60 v5.0
       
    77      */
       
    78 NONSHARABLE_CLASS( CDrmUiHandling ) : public CBase
       
    79     {
       
    80 
       
    81 public:
       
    82 
       
    83     /**
       
    84      * Creates a new CDrmUiHandling object and returns a pointer to it
       
    85      *
       
    86      * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
       
    87      *                  parameter is not provided the global instance
       
    88      *                  will be used. In the case of a server process
       
    89      *                  where the global instance is not available,
       
    90      *                  global notes will be used.
       
    91      *
       
    92      *                  If no CCoeEnv instance is available, applications
       
    93      *                  launched will be launched as standalone
       
    94      *                  applications.
       
    95      *
       
    96      * @return A functional CDrmUiHandling -object
       
    97      *
       
    98      * @leave System wide error code
       
    99      */
       
   100     IMPORT_C static CDrmUiHandling* NewL( CCoeEnv* aCoeEnv = NULL );
       
   101 
       
   102     /**
       
   103      * Creates a new CDrmUiHandling object and returns a pointer to it
       
   104      * Leaves the pointer to the cleanup stack
       
   105      *
       
   106      * @param aCoeEnv   A pointer to an instance of CCoeEnv. If the
       
   107      *                  parameter is not provided the global instance
       
   108      *                  will be used. In the case of a server process
       
   109      *                  where the global instance is not available,
       
   110      *                  global notes will be used.
       
   111      *
       
   112      *                  If no CCoeEnv instance is available, applications
       
   113      *                  launched will be launched as standalone
       
   114      *                  applications.
       
   115      *
       
   116      * @return A functional CDrmUiHandling -object
       
   117      *
       
   118      * @leave System wide error code
       
   119      */
       
   120 
       
   121     IMPORT_C static CDrmUiHandling* NewLC( CCoeEnv* aCoeEnv = NULL );
       
   122 
       
   123     /**
       
   124      * Destructor
       
   125      */
       
   126     virtual ~CDrmUiHandling();
       
   127 
       
   128 
       
   129     /**
       
   130      * Returns a reference to a CDrmUtility instance. The ownership
       
   131      * of the instance stays with the CDrmUiHandling -class
       
   132      *
       
   133      * @since S60 v5.0
       
   134      *
       
   135      * @return A reference to a functional CDrmUtility instance
       
   136      *
       
   137      * @leave None
       
   138      *
       
   139      * @see CDrmUtility
       
   140      */
       
   141     IMPORT_C CDrmUtility& GetUtility() const;
       
   142 
       
   143 
       
   144     /**
       
   145      * Returns a reference to a class which implements the
       
   146      * MDrmErrorHandling interface. The ownership
       
   147      * of the instance stays with the CDrmUiHandling -class
       
   148      *
       
   149      * @since S60 v5.0
       
   150      *
       
   151      * @return A reference to a functional object implementing the
       
   152      *         MDrmErrorHandling interface
       
   153      *
       
   154      * @leave None
       
   155      *
       
   156      * @see MDrmErrorHandling
       
   157      */
       
   158     IMPORT_C MDrmErrorHandling& GetErrorHandler() const;
       
   159 
       
   160 
       
   161     /**
       
   162      * Check how much rights there are left for the content.
       
   163      * This method also displays appropriate notes, which observer can
       
   164      * override, if rights are invalid. Asynchronous version, all errors
       
   165      * are signalled using request status.
       
   166      *
       
   167      * @since S60 v5.0
       
   168      * @param[in]   aFile       file of which rights are checked.
       
   169      * @param[in]   aIntent     the CAF intent to be used for checking
       
   170      * @param[in]   aObserver   reference to observer
       
   171      *
       
   172      * @return Operation Identifier for the async request
       
   173      *         required for cancelling an operation and
       
   174      *         identifying which request has been completed
       
   175      *
       
   176      * @leave System wide error code
       
   177      *        KErrArgument  if file is not DRM protected.
       
   178      *
       
   179      * @see MDrmUiCheckRightsObserver
       
   180      * @see ContentAccess::TIntent
       
   181      */
       
   182     IMPORT_C TInt CheckRightsAmountAsyncL(
       
   183             RFile& aFile,
       
   184             ContentAccess::TIntent aIntent,
       
   185             MDrmUiCheckRightsObserver& aObserver );
       
   186 
       
   187     /**
       
   188      * Check how much rights there are left for the content.
       
   189      * This method also displays appropriate notes, which observer can
       
   190      * override, if rights are invalid. Synchronous version, leaves in case
       
   191      * of error.
       
   192      *
       
   193      * @since S60 v5.0
       
   194      * @param[in]   aFile       file of which rights are checked.
       
   195      * @param[in]   aIntent     the CAF intent to be used for checking
       
   196      * @param[in]   aObserver   pointer to observer, NULL if no observer
       
   197      *
       
   198      * @return none
       
   199      * @leave System wide error code
       
   200      *        KErrArgument  if file is not DRM protected.
       
   201      *
       
   202      * @see MDrmUiCheckRightsObserver
       
   203      * @see ContentAccess::TIntent
       
   204      */
       
   205     IMPORT_C void CheckRightsAmountL(
       
   206             RFile& aFile,
       
   207             ContentAccess::TIntent aIntent,
       
   208             MDrmUiCheckRightsObserver* aObserver );
       
   209 
       
   210     /**
       
   211      * Check how much rights there are left for the content.
       
   212      * This method also displays appropriate notes, which observer can
       
   213      * override, if rights are invalid. Asynchronous version, all errors
       
   214      * are signalled using request status.
       
   215      *
       
   216      * @since S60 v5.0
       
   217      * @param[in]   aFile       content of which rights are checked.
       
   218      * @param[in]   aIntent     the CAF intent to be used for checking
       
   219      * @param[in]   aObserver   reference to observer
       
   220      *
       
   221      * @return Operation Identifier for the async request
       
   222      *         required for cancelling an operation and
       
   223      *         identifying which request has been completed
       
   224      *
       
   225      * @leave System wide error code
       
   226      *        KErrArgument  if file is not DRM protected.
       
   227      *
       
   228      * @see MDrmUiCheckRightsObserver
       
   229      * @see ContentAccess::TIntent
       
   230      */
       
   231     IMPORT_C TInt CheckRightsAmountAsyncL(
       
   232             ContentAccess::CData& aFile,
       
   233             ContentAccess::TIntent aIntent,
       
   234             MDrmUiCheckRightsObserver& aObserver );
       
   235 
       
   236     /**
       
   237      * Check how much rights there are left for the content.
       
   238      * This method also displays appropriate notes, which observer can
       
   239      * override, if rights are invalid. Synchronous version, leaves in case
       
   240      * of error.
       
   241      *
       
   242      * @since S60 v5.0
       
   243      * @param[in]   aFile       content of which rights are checked.
       
   244      * @param[in]   aIntent     the CAF intent to be used for checking
       
   245      * @param[in]   aObserver   pointer to observer, NULL if no observer
       
   246      * @return none
       
   247      * @leave System wide error code
       
   248      *        KErrArgument  if file is not DRM protected.
       
   249      *
       
   250      * @see MDrmUiCheckRightsObserver
       
   251      * @see ContentAccess::TIntent
       
   252      */
       
   253     IMPORT_C void CheckRightsAmountL(
       
   254             ContentAccess::CData& aFile,
       
   255             ContentAccess::TIntent aIntent,
       
   256             MDrmUiCheckRightsObserver* aObserver );
       
   257 
       
   258     /**
       
   259      * Displays information about rights for given content.
       
   260      * Asynchronous version.
       
   261      *
       
   262      * @since S60 v5.0
       
   263      * @param[in]   aFile           file for which rights details are
       
   264      *                              displayed.
       
   265      * @param[in]   aObserver       reference to observer
       
   266      *
       
   267      * @return Operation Identifier for the async request
       
   268      *         required for cancelling an operation and
       
   269      *         identifying which request has been completed
       
   270      *
       
   271      * @leave   System wide error code
       
   272      */
       
   273     IMPORT_C TInt ShowDetailsViewAsyncL( RFile& aFile,
       
   274             MDrmAsyncObserver& aObserver );
       
   275 
       
   276     /**
       
   277      * Displays information about rights for given content.
       
   278      * Synchronous version, leaves in case of error.
       
   279      *
       
   280      * @since S60 v5.0
       
   281      * @param[in]   aFile       file for which rights details are
       
   282      *                          displayed.
       
   283      *
       
   284      * @leave   KErrArgument    File is not DRM protected.
       
   285      * @leave   KErrCANoRights  Rights object does not exist.
       
   286      *
       
   287      * @see caferr.h
       
   288      */
       
   289     IMPORT_C void ShowDetailsViewL( RFile& aFile );
       
   290 
       
   291     /**
       
   292      * Displays information about rights for given content.
       
   293      * Asynchronous version.
       
   294      *
       
   295      * @since S60 v5.0
       
   296      * @param[in]   aFile       content for which rights details are
       
   297      *                          displayed.
       
   298      * @param[in]   aObserver   reference to observer
       
   299      *
       
   300      * @return Operation Identifier for the async request
       
   301      *         required for cancelling an operation and
       
   302      *         identifying which request has been completed
       
   303      *
       
   304      * @leave System wide error code
       
   305      */
       
   306     IMPORT_C TInt ShowDetailsViewAsyncL( ContentAccess::CData& aFile,
       
   307             MDrmAsyncObserver& aObserver );
       
   308 
       
   309     /**
       
   310      * Displays information about rights for given content.
       
   311      * Synchronous version, leaves in case of error.
       
   312      *
       
   313      * @since S60 v5.0
       
   314      * @param[in]   aFile   content for which rights details are displayed.
       
   315      *
       
   316      * @leave   KErrArgument    Content is not DRM protected.
       
   317      * @leave   KErrCANoRights  Rights object does not exist.
       
   318      * @leave   System wide error code
       
   319      *
       
   320      * @see caferr.h
       
   321      */
       
   322     IMPORT_C void ShowDetailsViewL( ContentAccess::CData& aFile );
       
   323 
       
   324 
       
   325     /**
       
   326      * Handle the specific url defined by the file, such as InfoUrl
       
   327      * Asynchronous method
       
   328      *
       
   329      * @since S60 v5.0
       
   330      * @param[in]   aFile           file whose url is being handled
       
   331      * @param[in]   aType           type of the requested url,
       
   332      *                              only a single url may be requested
       
   333      *                              at a time
       
   334      * @param[in]   aObserver       reference to observer
       
   335      *
       
   336      * @return Operation Identifier for the async request
       
   337      *         required for cancelling an operation and
       
   338      *         identifying which request has been completed
       
   339      *
       
   340      * @leave   KErrArgument        File is not DRM protected.
       
   341      * @leave   KErrNotSupported    Url type is not supported for the file
       
   342      */
       
   343     IMPORT_C TInt HandleUrlAsyncL(
       
   344             RFile& aFile,
       
   345             TDrmUiUrlType aType,
       
   346             MDrmAsyncObserver& aObserver );
       
   347 
       
   348 
       
   349     /**
       
   350      * Handle the specific url defined by the file, such as InfoUrl
       
   351      *
       
   352      * @since S60 v5.0
       
   353      * @param[in]   aFile        file whose url is being handled
       
   354      * @param[in]   aType           type of the requested url,
       
   355      *                              only a single url may be requested
       
   356      *                              at a time
       
   357      *
       
   358      * @leave   KErrArgument     File is not DRM protected.
       
   359      * @leave   KErrNotSupported Url type is not supported for the file
       
   360      */
       
   361     IMPORT_C void HandleUrlL(
       
   362             RFile& aFile,
       
   363             TDrmUiUrlType aType );
       
   364 
       
   365     /**
       
   366      * Handle the specific url defined by the file, such as InfoUrl
       
   367      * Asynchronous method
       
   368      *
       
   369      * @since S60 v5.0
       
   370      * @param[in]   aFile           content whose url is being handled
       
   371      * @param[in]   aType           type of the requested url,
       
   372      *                              only a single url may be requested
       
   373      *                              at a time
       
   374      * @param[in]   aObserver       reference to observer
       
   375      *
       
   376      * @return Operation Identifier for the async request
       
   377      *         required for cancelling an operation and
       
   378      *         identifying which request has been completed
       
   379      *
       
   380      * @leave   KErrArgument        File is not DRM protected,
       
   381      *                              or multiple url:s were requested
       
   382      * @leave   KErrNotSupported    Url type is not supported for the file
       
   383      */
       
   384     IMPORT_C TInt HandleUrlAsyncL(
       
   385             ContentAccess::CData& aFile,
       
   386             TDrmUiUrlType aType,
       
   387             MDrmAsyncObserver& aObserver );
       
   388 
       
   389     /**
       
   390      * Handle the specific url defined by the file, such as InfoUrl
       
   391      *
       
   392      * @since S60 v5.0
       
   393      * @param[in]   aFile        content whose url is being handled
       
   394      * @param[in]   aType           type of the requested url,
       
   395      *                              only a single url may be requested
       
   396      *                              at a time
       
   397      *
       
   398      * @leave   KErrArgument     File is not DRM protected.
       
   399      * @leave   KErrNotSupported Url type is not supported for the file
       
   400      */
       
   401     IMPORT_C void HandleUrlL(
       
   402             ContentAccess::CData& aFile,
       
   403             TDrmUiUrlType aType );
       
   404 
       
   405 
       
   406     /**
       
   407      * Get information of the available urls
       
   408      * Asynchronous method
       
   409      *
       
   410      * @since S60 v5.0
       
   411      * @param[in]   aFile           file whose url is being handled
       
   412      * @param[out]  aType           A bitmask of the supported url types
       
   413      * @param[in]   aObserver       reference to observer
       
   414      *
       
   415      * @return Operation Identifier for the async request
       
   416      *         required for cancelling an operation and
       
   417      *         identifying which request has been completed
       
   418      *
       
   419      * @leave   KErrArgument        File is not DRM protected.
       
   420      */
       
   421     IMPORT_C TInt AvailableUrlsAsyncL(
       
   422             RFile& aFile,
       
   423             TDrmUiUrlType& aType,
       
   424             MDrmAsyncObserver& aObserver );
       
   425 
       
   426     /**
       
   427      * Get information of the available urls
       
   428      *
       
   429      * @since S60 v5.0
       
   430      * @param[in]   aFile           file whose url is being handled
       
   431      * @param[out]  aType           A bitmask of the supported url types
       
   432      *
       
   433      * @leave   KErrArgument        File is not DRM protected.
       
   434      */
       
   435     IMPORT_C void AvailableUrlsL(
       
   436             RFile& aFile,
       
   437             TDrmUiUrlType& aType );
       
   438 
       
   439 
       
   440     /**
       
   441      * Get information of the available urls
       
   442      * Asynchronous method
       
   443      *
       
   444      * @since S60 v5.0
       
   445      * @param[in]   aFile           content whose url is being handled
       
   446      * @param[out]  aType           A bitmask of the supported url types
       
   447      * @param[in]   aObserver       reference to observer
       
   448      *
       
   449      * @return Operation Identifier for the async request
       
   450      *         required for cancelling an operation and
       
   451      *         identifying which request has been completed
       
   452      *
       
   453      * @leave   KErrArgument        File is not DRM protected.
       
   454      */
       
   455     IMPORT_C TInt AvailableUrlsAsyncL(
       
   456             ContentAccess::CData& aFile,
       
   457             TDrmUiUrlType& aType,
       
   458             MDrmAsyncObserver& aObserver );
       
   459 
       
   460     /**
       
   461      * Get information of the available urls
       
   462      *
       
   463      * @since S60 v5.0
       
   464      * @param[in]   aFile           content whose url is being handled
       
   465      * @param[out]  aType           A bitmask of the supported url types
       
   466      *
       
   467      * @leave   KErrArgument        File is not DRM protected.
       
   468      */
       
   469     IMPORT_C void AvailableUrlsL(
       
   470             ContentAccess::CData& aFile,
       
   471             TDrmUiUrlType& aType );
       
   472 
       
   473 
       
   474     /**
       
   475      * Cancel an asyncronous operation
       
   476      *
       
   477      * @since S60 v5.0
       
   478      * @param[in]   aOperationId    identifier of the async operation
       
   479      *                              to be cancelled
       
   480      * @return KErrNotFound if the operation has already been executed
       
   481      *         or it does not exist
       
   482      */
       
   483     IMPORT_C TInt CancelOperation( TInt aOperationId );
       
   484 
       
   485 
       
   486 private:
       
   487     /**
       
   488      * Default Constructor
       
   489      */
       
   490     CDrmUiHandling();
       
   491 
       
   492     /**
       
   493      * 2nd phase constructor
       
   494      */
       
   495     void ConstructL( CCoeEnv* aCoeEnv );
       
   496 
       
   497 private: // data
       
   498 
       
   499     /**
       
   500      * Pointer to the implementation
       
   501      * Owned
       
   502      */
       
   503     CDrmUiHandlingImpl* iImplementation;
       
   504 
       
   505     /**
       
   506      * Pointer to a CDrmUtility -Instance
       
   507      * Owned
       
   508      */
       
   509     CDrmUtility* iUtility;
       
   510 
       
   511     /**
       
   512      * Pointer to an MDrmErrorHandling interface class instance
       
   513      * Owned
       
   514      */
       
   515     MDrmErrorHandling* iErrorHandler;
       
   516 
       
   517     };
       
   518     }
       
   519 
       
   520 
       
   521 
       
   522 #endif // C_CDRMUIHANDLING_H