commondrm/drmutility/src/drmutilityui.cpp
branchRCL_3
changeset 27 1481bf457703
parent 26 1221b68b8a5f
--- a/commondrm/drmutility/src/drmutilityui.cpp	Tue Aug 31 15:29:38 2010 +0300
+++ b/commondrm/drmutility/src/drmutilityui.cpp	Wed Sep 01 12:21:16 2010 +0100
@@ -32,6 +32,7 @@
 #include <AknGlobalNote.h>
 #include <AknQueryDialog.h>
 #include <aknlistquerydialog.h>
+#include <aknmessagequerydialog.h> 
 
 // secondary display support
 #include <AknMediatorFacade.h>
@@ -58,9 +59,6 @@
 #include "DrmUtilityGlobalNoteWrapper.h"
 #include "DrmUtilityInfoNoteWrapper.h"
 
-#include "drmuidialogids.h"
-#include "drmuidialogs.h"
-
 // CONSTANTS
 #ifndef RD_MULTIPLE_DRIVE
 _LIT( KDriveZ, "z:" );
@@ -77,7 +75,6 @@
 const TInt KDRMUtilityMaxTimeFormatLen( 30 );
 const TInt KDRMUtilityMaxTimeLen( 30 );
 const TInt KDRMUtilityNoteMaxSize ( 256 );
-const TInt KNoValue = -1;
 
 #ifdef _DEBUG
 // debug panic
@@ -235,6 +232,8 @@
     iNoteList.Close();
 
     FeatureManager::UnInitializeLib();
+    delete iNoteWrapper;	
+    	
     }
 
 // -----------------------------------------------------------------------------
@@ -317,12 +316,38 @@
     TInt aTextResourceId,
     TInt aValue )
     {
-    TInt resultCode( ECancelled );
+    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 );
 
-    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() ); 
-    resultCode = drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
-    CleanupStack::PopAndDestroy( drmUiDialog );
-    return resultCode;
+        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;
     }
 
 // -----------------------------------------------------------------------------
@@ -333,12 +358,39 @@
     TInt aTextResourceId,
     const TDesC& aString )
     {
-    TInt resultCode( ECancelled );
+    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 );
 
-    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
-    resultCode = drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
-    CleanupStack::PopAndDestroy( drmUiDialog );
-    return resultCode;
+        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;
     }
 
 // -----------------------------------------------------------------------------
@@ -436,7 +488,7 @@
     __ASSERT_DEBUG( aConstraint, User::Panic( KDRMUtilityDebugPanicMessage,
                                               KDRMUtilityDebugPanicCode ) );
 
-    TInt buttonCode( EOk );
+    TInt buttonCode( 1 );
 
     if ( aConstraint->iActiveConstraints & EConstraintEndTime )
         {
@@ -457,14 +509,13 @@
             }
 
         endTime.FormatL( endDate, dateFormat );
-
-        // Qt dialog not implmented yet.
-        buttonCode = DisplayQueryL( EQueryLicenceValidUntil, endDate );
+        buttonCode = DisplayQueryL(R_DRM_QUERY_SET_AUTOMATED, endDate );
         }
     else if ( aConstraint->iActiveConstraints & EConstraintInterval )
         {
-        // Qt dialog not implemented yet.
-        buttonCode = DisplayQueryL( EQueryValidForLimitedTime, KNoValue );
+        buttonCode = DisplayQueryWithIdL( R_DRM_QUERY_SET_AUTO_INTERVAL,
+                                          R_DRMUTILITY_CONFIRMATION_QUERY );
+
         }
     return buttonCode;
     }
@@ -508,8 +559,7 @@
     startDateBuf.Append( startTimeBuf );
 
     // display note with start date
-    // Qt dialog not implemented yet
-    DisplayNoteL( EConfUnableToUse, startDateBuf );
+    DisplayNoteL( R_DRMUTILITY_USAGE_RIGHTS_IN_FUTURE, startDateBuf );
     }
 
 // -----------------------------------------------------------------------------
@@ -518,9 +568,20 @@
 //
 EXPORT_C void DRM::CDrmUtilityUI::DisplayNoteL( TInt aTextResourceId )
     {
-    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
-    drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, KNoValue );
-    CleanupStack::PopAndDestroy( drmUiDialog );
+    if ( iCoeEnv )
+        {
+        HBufC* msgText( StringLoader::LoadLC( aTextResourceId, iCoeEnv ) );
+        DisplayNoteL( *msgText, aTextResourceId );
+        CleanupStack::PopAndDestroy( msgText );
+        }
+
+    else
+        {
+        TBuf<KDRMUtilityNoteMaxSize> buffer(
+            iUtilityStringResourceReader->ReadResourceString( aTextResourceId ) );
+
+        DisplayNoteL( buffer, aTextResourceId );
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -531,9 +592,26 @@
     TInt aTextResourceId,
     const TDesC& aString )
     {
-    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
-    drmUiDialog->ShowNoteL( aTextResourceId, aString, KNoValue );
-    CleanupStack::PopAndDestroy( drmUiDialog );
+    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 );
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -544,9 +622,26 @@
     TInt aTextResourceId,
     TInt aValue )
     {
-    CDrmUIDialogs* drmUiDialog( CDrmUIDialogs::NewLC() );
-    drmUiDialog->ShowNoteL( aTextResourceId, KNullDesC, aValue );
-    CleanupStack::PopAndDestroy( drmUiDialog );
+    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 );
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -677,6 +772,39 @@
 
 #endif  // RD_DRM_PREVIEW_RIGHT_FOR_AUDIO
 
+EXPORT_C TInt DRM::CDrmUtilityUI::DisplayMessageQueryL( TInt aMessage, TInt aHeader, const TDesC& aString)
+    {
+    TInt buttonCode = 0;
+		if ( iCoeEnv )
+	    	{
+		    CAknMessageQueryDialog* messageQuery = new (ELeave) CAknMessageQueryDialog();
+		    messageQuery->PrepareLC(R_DRMUTILITY_SYNC_DIALOG);
+		    		    
+		    HBufC* headerStringholder ( StringLoader::LoadLC( aHeader, iCoeEnv ) );
+        
+		    messageQuery->QueryHeading()->SetTextL(*headerStringholder);
+ 				CleanupStack::PopAndDestroy(); // headerStringholder
+ 				 				
+ 				HBufC* messageStringholder ( StringLoader::LoadLC( aMessage, aString, iCoeEnv ) );
+ 				
+ 				messageQuery->SetMessageTextL(*messageStringholder);
+ 				CleanupStack::PopAndDestroy(); // messageStringholder
+		    
+		    buttonCode =  messageQuery->RunLD();
+		    }
+		else
+		  	{
+		  	if(!iNoteWrapper)
+		  			{
+		    		iNoteWrapper = DRM::CDrmUtilityGlobalNoteWrapper::NewL( iUtilityStringResourceReader );
+        		}
+        		
+        iNoteWrapper->ShowMessageQueryL(aMessage, aHeader, aString);
+				}
+		return buttonCode;
+    }
+
+
 // -----------------------------------------------------------------------------
 // CDrmUtilityUI::CreateNoteForResourceL
 // -----------------------------------------------------------------------------