usbuis/imageprintui/src/notes.cpp
changeset 93 2dc695882abd
parent 89 3592750162a5
equal deleted inserted replaced
89:3592750162a5 93:2dc695882abd
     1 /*
       
     2 * Copyright (c) 2006 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:  Show all notes on the screen
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aknViewAppUi.h>
       
    20 #include <imageprintui.rsg>
       
    21 
       
    22 #include "imageprintui.hrh"
       
    23 #include "settingsview.h"
       
    24 #include <AknWaitDialog.h>
       
    25 #include <aknnotedialog.h>
       
    26 #include <aknprogresstimer.h>
       
    27 
       
    28 
       
    29 #include <e32std.h>
       
    30 #include <AknProgressDialog.h>
       
    31 #include <AknInfoPopupNoteController.h>
       
    32 
       
    33 #include <aknstaticnotedialog.h>
       
    34 #include <eikprogi.h>
       
    35 #include <aknnotewrappers.h>
       
    36 #include <StringLoader.h>
       
    37 #include <eikenv.h>
       
    38 
       
    39 #include "settingscontainer.h"
       
    40 #include "imageprintuidebug.h"
       
    41 #include "imageprintuiappui.h"
       
    42 #include "notes.h"
       
    43 
       
    44 const TUint KProgressFinishValue = 100;
       
    45 
       
    46 
       
    47 // ======== MEMBER FUNCTIONS ========
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // 
       
    51 // ---------------------------------------------------------------------------
       
    52 //
       
    53 CNotes* CNotes::NewL(CImagePrintUiAppUi* aPrintUiAppUi)
       
    54     {
       
    55     FLOG(_L("[IMAGEPRINTUI]\t CNotes::NewL()"));
       
    56     CNotes* self = new( ELeave ) CNotes(aPrintUiAppUi);
       
    57     FLOG(_L("[IMAGEPRINTUI]\t CNotes::NewL() complete"));
       
    58     return self;
       
    59     }
       
    60 
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // 
       
    64 // ---------------------------------------------------------------------------
       
    65 //
       
    66 CNotes::~CNotes()
       
    67     {
       
    68     FLOG(_L("[IMAGEPRINTUI]\t CNotes::Destructor"));
       
    69     if(iWaitNote)
       
    70     	{
       
    71     	FLOG(_L("[IMAGEPRINTUI]\t CNotes::Delete iWaitNote"));
       
    72         delete iWaitNote;
       
    73         iWaitNote = NULL;
       
    74     	}
       
    75     if ( iProgressDialog )
       
    76         {
       
    77         FLOG(_L("[IMAGEPRINTUI]\t CNotes::Delete iProgressDialog"));
       
    78         delete iProgressDialog;
       
    79         iProgressDialog = NULL;
       
    80         }
       
    81     FLOG(_L("[IMAGEPRINTUI]\t CNotes::Destructor complete"));
       
    82 
       
    83     }
       
    84 
       
    85 // ---------------------------------------------------------------------------
       
    86 // Default constructor
       
    87 // ---------------------------------------------------------------------------
       
    88 //
       
    89 CNotes::CNotes(CImagePrintUiAppUi* aPrintUiAppUi): iPrintUiAppUi(aPrintUiAppUi),
       
    90     iDisconnect(EFalse ),
       
    91     iCancelling(EFalse)
       
    92     {
       
    93     }
       
    94 
       
    95 // ---------------------------------------------------------------------------
       
    96 // 
       
    97 // ---------------------------------------------------------------------------
       
    98 //
       
    99 void CNotes::DialogDismissedL(TInt aButtonId )
       
   100     {
       
   101     FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogDismissedL BEGIN"));	
       
   102 	
       
   103     // If user pressed cancel, cancel printing
       
   104     if(iProgressDialog)
       
   105     	{
       
   106         if(!iDisconnect)
       
   107         	{
       
   108         	FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogMissedL, not disconnect case"));
       
   109 		    if ( aButtonId == EAknSoftkeyCancel )
       
   110 		        {
       
   111 		        FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogMissedL ,sotfkey cancel iProgressDialog"));	
       
   112 		        iCancelling = ETrue;
       
   113 		        iPrintUiAppUi->CancelPrinting();
       
   114 		        }
       
   115         	}
       
   116     	}
       
   117 	if(iWaitNote)
       
   118 		{
       
   119 	 	if(!iDisconnect)
       
   120         	{
       
   121 		 	if ( aButtonId == EAknSoftkeyCancel )
       
   122 		        {
       
   123 		        FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogMissedL ,sotfkey cancel iWaitNote"));
       
   124 		        iPrintUiAppUi->CloseApplication(EFalse);
       
   125 		        }
       
   126         	}
       
   127 	  	}
       
   128     
       
   129     FLOG(_L("[IMAGEPRINTUI]\t CNotes::DialogDismissedL END"));	
       
   130     }
       
   131 
       
   132 // ---------------------------------------------------------------------------
       
   133 // 
       
   134 // ---------------------------------------------------------------------------
       
   135 //
       
   136 void CNotes::ShowNoteL(TUint aNoteType)
       
   137 	{
       
   138 	FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNote Start"));
       
   139 	if(!iWaitNote)
       
   140     	{
       
   141     	FLOG(_L("[IMAGEPRINTUI]\t CNotes::Create note"));
       
   142 		iWaitNote = new (ELeave) CAknWaitDialog(
       
   143 	              (REINTERPRET_CAST(CEikDialog**,&iWaitNote)), ETrue);
       
   144 	    FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNoteL; Note created"));          
       
   145         iWaitNote->SetCallback( this ); 
       
   146         FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNoteL; Callback set"));   
       
   147         iWaitNote->ExecuteLD(aNoteType);
       
   148         FLOG(_L("[IMAGEPRINTUI]\t CNotes::ShowNoteL; ExecuteLD passed")); 
       
   149     	} 	
       
   150 	}
       
   151 
       
   152 // ---------------------------------------------------------------------------
       
   153 // 
       
   154 // ---------------------------------------------------------------------------
       
   155 //	
       
   156 void CNotes::StopShowNote(TUint /*aNoteType*/)
       
   157 	{
       
   158 	FLOG(_L("[IMAGEPRINTUI]\t CNotes::Stop note"));
       
   159 	delete iWaitNote;
       
   160 	iWaitNote = NULL;
       
   161 	}
       
   162 	
       
   163 
       
   164 
       
   165 // ---------------------------------------------------------------------------
       
   166 // 
       
   167 // ---------------------------------------------------------------------------
       
   168 //
       
   169 void CNotes::StartPrintingNotesL()
       
   170     {
       
   171     FLOG(_L("[IMAGEPRINTUI]>>> CNotes::StartPrintingNotesL")); 
       
   172 	PrepareShowProgressNoteL();
       
   173     FLOG(_L("[IMAGEPRINTUI]<<< CNotes::StartPrintingNotesL")); 
       
   174     }
       
   175 
       
   176 // ---------------------------------------------------------------------------
       
   177 // 
       
   178 // ---------------------------------------------------------------------------
       
   179 //	
       
   180 void CNotes::PrepareShowProgressNoteL()
       
   181 	{
       
   182 	FLOG(_L("[IMAGEPRINTUI]>>> CNotes::PrepareShowProgressNoteL")); 
       
   183 	HBufC* txt;
       
   184 	txt = StringLoader::LoadLC( R_QTN_PRINT_PROGRESS_NOTE_TITLE );
       
   185             
       
   186 	if(!iProgressDialog)
       
   187     	{
       
   188     	iProgressDialog = new (ELeave) CAknProgressDialog(
       
   189 						(reinterpret_cast<CEikDialog**> (&iProgressDialog)));				
       
   190     	}
       
   191     	
       
   192     FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL; PrepareLC next"));	
       
   193    	iProgressDialog->PrepareLC(R_PROGRESS_NOTE);
       
   194 	CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL(); // not taking ownership
       
   195 	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL; progressinfo got"));	
       
   196 	
       
   197     progressBar->SetFinalValue( KProgressFinishValue );
       
   198     iProgressDialog->SetTextL( *txt );
       
   199     iProgressDialog->SetCallback( this );
       
   200     FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL; RunLD next"));  
       
   201     iProgressDialog->RunLD();
       
   202     CleanupStack::PopAndDestroy( txt );  
       
   203 	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrepareShowProgressNoteL")); 
       
   204 	}
       
   205 
       
   206 // ---------------------------------------------------------------------------
       
   207 // 
       
   208 // ---------------------------------------------------------------------------
       
   209 //	
       
   210 void CNotes::PrintProgress(TUint aProgress )
       
   211     {
       
   212     FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgress start "));
       
   213     FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CNotes PrintProgress aProgress value  is %d"), aProgress ));	
       
   214     TInt err = KErrNone;
       
   215     TRAP( err, PrintProgressL( aProgress ) );
       
   216     if ( err != KErrNone )
       
   217         {
       
   218         FTRACE(FPrint(_L("[IMAGEPRINTUI]\t CNotes PrintProgress err value  is %d"), err ));	
       
   219         TRAP_IGNORE( CNotes::ShowErrorMsgL( err ) );
       
   220         }
       
   221     }
       
   222 
       
   223 // ---------------------------------------------------------------------------
       
   224 // 
       
   225 // ---------------------------------------------------------------------------
       
   226 //
       
   227 void CNotes::SetCancelState(TBool aCancel)
       
   228 	{
       
   229 	iCancelling = aCancel;
       
   230 	}
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // 
       
   234 // ---------------------------------------------------------------------------
       
   235 //	
       
   236 void CNotes::SetDisconnectState(TBool aDisconnect)
       
   237 	{
       
   238 	iDisconnect = aDisconnect;
       
   239 	}
       
   240 
       
   241 
       
   242 // ---------------------------------------------------------------------------
       
   243 // Called to update the print progress 
       
   244 // ---------------------------------------------------------------------------
       
   245 //
       
   246 void CNotes::PrintProgressL(TUint aProgress )
       
   247     {
       
   248     FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL start; "));
       
   249 	if( !iCancelling )
       
   250 		{
       
   251 		if ( !iProgressDialog )
       
   252         	{
       
   253         	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL call PrepareShowProgressNoteL "));
       
   254 			PrepareShowProgressNoteL();
       
   255         	}
       
   256     	CEikProgressInfo* progressBar = iProgressDialog->GetProgressInfoL(); // not taking ownership
       
   257     	FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL; Update progress"));
       
   258     	progressBar->SetAndDraw( aProgress );
       
   259     	if(aProgress == KProgressFinishValue )
       
   260     		{
       
   261     		FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintProgressL; normal printing finish"));
       
   262     		PrintFinished();
       
   263     		}
       
   264 		}
       
   265     FLOG(_L("[IMAGEPRINTUI]>>> CNotes::PrintProgressL END "));
       
   266     }	
       
   267 
       
   268 // ---------------------------------------------------------------------------
       
   269 // 
       
   270 // ---------------------------------------------------------------------------
       
   271 //	    
       
   272 void CNotes::ShowErrorMsgL(TUint aErrCode )
       
   273 	{
       
   274 	if ( aErrCode != KErrNone )
       
   275         {
       
   276         FLOG(_L("[IMAGEPRINTUI]>>> CNotes:Show err note "));
       
   277         HBufC* str = StringLoader::LoadLC( aErrCode  );
       
   278         CAknErrorNote* note = new ( ELeave ) CAknErrorNote;
       
   279         note->ExecuteLD( *str );
       
   280         CleanupStack::PopAndDestroy( str );  // str
       
   281         }
       
   282 	}
       
   283 
       
   284 // ---------------------------------------------------------------------------
       
   285 // 
       
   286 // ---------------------------------------------------------------------------
       
   287 //	
       
   288 void CNotes::ShowInfoNoteL(TInt aResourceId )
       
   289     {
       
   290     HBufC* str = StringLoader::LoadLC( aResourceId );
       
   291     CAknInformationNote* note = new ( ELeave ) CAknInformationNote;
       
   292     note->ExecuteLD( *str );
       
   293     CleanupStack::PopAndDestroy( str);  // str
       
   294     }
       
   295 // ---------------------------------------------------------------------------
       
   296 // 
       
   297 // ---------------------------------------------------------------------------
       
   298 //			
       
   299 void CNotes::PrintFinished()
       
   300     {
       
   301     FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintFinished; START"));
       
   302     if ( iProgressDialog )
       
   303         {
       
   304         FLOG(_L("[IMAGEPRINTUI]<<< CNotes::PrintFinished, delete progress note"));
       
   305         delete iProgressDialog;
       
   306         iProgressDialog = NULL;
       
   307         iCancelling = EFalse;
       
   308         }
       
   309     }
       
   310 
       
   311 //End of File
       
   312 
       
   313