browserutilities/feedsengine/FeedsUI/TestHarness/src/FeedsWaitDialog.cpp
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2005 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 the License "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:  Encapsulates a wait or progress dialog.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AknWaitDialog.h>
       
    20 #include <eikprogi.h>
       
    21 #include <eikdialg.h>
       
    22 #include <StringLoader.h>
       
    23 
       
    24 #include <FeedsApp.rsg>
       
    25 
       
    26 #include "FeedsWaitDialog.h"
       
    27 
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CFeedsWaitDialog::NewL
       
    31 //
       
    32 // Two-phased constructor.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CFeedsWaitDialog* CFeedsWaitDialog::NewL(MFeedsWaitDialogListener& aListener)
       
    36     {
       
    37     CFeedsWaitDialog* self = new (ELeave) CFeedsWaitDialog(aListener);
       
    38     
       
    39     CleanupStack::PushL(self);
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop();
       
    42 
       
    43     return self;
       
    44     }
       
    45 
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CFeedsWaitDialog::CFeedsWaitDialog
       
    49 //
       
    50 // C++ default constructor.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CFeedsWaitDialog::CFeedsWaitDialog(MFeedsWaitDialogListener& aListener):
       
    54         iListener(aListener)
       
    55     {
       
    56     }
       
    57 
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CFeedsWaitDialog::ConstructL
       
    61 //
       
    62 // Symbian 2nd phase constructor can leave.
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CFeedsWaitDialog::ConstructL()
       
    66     {
       
    67     }
       
    68 
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CFeedsWaitDialog::~CFeedsWaitDialog
       
    72 //
       
    73 // Deconstructor.
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 CFeedsWaitDialog::~CFeedsWaitDialog()
       
    77     {
       
    78     delete iWaitDialog;
       
    79     delete iProgressDialog;
       
    80     }
       
    81 
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CFeedsWaitDialog::DialogDismissedL
       
    85 //
       
    86 // Called when the user presses the cancel button.
       
    87 // -----------------------------------------------------------------------------
       
    88 //
       
    89 void CFeedsWaitDialog::DialogDismissedL(TInt /*aButtonId*/)
       
    90     {
       
    91     iListener.DialogDismissedL();
       
    92     }
       
    93 
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CFeedsWaitDialog::ShowWaitDialogL
       
    97 //
       
    98 // Displays a WaitDialog.
       
    99 // -----------------------------------------------------------------------------
       
   100 //
       
   101 void CFeedsWaitDialog::ShowWaitDialogL(TInt aLabelId)
       
   102     {
       
   103     iWaitDialog = new (ELeave) CAknWaitDialog(
       
   104             reinterpret_cast<CEikDialog**>(&iWaitDialog));
       
   105     iWaitDialog->PrepareLC(R_FEEDS_WAIT_NOTE_DIALOG);
       
   106     
       
   107     UpdateLabelL(aLabelId);
       
   108     iWaitDialog->SetCallback(this);
       
   109     iWaitDialog->RunLD();
       
   110     }
       
   111 
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CFeedsWaitDialog::ShowProgressDialogL
       
   115 //
       
   116 // Displays a ProgressDialog.
       
   117 // -----------------------------------------------------------------------------
       
   118 //
       
   119 void CFeedsWaitDialog::ShowProgressDialogL(TInt aLabelId)
       
   120     {
       
   121     iProgressDialog = new (ELeave) CAknProgressDialog(
       
   122             reinterpret_cast<CEikDialog**>(&iProgressDialog));
       
   123     iProgressDialog->PrepareLC(R_FEEDS_PROGRESS_NOTE_DIALOG);
       
   124     
       
   125     UpdateLabelL(aLabelId);
       
   126     iProgressDialog->SetCallback(this);
       
   127     iProgressInfo = iProgressDialog->GetProgressInfoL();
       
   128     iProgressDialog->RunLD();
       
   129     }
       
   130 
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CFeedsWaitDialog::UpdateLabelL
       
   134 //
       
   135 // Updates the dialog's label.
       
   136 // -----------------------------------------------------------------------------
       
   137 //
       
   138 void CFeedsWaitDialog::UpdateLabelL(TInt aLabelId)
       
   139     {
       
   140     HBufC*  label = NULL;
       
   141 
       
   142     // Load the label's resource.
       
   143     label = StringLoader::LoadLC(aLabelId);
       
   144 
       
   145     // Set the label.
       
   146     if (iWaitDialog != NULL)
       
   147         {
       
   148         iWaitDialog->SetTextL(*label);
       
   149         }
       
   150     else if (iProgressDialog != NULL)
       
   151         {
       
   152         iProgressDialog->SetTextL(*label);
       
   153         }
       
   154         
       
   155     CleanupStack::PopAndDestroy(label);
       
   156     }
       
   157 
       
   158 
       
   159 // -----------------------------------------------------------------------------
       
   160 // CFeedsWaitDialog::SetMaxProgressL
       
   161 //
       
   162 // For progress dialogs this method set the max progress value.
       
   163 // -----------------------------------------------------------------------------
       
   164 //
       
   165 void CFeedsWaitDialog::SetMaxProgressL(TInt aMaxValue)
       
   166     {
       
   167     if (iProgressDialog != NULL)
       
   168         {
       
   169         iProgressInfo->SetFinalValue(aMaxValue);
       
   170         }
       
   171     }
       
   172 
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CFeedsWaitDialog::UpdateProgressL
       
   176 //
       
   177 // For progress dialogs this method updates the progress.
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 void CFeedsWaitDialog::UpdateProgressL(TInt aIncrement)
       
   181     {
       
   182     if (iProgressDialog != NULL)
       
   183         {
       
   184         iProgressInfo->IncrementAndDraw(aIncrement);
       
   185         }
       
   186     }
       
   187 
       
   188 
       
   189 // -----------------------------------------------------------------------------
       
   190 // CFeedsWaitDialog::Close
       
   191 //
       
   192 // Closes the dialog.
       
   193 // -----------------------------------------------------------------------------
       
   194 //
       
   195 void CFeedsWaitDialog::Close()
       
   196     {
       
   197     if (iWaitDialog != NULL)
       
   198         {
       
   199         //iWaitDialog->ProcessFinishedL();
       
   200         delete iWaitDialog;
       
   201         iWaitDialog = NULL;
       
   202         }
       
   203     else if (iProgressDialog != NULL)
       
   204         {
       
   205         //iProgressDialog->ProcessFinishedL();
       
   206         delete iProgressDialog;
       
   207         iProgressDialog = NULL;
       
   208         }
       
   209     }