commondrm/drmutility/src/drmutilityui.cpp
changeset 49 69d8e75812b7
parent 23 493788a4a8a4
child 84 b09186059647
--- a/commondrm/drmutility/src/drmutilityui.cpp	Fri Jun 11 15:44:45 2010 +0300
+++ b/commondrm/drmutility/src/drmutilityui.cpp	Thu Jun 24 12:39:58 2010 +0300
@@ -58,6 +58,9 @@
 #include "DrmUtilityGlobalNoteWrapper.h"
 #include "DrmUtilityInfoNoteWrapper.h"
 
+#include "drmuidialogids.h"
+#include "drmuidialogs.h"
+
 // CONSTANTS
 #ifndef RD_MULTIPLE_DRIVE
 _LIT( KDriveZ, "z:" );
@@ -74,6 +77,7 @@
 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
 const TInt KDRMUtilityMaxTimeLen( 30 );
 const TInt KDRMUtilityNoteMaxSize ( 256 );
+const TInt KNoValue = -1;
 
 #ifdef _DEBUG
 // debug panic
@@ -313,38 +317,12 @@
     TInt aTextResourceId,
     TInt aValue )
     {
-    TInt buttonCode( 0 );
-
-    if ( iCoeEnv )
-        {
-        TPtr bufPtr( NULL, 0 );
-
-        HBufC* stringholder( StringLoader::LoadLC( aTextResourceId,
-                                                   aValue,
-                                                   iCoeEnv ) );
-        CAknQueryDialog* dlg(
-                        CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
-
-        bufPtr.Set( stringholder->Des() );
-        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
-        PrepareSecondaryDisplayL( *dlg, aTextResourceId, KNullDesC, aValue );
+    TInt resultCode( ECancelled );
 
-        buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY,
-                                     *stringholder );
-
-        CancelSecondaryDisplayL( aTextResourceId );
-        CleanupStack::PopAndDestroy( stringholder );
-        }
-    else
-        {
-        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
-            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
-
-        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aValue );
-
-        CleanupStack::PopAndDestroy( noteWrapper );
-        }
-    return buttonCode;
+    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() ); 
+    resultCode = drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
+    CleanupStack::PopAndDestroy( drmUiDialog );
+    return resultCode;
     }
 
 // -----------------------------------------------------------------------------
@@ -355,39 +333,12 @@
     TInt aTextResourceId,
     const TDesC& aString )
     {
-    TInt buttonCode( 0 );
-
-    if ( iCoeEnv )
-        {
-        TPtr bufPtr( NULL, 0 );
-
-        HBufC* stringholder( StringLoader::LoadLC( aTextResourceId,
-                                                   aString,
-                                                   iCoeEnv ) );
-        CAknQueryDialog* dlg(
-            CAknQueryDialog::NewL( CAknQueryDialog::ENoTone ) );
-
-        bufPtr.Set( stringholder->Des() );
-        AknTextUtils::LanguageSpecificNumberConversion( bufPtr );
-        PrepareSecondaryDisplayL( *dlg, aTextResourceId, aString, -1 );
+    TInt resultCode( ECancelled );
 
-        buttonCode = dlg->ExecuteLD( R_DRMUTILITY_CONFIRMATION_QUERY,
-                                     *stringholder );
-
-        CancelSecondaryDisplayL( aTextResourceId );
-        CleanupStack::PopAndDestroy( stringholder );
-        }
-    else
-        {
-        DRM::CDrmUtilityGlobalNoteWrapper* noteWrapper(
-            DRM::CDrmUtilityGlobalNoteWrapper::NewLC( iUtilityStringResourceReader ) );
-
-        buttonCode = noteWrapper->ShowNoteL( aTextResourceId, aString );
-
-        CleanupStack::PopAndDestroy( noteWrapper );
-        }
-
-    return buttonCode;
+    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
+    resultCode = drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
+    CleanupStack::PopAndDestroy( drmUiDialog );
+    return resultCode;
     }
 
 // -----------------------------------------------------------------------------
@@ -485,7 +436,7 @@
     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
                                               KDRMUtilityDebugPanicCode ) );
 
-    TInt buttonCode( 1 );
+    TInt buttonCode( EOk );
 
     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
         {
@@ -506,13 +457,14 @@
             }
 
         endTime.FormatL( endDate, dateFormat );
-        buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate );
+
+        // Qt dialog not implmented yet.
+        buttonCode = DisplayQueryL( EQueryLicenceValidUntil, endDate );
         }
     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
         {
-        buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL,
-                                          R_DRMUTILITY_CONFIRMATION_QUERY );
-
+        // Qt dialog not implemented yet.
+        buttonCode = DisplayQueryL( EQueryValidForLimitedTime, KNoValue );
         }
     return buttonCode;
     }
@@ -556,7 +508,8 @@
     startDateBuf.Append( startTimeBuf );
 
     // display note with start date
-    DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf );
+    // Qt dialog not implemented yet
+    DisplayNoteL( EConfUnableToUse, startDateBuf );
     }
 
 // -----------------------------------------------------------------------------
@@ -565,20 +518,9 @@
 //
 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
     {
-    if ( iCoeEnv )
-        {
-        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
-        DisplayNoteL( *msgText, aTextResourceId );
-        CleanupStack::PopAndDestroy( msgText );
-        }
-
-    else
-        {
-        TBuf<KDRMUtilityNoteMaxSize> buffer(
-            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
-
-        DisplayNoteL( buffer, aTextResourceId );
-        }
+    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
+    drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, KNoValue );
+    CleanupStack::PopAndDestroy( drmUiDialog );
     }
 
 // -----------------------------------------------------------------------------
@@ -589,26 +531,9 @@
     TInt aTextResourceId,
     const TDesC& aString )
     {
-    if ( iCoeEnv )
-        {
-        HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
-                                              aString,
-                                              iCoeEnv ) );
-        DisplayNoteL( *msgText, aTextResourceId );
-        CleanupStack::PopAndDestroy( msgText );
-        }
-    else
-        {
-        TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer;
-
-
-        TBuf<KDRMUtilityNoteMaxSize> buffer(
-            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
-
-
-        StringLoader::Format( destBuffer, buffer, -1, aString );
-        DisplayNoteL( destBuffer, aTextResourceId, aString, -1 );
-        }
+    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
+    drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
+    CleanupStack::PopAndDestroy( drmUiDialog );
     }
 
 // -----------------------------------------------------------------------------
@@ -619,26 +544,9 @@
     TInt aTextResourceId,
     TInt aValue )
     {
-    if ( iCoeEnv )
-        {
-        HBufC* msgText( StringLoader::LoadLC( aTextResourceId,
-                                              aValue,
-                                              iCoeEnv ) );
-
-        DisplayNoteL( *msgText, aTextResourceId, KNullDesC, aValue );
-        CleanupStack::PopAndDestroy( msgText );
-        }
-    else
-        {
-        TBuf<KDRMUtilityNoteMaxSize + KMaxFileName> destBuffer;
-
-        TBuf<KDRMUtilityNoteMaxSize> buffer(
-            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
-
-
-        StringLoader::Format( destBuffer, buffer, -1, aValue );
-        DisplayNoteL( destBuffer, aTextResourceId, KNullDesC, aValue );
-        }
+    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
+    drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
+    CleanupStack::PopAndDestroy( drmUiDialog );
     }
 
 // -----------------------------------------------------------------------------