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