commondrm/drmsettingsplugin/src/drmsettingsplugincontainer.cpp
changeset 31 908beac81e0a
parent 29 3bdc3b853094
child 34 7f8fbd0317cc
child 38 9dfde139acda
child 44 d642c9180c54
equal deleted inserted replaced
29:3bdc3b853094 31:908beac81e0a
     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:  Container for DRMSettinsPlugin
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <aknlists.h>
       
    21 #include <AknUtils.h>
       
    22 #include <csxhelp/drm.hlp.hrh>
       
    23 #include <gslistbox.h>
       
    24 #include <StringLoader.h>
       
    25 #include <drmsettingspluginrsc.rsg>
       
    26 
       
    27 #include "drmsettingsplugincontainer.h"
       
    28 #include "drmsettingsplugin.hrh"
       
    29 #include "drmsettingsmodel.h"
       
    30 
       
    31 const TUid KUidRightsManager = { 0x101F85C7 };
       
    32 
       
    33 // ========================= MEMBER FUNCTIONS ================================
       
    34 
       
    35 // ---------------------------------------------------------------------------
       
    36 // CDRMSettingsPluginContainer::ConstructL()
       
    37 //
       
    38 // Symbian OS two phased constructor
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 void CDRMSettingsPluginContainer::ConstructL( const TRect& aRect )
       
    42     {
       
    43     iListBox = new( ELeave ) CAknSettingStyleListBox;
       
    44     iModel = CDRMSettingsModel::NewL();
       
    45     BaseConstructL( aRect, R_DRM_SETTINGS_VIEW_TITLE, R_DRM_SETTINGS_LBX );
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CDRMSettingsPluginContainer::CDRMSettingsPluginContainer()
       
    50 //
       
    51 // Constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CDRMSettingsPluginContainer::CDRMSettingsPluginContainer(
       
    55     TBool aWmdrmSupported ) : iWmdrmSupported( aWmdrmSupported )
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CDRMSettingsPluginContainer::~CDRMSettingsPluginContainer()
       
    61 //
       
    62 // Destructor
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CDRMSettingsPluginContainer::~CDRMSettingsPluginContainer()
       
    66     {
       
    67     if ( iModel )
       
    68         {
       
    69         delete iModel;
       
    70         }
       
    71     // delete listbox item array
       
    72     if ( iListboxItemArray )
       
    73         {
       
    74         delete iListboxItemArray;
       
    75         }
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------------------------
       
    80 // CDRMSettingsPluginContainer::ConstructListBoxL()
       
    81 //
       
    82 // Construct the listbox from resource array.
       
    83 // ---------------------------------------------------------------------------
       
    84 //
       
    85 void CDRMSettingsPluginContainer::ConstructListBoxL( TInt aResLbxId )
       
    86     {
       
    87     iListBox->ConstructL( this, EAknListBoxSelectionList /* |
       
    88         EAknListBoxItemSpecificMenuDisabled */ );
       
    89     iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId,
       
    90                                                        *iListBox,
       
    91                                                        *iCoeEnv );
       
    92     iListBox->Model()->SetItemTextArray( iListboxItemArray );
       
    93     iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray );
       
    94     CreateListBoxItemsL();
       
    95     }
       
    96 
       
    97 
       
    98 // ---------------------------------------------------------------------------
       
    99 // CDRMSettingsPluginContainer::CreateListBoxItemsL()
       
   100 //
       
   101 // Create listbox items.
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CDRMSettingsPluginContainer::CreateListBoxItemsL()
       
   105     {
       
   106 #ifdef __DRM_OMA2
       
   107     MakeTransactionTrackingItemL();
       
   108 
       
   109 #ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
       
   110     MakeAutomaticActivationItemL();
       
   111 #endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
       
   112 
       
   113 #ifdef RD_DRM_METERING
       
   114     MakeUsageReportingItemL();
       
   115 #endif // RD_DRM_METERING
       
   116 #endif // __DRM_OMA2
       
   117 
       
   118 
       
   119     MakeWMDRMLicenseDeletionItemL();
       
   120     }
       
   121 
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CDRMSettingsPluginContainer::UpdateListBoxL()
       
   125 //
       
   126 // Update listbox item.
       
   127 // ---------------------------------------------------------------------------
       
   128 //
       
   129 void CDRMSettingsPluginContainer::UpdateListBoxL( TInt aFeatureId )
       
   130     {
       
   131     switch( aFeatureId )
       
   132         {
       
   133 #ifdef __DRM_OMA2
       
   134         case EDRMSettingsIdTransactionTracking:
       
   135             MakeTransactionTrackingItemL();
       
   136             break;
       
   137 
       
   138 #ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION
       
   139         case EDRMSettingsIdAutomaticActivation:
       
   140             MakeAutomaticActivationItemL();
       
   141             break;
       
   142 #endif // RD_DRM_SILENT_RIGHTS_ACQUISITION
       
   143 
       
   144 #ifdef RD_DRM_METERING
       
   145         case EDRMSettingsIdUsageReporting:
       
   146             MakeUsageReportingItemL();
       
   147             break;
       
   148 #endif // RD_DRM_METERING
       
   149 #endif // __DRM_OMA2
       
   150 
       
   151         case EDRMSettingsIdWMDRMLicenseDeletion:
       
   152 
       
   153             MakeWMDRMLicenseDeletionItemL();
       
   154 
       
   155             break;
       
   156 
       
   157         default:
       
   158             break;
       
   159         }
       
   160 
       
   161     iListBox->HandleItemAdditionL();
       
   162     }
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // CDRMSettingsPluginContainer::MakeTransactionTrackingItemL()
       
   167 //
       
   168 // Create Transaction tracking list item
       
   169 // ---------------------------------------------------------------------------
       
   170 //
       
   171 void CDRMSettingsPluginContainer::MakeTransactionTrackingItemL()
       
   172     {
       
   173     HBufC* dynamicText( NULL );
       
   174     TInt trxTrState( iModel->TransactionTrackingStateL() );
       
   175 
       
   176     switch ( trxTrState )
       
   177         {
       
   178         case KDRMTransactionTrackingEnabled:
       
   179             dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_TTRACKING_ON );
       
   180             break;
       
   181         default:
       
   182             dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_TTRACKING_OFF );
       
   183             break;
       
   184         }
       
   185 
       
   186     TPtr ptrBuffer ( dynamicText->Des() );
       
   187 
       
   188 
       
   189     // Finally, set the dynamic text
       
   190     iListboxItemArray->SetDynamicTextL( EDRMSettingsIdTransactionTracking, ptrBuffer );
       
   191 
       
   192     CleanupStack::PopAndDestroy( dynamicText );
       
   193 
       
   194     // And add to listbox
       
   195     iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdTransactionTracking,
       
   196         CGSListBoxItemTextArray::EVisible );
       
   197     }
       
   198 
       
   199 
       
   200 // ---------------------------------------------------------------------------
       
   201 // CDRMSettingsPluginContainer::MakeAutomaticActivationItemL()
       
   202 //
       
   203 // Create Automatic activation list item
       
   204 // ---------------------------------------------------------------------------
       
   205 //
       
   206 void CDRMSettingsPluginContainer::MakeAutomaticActivationItemL()
       
   207     {
       
   208     TInt automActivState( iModel->AutomaticActivationStateL() );
       
   209 
       
   210     HBufC* dynamicText( NULL );
       
   211 
       
   212     switch ( automActivState )
       
   213         {
       
   214         case KDRMTransactionTrackingEnabled:
       
   215             dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_AUTOM_ACTIV_ON );
       
   216             break;
       
   217         default:
       
   218             dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_AUTOM_ACTIV_OFF );
       
   219             break;
       
   220         }
       
   221 
       
   222     TPtr ptrBuffer ( dynamicText->Des() );
       
   223 
       
   224     // Finally, set the dynamic text
       
   225     iListboxItemArray->SetDynamicTextL( EDRMSettingsIdAutomaticActivation,
       
   226                                         ptrBuffer );
       
   227 
       
   228     CleanupStack::PopAndDestroy( dynamicText );
       
   229 
       
   230     // And add to listbox
       
   231     iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdAutomaticActivation,
       
   232                                            CGSListBoxItemTextArray::EVisible );
       
   233     }
       
   234 
       
   235 // ---------------------------------------------------------------------------
       
   236 // CDRMSettingsPluginContainer::MakeUsageReportingItemL()
       
   237 //
       
   238 // Create Usage reporting list item
       
   239 // ---------------------------------------------------------------------------
       
   240 //
       
   241 void CDRMSettingsPluginContainer::MakeUsageReportingItemL()
       
   242     {
       
   243     TInt count( iModel->UsageReportingCount() );
       
   244 
       
   245     HBufC* dynamicText( NULL );
       
   246 
       
   247     switch ( count )
       
   248         {
       
   249         case 0:
       
   250             dynamicText = StringLoader::LoadL( R_DRM_SET_USAGE_REPORT_NONE );
       
   251             break;
       
   252         case 1:
       
   253             dynamicText = iModel->GetFirstAllowedMeteringRIAliasL();
       
   254             break;
       
   255         default:
       
   256             dynamicText = StringLoader::LoadL( R_DRM_SET_SEVERAL_SERVICES );
       
   257             break;
       
   258         }
       
   259     CleanupStack::PushL( dynamicText );
       
   260 
       
   261     TPtr ptrBuffer ( dynamicText->Des() );
       
   262 
       
   263     // Finally, set the dynamic text
       
   264     iListboxItemArray->SetDynamicTextL( EDRMSettingsIdUsageReporting,
       
   265                                         ptrBuffer );
       
   266 
       
   267     CleanupStack::PopAndDestroy( dynamicText );
       
   268 
       
   269     // And add to listbox
       
   270     iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdUsageReporting,
       
   271                                            CGSListBoxItemTextArray::EVisible );
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 // CDRMSettingsPluginContainer::MakeWMDRMLicenseDeletionItemL()
       
   276 //
       
   277 // Create WMDRM license deletion list item
       
   278 // ---------------------------------------------------------------------------
       
   279 //
       
   280 void CDRMSettingsPluginContainer::MakeWMDRMLicenseDeletionItemL()
       
   281     {
       
   282     if ( iWmdrmSupported )
       
   283         {
       
   284         // Add to listbox
       
   285         iListboxItemArray->
       
   286             SetItemVisibilityL( EDRMSettingsIdWMDRMLicenseDeletion,
       
   287                                 CGSListBoxItemTextArray::EVisible );
       
   288         }
       
   289     else
       
   290         {
       
   291         // Add to listbox
       
   292         iListboxItemArray->
       
   293             SetItemVisibilityL( EDRMSettingsIdWMDRMLicenseDeletion,
       
   294                                 CGSListBoxItemTextArray::EInvisible );
       
   295 
       
   296         }
       
   297     }
       
   298 
       
   299 // ---------------------------------------------------------------------------
       
   300 // CDRMSettingsPluginContainer::GetHelpContext() const
       
   301 //
       
   302 // Gets Help
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CDRMSettingsPluginContainer::GetHelpContext(
       
   306     TCoeHelpContext& aContext ) const
       
   307     {
       
   308     aContext.iMajor = KUidRightsManager;
       
   309     aContext.iContext = KSET_HLP_PROTECTED_CONTENT;
       
   310     }
       
   311 
       
   312 
       
   313 // ---------------------------------------------------------------------------
       
   314 // CDRMSettingsPluginContainer::CurrentFeatureId()
       
   315 //
       
   316 // Return the feature id of selected listitem
       
   317 // ---------------------------------------------------------------------------
       
   318 //
       
   319 TInt CDRMSettingsPluginContainer::CurrentFeatureId( ) const
       
   320     {
       
   321     return iListboxItemArray->CurrentFeature();
       
   322     }
       
   323 
       
   324 
       
   325 // -----------------------------------------------------------------------------
       
   326 // CDRMSettingsPluginContainer::Model()
       
   327 //
       
   328 //
       
   329 // -----------------------------------------------------------------------------
       
   330 //
       
   331 CDRMSettingsModel* CDRMSettingsPluginContainer::Model()
       
   332     {
       
   333     return iModel;
       
   334     }
       
   335 
       
   336 // End of File