commondrm/drmrightsmanagerui/src/DRMRightsMgrAppUi.cpp
changeset 23 493788a4a8a4
parent 0 95b198f216e5
child 29 3bdc3b853094
equal deleted inserted replaced
5:79d62d1d7957 23:493788a4a8a4
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // INCLUDE FILES
    19 // INCLUDE FILES
    20 #include <dcfrep.h>
    20 #include <DcfRep.h>
    21 #include <dcfentry.h>
    21 #include <DcfEntry.h>
    22 #include <drmcommon.h>
    22 #include <DRMCommon.h>
    23 #include <dcfcommon.h>
    23 #include <DcfCommon.h>
    24 #include <wmdrmagent.h> // for WMDRM file details view
    24 #include <wmdrmagent.h> // for WMDRM file details view
    25 
    25 
    26 #include <drmrightsmanager.rsg>
    26 #include <DRMRightsManager.rsg>
    27 
    27 
    28 #include <aknwaitdialog.h>
    28 #include <AknWaitDialog.h>
    29 #include <aknlistquerydialog.h>
    29 #include <aknlistquerydialog.h>
    30 #include <stringloader.h>
    30 #include <StringLoader.h>
    31 #include <aknnavide.h>
    31 #include <aknnavide.h>
    32 #include <akndef.h>
    32 #include <AknDef.h>
    33 #include <barsread.h>  // for resource reader
    33 #include <barsread.h>  // for resource reader
    34 #include <centralrepository.h>
    34 #include <centralrepository.h>
    35 #include <coeutils.h>
    35 #include <coeutils.h>
    36 
    36 
    37 #include <starterclient.h>
    37 #include <starterclient.h>
    41 
    41 
    42 // caf
    42 // caf
    43 #include <caf/data.h>
    43 #include <caf/data.h>
    44 #include <caf/caftypes.h>
    44 #include <caf/caftypes.h>
    45 
    45 
    46 #include "drmrightsmgrappui.h"
    46 #include "DRMRightsMgrAppUi.h"
    47 #include "drmrightsmgrdetailsview.h"
    47 #include "DRMRightsMgrDetailsView.h"
    48 #include "drmrightsmgrdocument.h"
    48 #include "DRMRightsMgrDocument.h"
    49 #include "drmcommonutilities.h"
    49 #include "DRMCommonUtilities.h"
    50 #include "drmuilogger.h"
    50 #include "DRMUILogger.h"
    51 #include "drmrightsmanagerprivatecrkeys.h"
    51 #include "DRMRightsManagerPrivateCRKeys.h"
    52 #include "drmclockclient.h"
    52 #include "DRMClockClient.h"
    53 #include "drmutilityinternaltypes.h"
    53 #include "drmutilityinternaltypes.h"
    54 
    54 
    55 #include "oma1dcf.h"
    55 #include "Oma1Dcf.h"
    56 #include "oma2dcf.h"
    56 #include "oma2dcf.h"
    57 // CONSTANTS
    57 // CONSTANTS
    58 _LIT8( Kflk, "flk:" );
    58 _LIT8( Kflk, "flk:" );
    59 _LIT8( Kldf, "ldf:" );
    59 _LIT8( Kldf, "ldf:" );
    60 
    60 
    81 // ---------------------------------------------------------
    81 // ---------------------------------------------------------
    82 //
    82 //
    83 void CDRMRightsMgrAppUi::ConstructL()
    83 void CDRMRightsMgrAppUi::ConstructL()
    84     {
    84     {
    85     CLOG_WRITE( "-->ConstructL" );
    85     CLOG_WRITE( "-->ConstructL" );
    86     
    86 
    87     iCoeEnv->AddForegroundObserverL( *this );
    87     iCoeEnv->AddForegroundObserverL( *this );
    88     
    88 
    89     CDRMRightsMgrDetailsView* detailsView( NULL );
    89     CDRMRightsMgrDetailsView* detailsView( NULL );
    90 
    90 
    91     BaseConstructL( EAknEnableSkin | EAppOrientationAutomatic | 
    91     BaseConstructL( EAknEnableSkin | EAppOrientationAutomatic |
    92     	EAknEnableMSK | EAknSingleClickCompatible  );
    92         EAknEnableMSK | EAknSingleClickCompatible  );
    93 
    93 
    94     User::LeaveIfError( iRightsClient.Connect() );
    94     User::LeaveIfError( iRightsClient.Connect() );
    95     iDRMCommon = DRMCommon::NewL();
    95     iDRMCommon = DRMCommon::NewL();
    96     if ( !iDRMCommon )
    96     if ( !iDRMCommon )
    97         {
    97         {
   119 // CDRMRightsMgrAppUi::~CDRMRightsMgrAppUi
   119 // CDRMRightsMgrAppUi::~CDRMRightsMgrAppUi
   120 // ----------------------------------------------------
   120 // ----------------------------------------------------
   121 //
   121 //
   122 CDRMRightsMgrAppUi::~CDRMRightsMgrAppUi()
   122 CDRMRightsMgrAppUi::~CDRMRightsMgrAppUi()
   123     {
   123     {
   124     
   124 
   125     iCoeEnv->RemoveForegroundObserver( *this );
   125     iCoeEnv->RemoveForegroundObserver( *this );
   126     
   126 
   127     delete iWaitDialog;
   127     delete iWaitDialog;
   128 
   128 
   129     delete iDRMCommon;
   129     delete iDRMCommon;
   130 
   130 
   131     iRightsClient.Close();
   131     iRightsClient.Close();
   132 
   132 
   133     if ( iStartEmbedded && iDoorObserver )
   133     if ( iStartEmbedded && iDoorObserver )
   134         {
   134         {
   135         iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::ENoChanges );
   135         iDoorObserver->NotifyExit( MApaEmbeddedDocObserver::ENoChanges );
   136         }
   136         }
   137         
   137 
   138     if ( iContentURI )
   138     if ( iContentURI )
   139         {
   139         {
   140         delete iContentURI;
   140         delete iContentURI;
   141         }
   141         }
   142         
   142 
   143     }
   143     }
   144 
   144 
   145 
   145 
   146 // ---------------------------------------------------------
   146 // ---------------------------------------------------------
   147 // CDRMRightsMgrAppUi::HandleKeyEventL
   147 // CDRMRightsMgrAppUi::HandleKeyEventL
   198                                                const TUint32 aLocalID,
   198                                                const TUint32 aLocalID,
   199                                                const TBool aEmbedded,
   199                                                const TBool aEmbedded,
   200                                                const TInt aDrmScheme )
   200                                                const TInt aDrmScheme )
   201     {
   201     {
   202 
   202 
   203     // Store the content related information when the details view 
   203     // Store the content related information when the details view
   204     // is to be shown for the first time so that the information will be
   204     // is to be shown for the first time so that the information will be
   205     // available for details view refreshing in the future.
   205     // available for details view refreshing in the future.
   206     if ( !iContentURI )
   206     if ( !iContentURI )
   207         {
   207         {
   208         iDrmScheme = aDrmScheme;
   208         iDrmScheme = aDrmScheme;
   209         iLocalID = aLocalID;
   209         iLocalID = aLocalID;
   210         iContentURI = aContentURI.AllocL();
   210         iContentURI = aContentURI.AllocL();
   211         }
   211         }
   212     
   212 
   213     // For storing WM DRM rights information
   213     // For storing WM DRM rights information
   214     ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo> array;
   214     ContentAccess::RStreamablePtrArray<ContentAccess::CRightsInfo> array;
   215     CleanupClosePushL( array );
   215     CleanupClosePushL( array );
   216 
   216 
   217     TInt status( KErrCANoRights );
   217     TInt status( KErrCANoRights );
   229     // Check the status of rights. Currently supports OMA and WM DRM.
   229     // Check the status of rights. Currently supports OMA and WM DRM.
   230     switch ( iDrmScheme )
   230     switch ( iDrmScheme )
   231         {
   231         {
   232         case EDrmSchemeOmaDrm:
   232         case EDrmSchemeOmaDrm:
   233             CheckOmaDrmRightsL( aContentURI, aLocalID, rights, status );
   233             CheckOmaDrmRightsL( aContentURI, aLocalID, rights, status );
   234             if ( status ) 
   234             if ( status < 0 )
   235                 {
   235                 {
   236                 rights = NULL;
   236                 rights = NULL;
   237                 }
   237                 }
   238             break;
   238             break;
   239 
   239 
   329                                        TDes& aItemName,
   329                                        TDes& aItemName,
   330                                        const TDesC8& aID,
   330                                        const TDesC8& aID,
   331                                        const TBool aIsGroup )
   331                                        const TBool aIsGroup )
   332     {
   332     {
   333     CDcfCommon* dcf = NULL;
   333     CDcfCommon* dcf = NULL;
       
   334     HBufC8* buffer( NULL );
   334     TBool getName = ETrue;
   335     TBool getName = ETrue;
   335     TParse parse;
   336     TParse parse;
   336 
   337 
   337     // don't get the name if dealing with a file from a group
   338     // don't get the name if dealing with a file from a group
   338     if ( !aIsGroup )
   339     if ( !aIsGroup )
   354         HBufC* itemNameBuf = NULL;
   355         HBufC* itemNameBuf = NULL;
   355         TInt err = iRightsClient.GetName( aID, itemNameBuf );
   356         TInt err = iRightsClient.GetName( aID, itemNameBuf );
   356 
   357 
   357         if ( err == KErrNotFound || itemNameBuf->Length() == 0 )
   358         if ( err == KErrNotFound || itemNameBuf->Length() == 0 )
   358             {
   359             {
   359             if ( aIsGroup )
   360             // Do not show name if group rights or forward lock
   360                 {
   361             if ( !aIsGroup )
   361                 aItemName = aFullName;
   362                 {
       
   363                 if ( ( iRightsClient.ForwardLockURI( buffer ) ==
       
   364                         KErrNone ) && buffer )
       
   365                     {
       
   366 
       
   367                     // Not forward lock
       
   368                     if ( aID.Compare( *buffer ) != 0 )
       
   369                         {
       
   370                         parse.Set( aFullName, NULL, NULL );
       
   371                         aItemName = parse.NameAndExt();
       
   372                         }
       
   373                     delete buffer;
       
   374                     buffer = NULL;
       
   375 
       
   376                     }
       
   377                 else
       
   378                     {
       
   379                     parse.Set( aFullName, NULL, NULL );
       
   380                     aItemName = parse.NameAndExt();
       
   381                     }
       
   382                 }
       
   383             }
       
   384         else if ( err == KErrNone )
       
   385             {
       
   386             // Forward lock or combined delivery
       
   387             // If forward lock, do not show name
       
   388             if ( iRightsClient.ForwardLockURI( buffer ) == KErrNone &&
       
   389                     buffer )
       
   390                 {
       
   391                 if ( aID.Compare( *buffer ) != 0 )
       
   392                     {
       
   393                     // Combined delivery
       
   394                     aItemName = *itemNameBuf;
       
   395                     }
       
   396                 delete buffer;
   362                 }
   397                 }
   363             else
   398             else
   364                 {
   399                 {
   365                 parse.Set( aFullName, NULL, NULL );
   400                 // Do not show name if having group rights
   366                 aItemName = parse.NameAndExt();
   401                 if ( !aIsGroup )
   367                 }
   402                     {
   368             }
   403                     aItemName = *itemNameBuf;
   369         else if ( err == KErrNone )
   404                     }
   370             {
   405                 }
   371             aItemName = *itemNameBuf;
       
   372             }
   406             }
   373         else
   407         else
   374             {
   408             {
   375             User::Leave( err );
   409             User::Leave( err );
   376             }
   410             }
   521     {
   555     {
   522     // Refresh details view when the details view is returned
   556     // Refresh details view when the details view is returned
   523     // from the background to the foreground.
   557     // from the background to the foreground.
   524     if ( iForegroundHasBeenActive && iContentURI )
   558     if ( iForegroundHasBeenActive && iContentURI )
   525         {
   559         {
   526         StartOnlyForDetailsL( iContentURI->Des(), iLocalID, 
   560         StartOnlyForDetailsL( iContentURI->Des(), iLocalID,
   527             iStartEmbedded, iDrmScheme );
   561             iStartEmbedded, iDrmScheme );
   528         }
   562         }
   529     }
   563     }
   530 
   564 
   531 
   565 
   718 
   752 
   719             CDcfEntry* entry = dcfRep->NextL();
   753             CDcfEntry* entry = dcfRep->NextL();
   720             if ( entry )
   754             if ( entry )
   721                 {
   755                 {
   722                 fullName = entry->FileName();
   756                 fullName = entry->FileName();
       
   757                 SetSelectedItemFullName( fullName );
       
   758 
       
   759                 TFileName itemName;
       
   760 
       
   761                 if ( entry->GroupId().Length() > 0 )
       
   762                     {
       
   763                     GetItemNameL( fullName, itemName, aContentURI, ETrue );
       
   764                     }
       
   765                 else
       
   766                     {
       
   767                     GetItemNameL( fullName, itemName, aContentURI, EFalse );
       
   768                     }
       
   769 
   723                 delete entry;
   770                 delete entry;
   724                 SetSelectedItemFullName( fullName );
   771 
   725 
       
   726                 TFileName itemName;
       
   727                 GetItemNameL( fullName, itemName, aContentURI, EFalse );
       
   728                 SetSelectedItemName( itemName );
   772                 SetSelectedItemName( itemName );
   729 
   773 
   730                 if ( GetItemDataL( fullName, aContentURI, listable,
   774                 if ( GetItemDataL( fullName, aContentURI, listable,
   731                     sendable ) == KErrNone )
   775                     sendable ) == KErrNone )
   732                     {
   776                     {
   736             }
   780             }
   737         else // No related media was found
   781         else // No related media was found
   738             {
   782             {
   739             SetSelectedItemFullName( KNullDesC );
   783             SetSelectedItemFullName( KNullDesC );
   740             TFileName itemName;
   784             TFileName itemName;
       
   785             // Treat in GetItemNameL as if having group rights
   741             GetItemNameL( KNullDesC, itemName, aContentURI, ETrue );
   786             GetItemNameL( KNullDesC, itemName, aContentURI, ETrue );
   742             SetSelectedItemName( itemName );
   787             SetSelectedItemName( itemName );
   743 
   788 
   744             SetSelectedContentCanBeSent( EFalse );
   789             SetSelectedContentCanBeSent( EFalse );
   745             }
   790             }
   751 
   796 
   752     if ( aLocalID > 0 )
   797     if ( aLocalID > 0 )
   753         {
   798         {
   754         aStatus = iDRMCommon->GetSingleRightsObject( aContentURI,
   799         aStatus = iDRMCommon->GetSingleRightsObject( aContentURI,
   755             aLocalID, aRights );
   800             aLocalID, aRights );
   756         }
   801         if ( aStatus )
   757         else
   802             {
       
   803             aRights = NULL;
       
   804             }
       
   805         }
       
   806     else
   758         {
   807         {
   759         aStatus = iDRMCommon->GetActiveRights( aContentURI, 0, aRights );
   808         aStatus = iDRMCommon->GetActiveRights( aContentURI, 0, aRights );
   760         }
       
   761     if ( aStatus )
       
   762         {
       
   763         aRights = NULL;
       
   764         }
   809         }
   765 
   810 
   766     CheckIndividualConstraint( aContentURI, individualConstraint, usageAllowed );
   811     CheckIndividualConstraint( aContentURI, individualConstraint, usageAllowed );
   767     SetSelectedIndividualConstraint( individualConstraint );
   812     SetSelectedIndividualConstraint( individualConstraint );
   768     SetSelectedUsageAllowed( usageAllowed );
   813     SetSelectedUsageAllowed( usageAllowed );