commondrm/drmrightsmanagerui/src/DRMRightsMgrDetailsContainer.cpp
changeset 0 95b198f216e5
child 17 e16d72588c28
child 23 493788a4a8a4
equal deleted inserted replaced
-1:000000000000 0:95b198f216e5
       
     1 /*
       
     2 * Copyright (c) 2003-2009 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:  Implementation of CDRMRightsMgrDetailsContainer class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <stringloader.h>
       
    21 #include <aknlists.h>
       
    22 #include <cdirectorylocalizer.h>
       
    23 #include <drmrights.h>
       
    24 
       
    25 #include <drmrightsmanager.rsg>
       
    26 
       
    27 #include "drmrightsmgrdetailscontainer.h"
       
    28 #include "drmcommonutilities.h"
       
    29 #include "drmutilityinternaltypes.h"
       
    30 
       
    31 // CONSTANTS
       
    32 LOCAL_C const TInt KMsgLineLength = 100;
       
    33 
       
    34 
       
    35 // ================= MEMBER FUNCTIONS =======================
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // CDRMRightsMgrDetailsContainer::CDRMRightsMgrDetailsContainer
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 CDRMRightsMgrDetailsContainer::CDRMRightsMgrDetailsContainer(
       
    42                                                         TDetails& aDetails,
       
    43                                                         TBool aStartEmbedded )
       
    44 : iDetails( aDetails ),
       
    45   iStartEmbedded( aStartEmbedded ),
       
    46   iListBox( NULL )
       
    47     {
       
    48     }
       
    49 
       
    50 
       
    51 // ---------------------------------------------------------
       
    52 // CDRMRightsMgrDetailsContainer::ConstructL
       
    53 // ---------------------------------------------------------
       
    54 //
       
    55 void CDRMRightsMgrDetailsContainer::ConstructL( const TRect& aRect )
       
    56     {
       
    57     iListBox = new( ELeave )CAknDoubleStyleListBox;     // Creates new object
       
    58 
       
    59     CreateWindowL(); //makes the control a window-owning control
       
    60 
       
    61     ConstructListBoxL();
       
    62 
       
    63     if ( iListBox )
       
    64         {
       
    65         // set iListBox to be contained in this container
       
    66         iListBox->SetContainerWindowL( *this );
       
    67         SetScrollBarL();
       
    68         }
       
    69 
       
    70     SetRect( aRect );
       
    71     ActivateL();
       
    72 
       
    73     SetIconsL();
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // CDRMRightsMgrDetailsContainer::~CDRMRightsMgrDetailsContainer
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 CDRMRightsMgrDetailsContainer::~CDRMRightsMgrDetailsContainer()
       
    81     {
       
    82     delete iListBox;
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------
       
    86 // CDRMRightsMgrDetailsContainer::SizeChanged
       
    87 // ---------------------------------------------------------
       
    88 //
       
    89 void CDRMRightsMgrDetailsContainer::SizeChanged()
       
    90    {
       
    91     if ( iListBox )
       
    92         {
       
    93         iListBox->SetRect( Rect() ); // Sets rectangle of listbox.
       
    94         }
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // CDRMRightsMgrDetailsContainer::CountComponentControls
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 TInt CDRMRightsMgrDetailsContainer::CountComponentControls() const
       
   102     {
       
   103     TInt count( 0 );
       
   104 
       
   105     if ( iListBox )
       
   106         {
       
   107         count++;
       
   108         }
       
   109 
       
   110     return count; // Returns number of controls inside this container.
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 // CDRMRightsMgrDetailsContainer::ComponentControl
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 CCoeControl* CDRMRightsMgrDetailsContainer::ComponentControl( TInt aIndex ) const
       
   118     {
       
   119     switch ( aIndex )
       
   120         {
       
   121         case 0:
       
   122             return iListBox;    // Returns the pointer to listbox object.
       
   123         default:
       
   124             return NULL;        // Exception : Returns NULL.
       
   125         }
       
   126     }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CDRMRightsMgrDetailsContainer::HandleResourceChange
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 void CDRMRightsMgrDetailsContainer::HandleResourceChange( TInt aType )
       
   133     {
       
   134     CCoeControl::HandleResourceChange( aType );
       
   135     }
       
   136 
       
   137 // ---------------------------------------------------------
       
   138 // CDRMRightsMgrDetailsContainer::SetScrollBarL
       
   139 // ---------------------------------------------------------
       
   140 //
       
   141 void CDRMRightsMgrDetailsContainer::SetScrollBarL()
       
   142     {
       
   143     // Update scrollbar in order to draw correct scroll bar.
       
   144     TInt pos( iListBox->View()->CurrentItemIndex() );
       
   145     if ( iListBox->ScrollBarFrame() )
       
   146         {
       
   147         iListBox->ScrollBarFrame()->MoveVertThumbTo( pos );
       
   148         }
       
   149 
       
   150     iListBox->CreateScrollBarFrameL( ETrue );
       
   151     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   152                                                 CEikScrollBarFrame::EOff,
       
   153                                                 CEikScrollBarFrame::EAuto );
       
   154     }
       
   155 
       
   156 
       
   157 // ---------------------------------------------------------
       
   158 // CDRMRightsMgrDetailsContainer::OfferKeyEventL
       
   159 // ---------------------------------------------------------
       
   160 //
       
   161 TKeyResponse CDRMRightsMgrDetailsContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   162                                                 TEventCode aType )
       
   163     {
       
   164     if ( aType != EEventKey ) // Is not key event?
       
   165         {
       
   166         return EKeyWasNotConsumed;
       
   167         }
       
   168     else if ( aKeyEvent.iCode == EKeyLeftArrow ||
       
   169               aKeyEvent.iCode == EKeyRightArrow )
       
   170         {
       
   171         return EKeyWasConsumed;
       
   172         }
       
   173     else
       
   174         {
       
   175         return iListBox ? iListBox->OfferKeyEventL( aKeyEvent, aType ) :
       
   176                           EKeyWasNotConsumed;
       
   177         }
       
   178     }
       
   179 
       
   180 // ---------------------------------------------------------
       
   181 // CDRMRightsMgrDetailsContainer::Draw
       
   182 // ---------------------------------------------------------
       
   183 //
       
   184 void CDRMRightsMgrDetailsContainer::Draw( const TRect& /*aRect*/ ) const
       
   185     {
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------
       
   189 // CDRMRightsMgrDetailsContainer::HandleControlEventL
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 void CDRMRightsMgrDetailsContainer::HandleControlEventL( CCoeControl* /*aControl*/,
       
   193                                              TCoeEvent /*aEventType*/ )
       
   194     {
       
   195     }
       
   196 
       
   197 // ---------------------------------------------------------
       
   198 // CDRMRightsMgrDetailsContainer::SetIconsL
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 void CDRMRightsMgrDetailsContainer::SetIconsL()
       
   202     {
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------
       
   206 // CDRMRightsMgrDetailsContainer::FocusChanged
       
   207 // ---------------------------------------------------------
       
   208 //
       
   209 void CDRMRightsMgrDetailsContainer::FocusChanged(TDrawNow /*aDrawNow*/)
       
   210    {
       
   211     if ( iListBox )
       
   212         {
       
   213         iListBox->SetFocus( IsFocused() );
       
   214         }
       
   215     }
       
   216 
       
   217 // ---------------------------------------------------------
       
   218 // CDRMRightsMgrDetailsContainer::ConstructListBoxL
       
   219 // ---------------------------------------------------------
       
   220 //
       
   221 void CDRMRightsMgrDetailsContainer::ConstructListBoxL()
       
   222     {
       
   223     iListBox->ConstructL( this, EAknListBoxViewerFlags /* | 
       
   224         EAknListBoxItemSpecificMenuDisabled */ );
       
   225 
       
   226     if ( iStartEmbedded )
       
   227         {
       
   228         iListBox->View()->SetListEmptyTextL( KNullDesC );
       
   229         }
       
   230     else
       
   231         {
       
   232         UpdateListBoxContentL( iDetails );        // Updates content
       
   233         }
       
   234     }
       
   235 
       
   236 // ---------------------------------------------------------
       
   237 // CDRMRightsMgrDetailsContainer::UpdateListBoxContentL
       
   238 // ---------------------------------------------------------
       
   239 //
       
   240 void CDRMRightsMgrDetailsContainer::UpdateListBoxContentL( TDetails& aDetails )
       
   241     {
       
   242     CDesCArray* items = ( CDesCArray* )( iListBox->Model()->ItemTextArray() );
       
   243     items->Reset();
       
   244 
       
   245     TInt rightsCount = aDetails.iRights->Count();
       
   246 
       
   247     if ( rightsCount )
       
   248         {
       
   249         // Add only the details of the currently active RO, although the file
       
   250         // could be related to multiple ROs.
       
   251         AddRightsDetailsL( aDetails.iActiveROindex, aDetails, items );
       
   252         }
       
   253     else
       
   254         {
       
   255         // WMDRM agent returned an empty array of rights. Add the status line
       
   256         // of rights.
       
   257         if ( aDetails.iDrmScheme == EDrmSchemeWmDrm )
       
   258             {
       
   259             AddStatusLineL( aDetails.iRights->At( 0 ).iStatus, items );
       
   260             }
       
   261         }
       
   262 
       
   263     // Content sending
       
   264     if ( aDetails.iDrmScheme != EDrmSchemeUnknownDrm )
       
   265         {
       
   266         AddContentSendingLineL( aDetails.iContentCanBeSent, items );
       
   267         }
       
   268 
       
   269     // Individual constraint
       
   270     if ( aDetails.iIndividualConstraint )
       
   271         {
       
   272         AddContentUseLineL( aDetails.iUsageAllowed, items );
       
   273         }
       
   274 
       
   275     iListBox->HandleItemAdditionL();
       
   276     }
       
   277 
       
   278 
       
   279 // ---------------------------------------------------------
       
   280 // CDRMRightsMgrDetailsContainer::HandleListBoxEventL
       
   281 // ---------------------------------------------------------
       
   282 //
       
   283 void CDRMRightsMgrDetailsContainer::HandleListBoxEventL(
       
   284                     CEikListBox* /*aListBox*/, TListBoxEvent /*aEventType*/ )
       
   285     {
       
   286     }
       
   287 
       
   288 
       
   289 // ---------------------------------------------------------
       
   290 // CDRMRightsMgrDetailsContainer::AddRightsDetailsL
       
   291 // ---------------------------------------------------------
       
   292 //
       
   293 void CDRMRightsMgrDetailsContainer::AddRightsDetailsL( TInt aNumberOfKey,
       
   294                                                        TDetails& aDetails,
       
   295                                                        CDesCArray* aItems )
       
   296     {
       
   297 
       
   298     if ( aNumberOfKey < aDetails.iRights->Count() && aNumberOfKey >= 0 )
       
   299         {
       
   300         // Status of Rights
       
   301         AddStatusLineL( aDetails.iRights->At( aNumberOfKey ).iStatus,
       
   302             aItems );
       
   303 
       
   304         // Play Rights
       
   305         AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iPlayConstraint,
       
   306             aItems,
       
   307             aDetails.iDrmScheme,
       
   308             ContentAccess::EPlay );
       
   309 
       
   310         // Display Rights
       
   311         AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iDisplayConstraint,
       
   312             aItems,
       
   313             aDetails.iDrmScheme,
       
   314             ContentAccess::EView );
       
   315 
       
   316         // Print Rights
       
   317         AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iPrintConstraint,
       
   318             aItems,
       
   319             aDetails.iDrmScheme,
       
   320             ContentAccess::EPrint );
       
   321 
       
   322         // Execute Rights
       
   323         AddRightsLineL( aDetails.iRights->At( aNumberOfKey ).iExecuteConstraint,
       
   324             aItems,
       
   325             aDetails.iDrmScheme,
       
   326             ContentAccess::EExecute );
       
   327 
       
   328         }
       
   329     }
       
   330 
       
   331 // ---------------------------------------------------------
       
   332 // CDRMRightsMgrDetailsContainer::AddStatusLineL
       
   333 // ---------------------------------------------------------
       
   334 //
       
   335 void CDRMRightsMgrDetailsContainer::AddStatusLineL( TDRMUIRightsStatus aStatus,
       
   336                                                     CDesCArray* aItems )
       
   337     {
       
   338     TBuf<KMsgLineLength> msgLine;
       
   339     HBufC* stringHolder;
       
   340 
       
   341 
       
   342     stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_STATUS,
       
   343                                             iEikonEnv );
       
   344 
       
   345     msgLine.Zero();
       
   346     msgLine.Append( '\t' );
       
   347     msgLine.Append( *stringHolder );
       
   348 
       
   349     delete stringHolder;
       
   350     stringHolder = NULL;
       
   351 
       
   352     msgLine.Append( '\t' );
       
   353 
       
   354     TInt resourceId;
       
   355     switch( aStatus )
       
   356         {
       
   357         case EDRMUIStatusInvalid:
       
   358             resourceId = R_QTN_DRM_DETAILS_NO_LICENCE_AVAILABLE;
       
   359             break;
       
   360 
       
   361         case EDRMUIStatusValid:
       
   362             resourceId = R_QTN_DRM_DETAILS_VALID;
       
   363             break;
       
   364 
       
   365         case EDRMUIStatusFuture:
       
   366             resourceId = R_QTN_DRM_DETAILS_NOT_VALID_YET;
       
   367             break;
       
   368 
       
   369         case EDRMUIStatusExpired:
       
   370             resourceId = R_QTN_DRM_DETAILS_NO_LICENCE_AVAILABLE;
       
   371             break;
       
   372 
       
   373         default:
       
   374             resourceId = 0;
       
   375             break;
       
   376         }
       
   377 
       
   378     if ( resourceId )
       
   379         {
       
   380         stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
       
   381         msgLine.Append( *stringHolder );
       
   382 
       
   383         delete stringHolder;
       
   384         stringHolder = NULL;
       
   385         }
       
   386 
       
   387     if ( aItems )
       
   388         {
       
   389         aItems->AppendL( msgLine );
       
   390         }
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------
       
   394 // CDRMRightsMgrDetailsContainer::AddContentSendingLineL
       
   395 // ---------------------------------------------------------
       
   396 //
       
   397 void CDRMRightsMgrDetailsContainer::AddContentSendingLineL(
       
   398                                                     TBool aContentCanBeSent,
       
   399                                                     CDesCArray* aItems )
       
   400     {
       
   401     TBuf<KMsgLineLength> msgLine;
       
   402 
       
   403     msgLine.Zero();
       
   404     msgLine.Append( '\t' );
       
   405     HBufC* stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_SENDING,
       
   406                                                iEikonEnv );
       
   407     msgLine.Append( *stringHolder );
       
   408 
       
   409     delete stringHolder;
       
   410     stringHolder = NULL;
       
   411 
       
   412     msgLine.Append( '\t' );
       
   413     stringHolder = StringLoader::LoadL( aContentCanBeSent ?
       
   414                                         R_QTN_DRM_MGR_DET_ALLOWED :
       
   415                                         R_QTN_DRM_MGR_DET_FORBID, iEikonEnv );
       
   416     msgLine.Append( *stringHolder );
       
   417 
       
   418     delete stringHolder;
       
   419     stringHolder = NULL;
       
   420 
       
   421     if ( aItems )
       
   422         {
       
   423         aItems->AppendL( msgLine );
       
   424         }
       
   425     }
       
   426 
       
   427 // ---------------------------------------------------------
       
   428 // CDRMRightsMgrDetailsContainer::AddContentUseLineL
       
   429 // ---------------------------------------------------------
       
   430 //
       
   431 void CDRMRightsMgrDetailsContainer::AddContentUseLineL( TBool aUsageAllowed,
       
   432                                                         CDesCArray* aItems )
       
   433     {
       
   434     TBuf<KMsgLineLength> msgLine;
       
   435 
       
   436     msgLine.Zero();
       
   437     msgLine.Append( '\t' );
       
   438     HBufC* stringHolder = StringLoader::LoadL( R_QTN_DRM_DET_CONTENT_USE,
       
   439                                                iEikonEnv );
       
   440     msgLine.Append( *stringHolder );
       
   441 
       
   442     delete stringHolder;
       
   443     stringHolder = NULL;
       
   444 
       
   445     msgLine.Append( '\t' );
       
   446     stringHolder = StringLoader::LoadL( aUsageAllowed ?
       
   447                                         R_QTN_DRM_DET_SIM_ALLOWED :
       
   448                                         R_QTN_DRM_DET_SIM_NOT_ALLOWED, iEikonEnv );
       
   449     msgLine.Append( *stringHolder );
       
   450 
       
   451     delete stringHolder;
       
   452     stringHolder = NULL;
       
   453 
       
   454     if ( aItems )
       
   455         {
       
   456         aItems->AppendL( msgLine );
       
   457         }
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------
       
   461 // CDRMRightsMgrDetailsContainer::AddRightsLineL
       
   462 // ---------------------------------------------------------
       
   463 //
       
   464 void CDRMRightsMgrDetailsContainer::AddRightsLineL(
       
   465                                             CDRMRightsConstraints* aConstraint,
       
   466                                             CDesCArray* aItems,
       
   467                                             const TInt aDrmScheme,
       
   468                                             const TUint32& aIntent )
       
   469     {
       
   470     if ( !aConstraint )
       
   471         {
       
   472         return;
       
   473         }
       
   474     else if ( aConstraint->FullRights() )
       
   475         {
       
   476         // Full Rights
       
   477         AddUsageRightsL( aItems, aIntent );
       
   478         }
       
   479     else
       
   480         {
       
   481         TUint32 counter( 0 );
       
   482         TUint32 originalCounter( 0 );
       
   483         TTime startDateTime( 0 );
       
   484         TTime endDateTime( 0 );
       
   485         TTimeIntervalSeconds interval( 0 );
       
   486 
       
   487         if ( aConstraint->GetCounters( counter, originalCounter ) == KErrNone )
       
   488             {
       
   489             // RO has a count constraint
       
   490             AddUsageTimesLeftL( counter, aItems, aIntent );
       
   491             }
       
   492 
       
   493         if ( aDrmScheme == EDrmSchemeOmaDrm )
       
   494             {
       
   495             // For OMA DRM only
       
   496             CDRMConstraint& drmConstraint = aConstraint->GetConstraint();
       
   497             if ( drmConstraint.iActiveConstraints & EConstraintTimedCounter )
       
   498                 {
       
   499                 // RO has Timed Counter constraint
       
   500                 AddUsageTimesLeftL( drmConstraint.iTimedCounter, aItems,
       
   501                                     aIntent );
       
   502                 }
       
   503             }
       
   504 
       
   505         if ( aConstraint->GetInterval( interval ) == KErrNone )
       
   506             {
       
   507 
       
   508             // RO has an interval constraint
       
   509             // WM DRM duration rights are mapped to the interval constraint
       
   510             // (which is not activated).
       
   511             TTime intervalStart( 0 );
       
   512 
       
   513             // If the file has an interval constraint which is activated,
       
   514             // do not add information about the interval to the details view.
       
   515             if ( aConstraint->GetIntervalStart( intervalStart ) != KErrNone )
       
   516                 {
       
   517                 // File has an interval constraint which is not activated.
       
   518                 AddUsageTimeLeftL( interval, aItems, EFalse, aIntent );
       
   519                 }
       
   520             }
       
   521 
       
   522         if ( aConstraint->GetStartTime( startDateTime ) == KErrNone )
       
   523             {
       
   524             // RO has a start time constraint
       
   525             AddRightsValidFromL( startDateTime, aItems, aIntent );
       
   526             }
       
   527 
       
   528         if ( aConstraint->GetEndTime( endDateTime ) == KErrNone )
       
   529             {
       
   530             // RO has an expiring time constraint
       
   531             AddRightsValidUntilL( endDateTime, aItems, aIntent );
       
   532             }
       
   533 
       
   534         if ( aDrmScheme == EDrmSchemeOmaDrm )
       
   535             {
       
   536             // For OMA DRM only
       
   537             CDRMConstraint& drmConstraint = aConstraint->GetConstraint();
       
   538 
       
   539             if ( drmConstraint.iActiveConstraints & EConstraintAccumulated )
       
   540                 {
       
   541                 TTimeIntervalSeconds accInterval(
       
   542                     drmConstraint.iAccumulatedTime );
       
   543 
       
   544                 // RO has Accumulated Time constraint
       
   545                 AddUsageTimeLeftL( accInterval, aItems, ETrue, aIntent );
       
   546                 }
       
   547             }
       
   548 
       
   549         }
       
   550 
       
   551     }
       
   552 
       
   553 // ---------------------------------------------------------
       
   554 // CDRMRightsMgrDetailsContainer::AddUsageRightsL
       
   555 // ---------------------------------------------------------
       
   556 //
       
   557 void CDRMRightsMgrDetailsContainer::AddUsageRightsL( CDesCArray* aItems,
       
   558                                                      const TUint32& aIntent)
       
   559     {
       
   560     TBuf<KMaxFileName*2> msgLine;
       
   561     msgLine.Zero();
       
   562     msgLine.Append( '\t' );
       
   563 
       
   564     // Usage Rights
       
   565     // Check the intent and process the corresponding string.
       
   566     TInt resourceId( 0 );
       
   567     TInt resourceIdUnlimited( 0 );
       
   568     switch ( aIntent )
       
   569         {
       
   570         case ContentAccess::EPlay:
       
   571             resourceId = R_QTN_DRM_DETAILS_PLAYS_LEFT;
       
   572             resourceIdUnlimited = R_QTN_DRM_MGR_DET_PL_UNLIMITED;
       
   573             break;
       
   574 
       
   575         case ContentAccess::EView:
       
   576             resourceId = R_QTN_DRM_DETAILS_VIEWS_LEFT;
       
   577             resourceIdUnlimited = R_QTN_DRM_MGR_DET_VI_UNLIMITED;
       
   578             break;
       
   579 
       
   580         case ContentAccess::EPrint:
       
   581             resourceId = R_QTN_DRM_DETAILS_PRINTS_LEFT;
       
   582             resourceIdUnlimited = R_QTN_DRM_MGR_DET_PR_UNLIMITED;
       
   583             break;
       
   584 
       
   585         case ContentAccess::EExecute:
       
   586             resourceId = R_QTN_DRM_DETAILS_EXEC_TIMES;
       
   587             resourceIdUnlimited = R_QTN_DRM_MGR_DET_EX_UNLIMITED;
       
   588             break;
       
   589 
       
   590         default:
       
   591             User::Leave( KErrArgument );
       
   592             break;
       
   593         }
       
   594 
       
   595     HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
       
   596     msgLine.Append( *stringHolder );
       
   597 
       
   598     delete stringHolder;
       
   599     stringHolder = NULL;
       
   600 
       
   601     msgLine.Append( '\t' );
       
   602 
       
   603     // Unlimited
       
   604     stringHolder = StringLoader::LoadL( resourceIdUnlimited, iEikonEnv );
       
   605     msgLine.Append( *stringHolder );
       
   606 
       
   607     delete stringHolder;
       
   608     stringHolder = NULL;
       
   609 
       
   610     if ( aItems )
       
   611         {
       
   612         aItems->AppendL( msgLine );
       
   613         }
       
   614     }
       
   615 
       
   616 
       
   617 // ---------------------------------------------------------
       
   618 // CDRMRightsMgrDetailsContainer::AddUsageTimesLeftL
       
   619 // ---------------------------------------------------------
       
   620 //
       
   621 void CDRMRightsMgrDetailsContainer::AddUsageTimesLeftL( TUint32 aCounter,
       
   622                                                 CDesCArray* aItems,
       
   623                                                 const TUint32& aIntent )
       
   624     {
       
   625     TBuf<KMaxFileName*2> msgLine;
       
   626     msgLine.Zero();
       
   627     msgLine.Append( '\t' );
       
   628 
       
   629     // Usage times left
       
   630     // Check the intent and process the corresponding string.
       
   631     TInt resourceId( 0 );
       
   632     switch ( aIntent )
       
   633         {
       
   634         case ContentAccess::EPlay:
       
   635             resourceId = R_QTN_DRM_DETAILS_PLAYS_LEFT;
       
   636             break;
       
   637 
       
   638         case ContentAccess::EView:
       
   639             resourceId = R_QTN_DRM_DETAILS_VIEWS_LEFT;
       
   640             break;
       
   641 
       
   642         case ContentAccess::EPrint:
       
   643             resourceId = R_QTN_DRM_DETAILS_PRINTS_LEFT;
       
   644             break;
       
   645 
       
   646         case ContentAccess::EExecute:
       
   647             resourceId = R_QTN_DRM_DETAILS_EXEC_TIMES;
       
   648             break;
       
   649 
       
   650         default:
       
   651             User::Leave( KErrArgument );
       
   652             break;
       
   653         }
       
   654 
       
   655     HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
       
   656 
       
   657     msgLine.Append( *stringHolder );
       
   658 
       
   659     delete stringHolder;
       
   660     stringHolder = NULL;
       
   661 
       
   662     msgLine.Append( '\t' );
       
   663 
       
   664     if ( aCounter == 1 )
       
   665         {
       
   666         stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_1_TIME,
       
   667                                             iEikonEnv );
       
   668         }
       
   669     else
       
   670         {
       
   671         stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_N_TIMES,
       
   672                                             aCounter, iEikonEnv );
       
   673         }
       
   674 
       
   675     msgLine.Append( *stringHolder );
       
   676 
       
   677     delete stringHolder;
       
   678     stringHolder = NULL;
       
   679 
       
   680     if ( aItems )
       
   681         {
       
   682         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
       
   683         aItems->AppendL( msgLine );
       
   684         }
       
   685     }
       
   686 
       
   687 // ---------------------------------------------------------
       
   688 // CDRMRightsMgrDetailsContainer::AddUsageTimeLeftL
       
   689 // ---------------------------------------------------------
       
   690 //
       
   691 void CDRMRightsMgrDetailsContainer::AddUsageTimeLeftL(
       
   692                                         const TTimeIntervalSeconds& aInterval,
       
   693                                         CDesCArray* aItems,
       
   694                                         const TBool aIsAccumulatedTime,
       
   695                                         const TUint32& aIntent )
       
   696     {
       
   697     TBuf<KMaxFileName*2> msgLine;
       
   698     msgLine.Zero();
       
   699     msgLine.Append( '\t' );
       
   700 
       
   701     HBufC* stringHolder;
       
   702 
       
   703     if ( aIsAccumulatedTime )
       
   704         {
       
   705         // Accumulated time constraint
       
   706         stringHolder = StringLoader::LoadL( R_QTN_DRM_DETAILS_PLAYING_TIME_LEFT,
       
   707                                             iEikonEnv );
       
   708         }
       
   709     else
       
   710         {
       
   711         // Interval constraint which has not been activated
       
   712         TInt resourceId( 0 );
       
   713         switch ( aIntent )
       
   714             {
       
   715             case ContentAccess::EPlay:
       
   716                 resourceId = R_QTN_DRM_DETAILS_VALIDITY_PERIOD;
       
   717                 break;
       
   718 
       
   719             case ContentAccess::EView:
       
   720                 resourceId = R_QTN_DRM_DETAILS_VIEWING_RIGHTS;
       
   721                 break;
       
   722 
       
   723             case ContentAccess::EPrint:
       
   724                 resourceId = R_QTN_DRM_DETAILS_PRINTING_RIGHTS;
       
   725                 break;
       
   726 
       
   727             case ContentAccess::EExecute:
       
   728                 resourceId = R_QTN_DRM_DETAILS_VALIDITY_PERIOD;
       
   729                 break;
       
   730 
       
   731             default:
       
   732                 User::Leave( KErrArgument );
       
   733                 break;
       
   734             }
       
   735 
       
   736         stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
       
   737         }
       
   738 
       
   739     msgLine.Append( *stringHolder );
       
   740 
       
   741     delete stringHolder;
       
   742     stringHolder = NULL;
       
   743 
       
   744     msgLine.Append( '\t' );
       
   745 
       
   746     TInt intYrs, intMon, intDay, intHrs, intMin, intSec;
       
   747     SplitTime( aInterval, intYrs, intMon, intDay, intHrs, intMin, intSec );
       
   748 
       
   749     stringHolder = AddPartsOfTimeL( intYrs, intMon, intDay,
       
   750                                     intHrs, intMin, intSec );
       
   751 
       
   752     msgLine.Append( *stringHolder );
       
   753 
       
   754     delete stringHolder;
       
   755     stringHolder = NULL;
       
   756 
       
   757     if ( aItems )
       
   758         {
       
   759         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
       
   760         aItems->AppendL( msgLine );
       
   761         }
       
   762     }
       
   763 
       
   764 
       
   765 // ---------------------------------------------------------
       
   766 // CDRMRightsMgrDetailsContainer::SplitTime
       
   767 // ---------------------------------------------------------
       
   768 //
       
   769 void CDRMRightsMgrDetailsContainer::SplitTime(
       
   770                                 const TTimeIntervalSeconds& aInterval,
       
   771                                 TInt& aIntYrs, TInt& aIntMon, TInt& aIntDay,
       
   772                                 TInt& aIntHrs, TInt& aIntMin, TInt& aIntSec )
       
   773     {
       
   774     TInt temp;
       
   775     TInt i;
       
   776 
       
   777     const TInt daysInYear = 365;
       
   778     const TInt secsInMin = 60;
       
   779     const TInt secsInHour = secsInMin*60;
       
   780     const TInt secsInDay = secsInHour*24;
       
   781 
       
   782     const TInt maxDaysInMonths[12] = {  30,  60,  90, 120, 150, 180,
       
   783                                        210, 240, 270, 300, 330, 360 };
       
   784 
       
   785     // calculate full days
       
   786     temp = aInterval.Int() / secsInDay;
       
   787 
       
   788     // calculate full years
       
   789     aIntYrs = temp / daysInYear;
       
   790 
       
   791     // calc remainder days
       
   792     temp = temp % daysInYear;
       
   793 
       
   794     aIntMon = 0;
       
   795 
       
   796     i = 0;
       
   797     if ( temp >= maxDaysInMonths[0] )
       
   798         {
       
   799         for ( i = 0; i < 11; i++ )
       
   800             {
       
   801             // found correct amount of months
       
   802             if ( temp >= maxDaysInMonths[i] && temp < maxDaysInMonths[i+1] )
       
   803                 {
       
   804                 // i now contains amount of full months (+1 because of table index)
       
   805                 aIntMon = i+1;
       
   806                 break;
       
   807                 }
       
   808             }
       
   809         }
       
   810 
       
   811     // calc remainder days = allSecs - secsInFullYears - secsInFullMonts
       
   812     if( temp >= maxDaysInMonths[i] )
       
   813         {
       
   814         aIntDay = temp - maxDaysInMonths[i];
       
   815         }
       
   816     else
       
   817         {
       
   818         aIntDay = temp;
       
   819         }
       
   820 
       
   821     // calculate remainder secs
       
   822     temp = aInterval.Int() % secsInDay;
       
   823 
       
   824     aIntHrs = temp / secsInHour;
       
   825 
       
   826     // calculate remainder secs
       
   827     temp = temp % secsInHour;
       
   828 
       
   829     aIntMin = temp / secsInMin;
       
   830 
       
   831     // calculate remainder secs
       
   832     aIntSec = temp % secsInMin;
       
   833     }
       
   834 
       
   835 
       
   836 // ---------------------------------------------------------
       
   837 // CDRMRightsMgrDetailsContainer::AddPartsOfTimeL
       
   838 // ---------------------------------------------------------
       
   839 //
       
   840 HBufC* CDRMRightsMgrDetailsContainer::AddPartsOfTimeL(
       
   841                                     TInt aIntYrs, TInt aIntMon, TInt aIntDay,
       
   842                                     TInt aIntHrs, TInt aIntMin, TInt aIntSec )
       
   843     {
       
   844     // Only the two most meaningful data will be showed
       
   845     TInt numOfData = 0;
       
   846 
       
   847     CDesCArrayFlat* strings = new ( ELeave ) CDesCArrayFlat( 2 );
       
   848     CleanupStack::PushL( strings );
       
   849 
       
   850     if ( aIntYrs > 0 )
       
   851         {
       
   852         AddSinglePartOfTimeL( aIntYrs,
       
   853                               R_QTN_DRM_NBR_OF_YEARS_ONE,
       
   854                               R_QTN_DRM_NBR_OF_YEARS_ONE_FINAL,
       
   855                               R_QTN_DRM_NBR_OF_YEARS_TWO_FOUR,
       
   856                               R_QTN_DRM_NBR_OF_YEARS_FIVE_ZERO,
       
   857                               strings );
       
   858         numOfData++;
       
   859         }
       
   860 
       
   861     if ( aIntMon > 0 )
       
   862         {
       
   863         //  Second type not provided because 11 is the maximum
       
   864         AddSinglePartOfTimeL( aIntMon,
       
   865                               R_QTN_DRM_NBR_OF_MONTHS_ONE,
       
   866                               0,
       
   867                               R_QTN_DRM_NBR_OF_MONTHS_TWO_FOUR,
       
   868                               R_QTN_DRM_NBR_OF_MONTHS_FIVE_ZERO,
       
   869                               strings );
       
   870         numOfData++;
       
   871         }
       
   872 
       
   873     // Only if years or months were missing
       
   874     if ( aIntDay > 0 && numOfData < 2 )
       
   875         {
       
   876         AddSinglePartOfTimeL( aIntDay,
       
   877                               R_QTN_DRM_NBR_OF_DAYS_ONE,
       
   878                               R_QTN_DRM_NBR_OF_DAYS_ONE_FINAL,
       
   879                               R_QTN_DRM_NBR_OF_DAYS_TWO_FOUR,
       
   880                               R_QTN_DRM_NBR_OF_DAYS_FIVE_ZERO,
       
   881                               strings );
       
   882         numOfData++;
       
   883         }
       
   884 
       
   885     if ( aIntHrs > 0 && numOfData < 2 )
       
   886         {
       
   887         AddSinglePartOfTimeL( aIntHrs,
       
   888                               R_QTN_DRM_NBR_OF_HOURS_ONE,
       
   889                               R_QTN_DRM_NBR_OF_HOURS_ONE_FINAL,
       
   890                               R_QTN_DRM_NBR_OF_HOURS_TWO_FOUR,
       
   891                               R_QTN_DRM_NBR_OF_HOURS_FIVE_ZERO,
       
   892                               strings );
       
   893         numOfData++;
       
   894         }
       
   895 
       
   896     if ( aIntMin > 0 && numOfData < 2 )
       
   897         {
       
   898         AddSinglePartOfTimeL( aIntMin,
       
   899                               R_QTN_DRM_NBR_OF_MINS_ONE,
       
   900                               R_QTN_DRM_NBR_OF_MINS_ONE_FINAL,
       
   901                               R_QTN_DRM_NBR_OF_MINS_TWO_FOUR,
       
   902                               R_QTN_DRM_NBR_OF_MINS_FIVE_ZERO,
       
   903                               strings );
       
   904         numOfData++;
       
   905         }
       
   906 
       
   907     // If interval is 0, then it shows "0 seconds" anyway
       
   908     if ( ( aIntSec > 0 && numOfData < 2 ) || numOfData == 0 )
       
   909         {
       
   910         AddSinglePartOfTimeL( aIntSec,
       
   911                               R_QTN_DRM_NBR_OF_SECS_ONE,
       
   912                               R_QTN_DRM_NBR_OF_SECS_ONE_FINAL,
       
   913                               R_QTN_DRM_NBR_OF_SECS_TWO_FOUR,
       
   914                               R_QTN_DRM_NBR_OF_SECS_FIVE_ZERO,
       
   915                               strings );
       
   916         numOfData++;
       
   917         }
       
   918 
       
   919     HBufC* stringHolder;
       
   920     if ( numOfData == 1 )
       
   921         {
       
   922         stringHolder = StringLoader::LoadL( R_QTN_DRM_MGR_DET_INTER,
       
   923                                             strings->MdcaPoint(0), iEikonEnv );
       
   924         }
       
   925     else
       
   926         {
       
   927         stringHolder = StringLoader::LoadL( R_QTN_DRM_MGR_DET_INTER_TWO,
       
   928                                             *strings, iEikonEnv );
       
   929         }
       
   930 
       
   931     CleanupStack::PopAndDestroy( strings );
       
   932 
       
   933     return stringHolder;
       
   934     }
       
   935 
       
   936 
       
   937 // ---------------------------------------------------------
       
   938 // CDRMRightsMgrDetailsContainer::AddSinglePartOfTimeL
       
   939 // ---------------------------------------------------------
       
   940 //
       
   941 void CDRMRightsMgrDetailsContainer::AddSinglePartOfTimeL( TInt aNumOfElements,
       
   942                                                     TInt aResourceIdSingle,
       
   943                                                     TInt aResourceIdOneFinal,
       
   944                                                     TInt aResourceIdTwoFour,
       
   945                                                     TInt aResourceIdFiveZero,
       
   946                                                     CDesCArrayFlat* aStrings )
       
   947     {
       
   948     HBufC* stringHolder;
       
   949     TInt finalOneDigit = aNumOfElements % 10;
       
   950     TInt finalTwoDigits = aNumOfElements % 100;
       
   951 
       
   952     if ( aNumOfElements == 1 )
       
   953         {
       
   954         stringHolder = StringLoader::LoadLC( aResourceIdSingle, iEikonEnv );
       
   955         }
       
   956     else if ( finalOneDigit == 1 && finalTwoDigits != 11 )
       
   957         {
       
   958         stringHolder = StringLoader::LoadLC( aResourceIdOneFinal,
       
   959                                              aNumOfElements,
       
   960                                              iEikonEnv );
       
   961         }
       
   962     else if ( finalOneDigit == 0 ||
       
   963               ( finalOneDigit >= 5 && finalOneDigit <= 9 ) ||
       
   964               ( finalTwoDigits >= 11 && finalTwoDigits <= 14 ) )
       
   965         {
       
   966         stringHolder = StringLoader::LoadLC( aResourceIdFiveZero,
       
   967                                              aNumOfElements,
       
   968                                              iEikonEnv );
       
   969         }
       
   970     else
       
   971         {
       
   972         stringHolder = StringLoader::LoadLC( aResourceIdTwoFour,
       
   973                                              aNumOfElements,
       
   974                                              iEikonEnv );
       
   975         }
       
   976 
       
   977     if ( aStrings )
       
   978         {
       
   979         aStrings->AppendL( *stringHolder );
       
   980         }
       
   981 
       
   982     CleanupStack::PopAndDestroy ( stringHolder );
       
   983     }
       
   984 
       
   985 
       
   986 // ---------------------------------------------------------
       
   987 // CDRMRightsMgrDetailsContainer::AddRightsValidFromL
       
   988 // ---------------------------------------------------------
       
   989 //
       
   990 void CDRMRightsMgrDetailsContainer::AddRightsValidFromL(
       
   991                                                 const TTime& aStartDateTime,
       
   992                                                 CDesCArray* aItems,
       
   993                                                 const TUint32& aIntent )
       
   994     {
       
   995     TBuf<KMaxFileName*2> msgLine;
       
   996     msgLine.Zero();
       
   997     msgLine.Append( '\t' );
       
   998 
       
   999     TInt resourceId( 0 );
       
  1000     switch ( aIntent )
       
  1001         {
       
  1002         case ContentAccess::EPlay:
       
  1003             resourceId = R_QTN_DRM_DETAILS_VALID_FROM;
       
  1004             break;
       
  1005 
       
  1006         case ContentAccess::EView:
       
  1007             resourceId = R_QTN_DRM_DETAILS_VIEW_RIGHTS_FROM;
       
  1008             break;
       
  1009 
       
  1010         case ContentAccess::EPrint:
       
  1011             resourceId = R_QTN_DRM_DETAILS_PRINT_RIGHTS_FROM;
       
  1012             break;
       
  1013 
       
  1014         case ContentAccess::EExecute:
       
  1015             resourceId = R_QTN_DRM_DETAILS_VALID_FROM;
       
  1016             break;
       
  1017 
       
  1018         default:
       
  1019             User::Leave( KErrArgument );
       
  1020             break;
       
  1021         }
       
  1022 
       
  1023     HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
       
  1024     msgLine.Append( *stringHolder );
       
  1025 
       
  1026     delete stringHolder;
       
  1027     stringHolder = NULL;
       
  1028 
       
  1029     msgLine.Append( '\t' );
       
  1030 
       
  1031     if ( aStartDateTime != Time::NullTTime() )
       
  1032         {
       
  1033         TBuf<32> stringDate;
       
  1034         TBuf<32> stringTime;
       
  1035 
       
  1036         HBufC* stringFormatDate = StringLoader::LoadLC(
       
  1037                                                     R_QTN_DATE_USUAL_WITH_ZERO,
       
  1038                                                     iEikonEnv );
       
  1039         HBufC* stringFormatTime = StringLoader::LoadLC( R_QTN_TIME_USUAL,
       
  1040                                                        iEikonEnv );
       
  1041 
       
  1042         aStartDateTime.FormatL( stringDate, *stringFormatDate );
       
  1043         aStartDateTime.FormatL( stringTime, *stringFormatTime );
       
  1044         CleanupStack::PopAndDestroy( stringFormatTime );
       
  1045         CleanupStack::PopAndDestroy( stringFormatDate );
       
  1046 
       
  1047         msgLine.Append( stringDate );
       
  1048         msgLine.Append( ' ' );
       
  1049         msgLine.Append( stringTime );
       
  1050         }
       
  1051 
       
  1052     if ( aItems )
       
  1053         {
       
  1054         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
       
  1055         aItems->AppendL( msgLine );
       
  1056         }
       
  1057     }
       
  1058 
       
  1059 
       
  1060 // ---------------------------------------------------------
       
  1061 // CDRMRightsMgrDetailsContainer::AddRightsValidUntilL
       
  1062 // ---------------------------------------------------------
       
  1063 //
       
  1064 void CDRMRightsMgrDetailsContainer::AddRightsValidUntilL(
       
  1065                                                 const TTime& aEndDateTime,
       
  1066                                                 CDesCArray* aItems,
       
  1067                                                 const TUint32& aIntent )
       
  1068     {
       
  1069     TBuf<KMaxFileName*2> msgLine;
       
  1070     msgLine.Zero();
       
  1071     msgLine.Append( '\t' );
       
  1072 
       
  1073     TInt resourceId( 0 );
       
  1074     switch ( aIntent )
       
  1075         {
       
  1076         case ContentAccess::EPlay:
       
  1077             resourceId = R_QTN_DRM_DETAILS_VALID_UNTIL;
       
  1078             break;
       
  1079 
       
  1080         case ContentAccess::EView:
       
  1081             resourceId = R_QTN_DRM_DETAILS_VIEW_RIGHTS_UNTIL;
       
  1082             break;
       
  1083 
       
  1084         case ContentAccess::EPrint:
       
  1085             resourceId = R_QTN_DRM_DETAILS_PRINT_RIGHTS_UNTIL;
       
  1086             break;
       
  1087 
       
  1088         case ContentAccess::EExecute:
       
  1089             resourceId = R_QTN_DRM_DETAILS_VALID_UNTIL;
       
  1090             break;
       
  1091 
       
  1092         default:
       
  1093             User::Leave( KErrArgument );
       
  1094             break;
       
  1095         }
       
  1096 
       
  1097     HBufC* stringHolder = StringLoader::LoadL( resourceId, iEikonEnv );
       
  1098     msgLine.Append( *stringHolder );
       
  1099 
       
  1100     delete stringHolder;
       
  1101     stringHolder = NULL;
       
  1102 
       
  1103     msgLine.Append( '\t' );
       
  1104 
       
  1105     if ( aEndDateTime != Time::NullTTime() )
       
  1106         {
       
  1107         TBuf<32> stringDate;
       
  1108         TBuf<32> stringTime;
       
  1109 
       
  1110         HBufC* stringFormatDate = StringLoader::LoadLC(
       
  1111                                                     R_QTN_DATE_USUAL_WITH_ZERO,
       
  1112                                                     iEikonEnv );
       
  1113         HBufC* stringFormatTime = StringLoader::LoadLC( R_QTN_TIME_USUAL,
       
  1114                                                         iEikonEnv );
       
  1115 
       
  1116         aEndDateTime.FormatL( stringDate, *stringFormatDate );
       
  1117         aEndDateTime.FormatL( stringTime, *stringFormatTime );
       
  1118         CleanupStack::PopAndDestroy( stringFormatTime );
       
  1119         CleanupStack::PopAndDestroy( stringFormatDate );
       
  1120 
       
  1121         msgLine.Append( stringDate );
       
  1122         msgLine.Append( ' ' );
       
  1123         msgLine.Append( stringTime );
       
  1124         }
       
  1125 
       
  1126     if ( aItems )
       
  1127         {
       
  1128         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( msgLine );
       
  1129         aItems->AppendL( msgLine );
       
  1130         }
       
  1131     }
       
  1132 
       
  1133 // End of File