syncmlfw/syncmlnotifier/src/SyncMLTimedNumberQueryDialog.cpp
branchRCL_3
changeset 25 b183ec05bd8c
parent 24 13d7c31c74e0
child 26 19bba8228ff0
equal deleted inserted replaced
24:13d7c31c74e0 25:b183ec05bd8c
     1 /*
       
     2 * Copyright (c) 2007 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:  Implementation of the query dialog with timeout timer.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "SyncMLTimedNumberQueryDialog.h"
       
    22 #include "SyncMLNotifDebug.h"
       
    23 
       
    24 // CONSTANTS
       
    25 const TInt  KSyncMLuSecsInSec   = 1000000; // Microseconds in a second
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CSyncMLTimedNumberQueryDialog::CSyncMLTimedNumberQueryDialog
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CSyncMLTimedNumberQueryDialog::CSyncMLTimedNumberQueryDialog( TReal& aValue, TBool& aKeypress,TInt aTimeout ):
       
    36 CAknFloatingPointQueryDialog( aValue, CAknQueryDialog::EConfirmationTone )
       
    37    
       
    38     {
       
    39      iTimeout = aTimeout ;
       
    40      iKeypress = aKeypress;
       
    41     }
       
    42     
       
    43 // -----------------------------------------------------------------------------
       
    44 // CSyncMLTimedNumberQueryDialog::NewL
       
    45 // Two-phased constructor.
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 CSyncMLTimedNumberQueryDialog* CSyncMLTimedNumberQueryDialog::NewL( TReal& aValue,                                                              
       
    49                                 const TDesC& aMessage,TBool& aKeypress, TInt  aTimeout )                                                             
       
    50     {
       
    51     CSyncMLTimedNumberQueryDialog* self =
       
    52         new( ELeave ) CSyncMLTimedNumberQueryDialog( aValue, aKeypress, aTimeout ) ;
       
    53     
       
    54     CleanupStack::PushL( self );
       
    55     
       
    56     	self->SetPromptL( aMessage );
       
    57     CleanupStack::Pop( self );
       
    58 
       
    59     return self;
       
    60     }
       
    61 
       
    62   
       
    63 // -----------------------------------------------------------------------------
       
    64 // CSyncMLTimedNumberQueryDialog::~CSyncMLTimedNumberQueryDialog
       
    65 // Destructor.
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CSyncMLTimedNumberQueryDialog::~CSyncMLTimedNumberQueryDialog()
       
    69     {
       
    70     if ( iTimer )
       
    71         {
       
    72         iTimer->Cancel();
       
    73         delete iTimer;
       
    74         iTimer = NULL;
       
    75         }
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CSyncMLTimedNumberQueryDialog::OkToExitL
       
    80 // -----------------------------------------------------------------------------
       
    81 //
       
    82 TBool CSyncMLTimedNumberQueryDialog::OkToExitL( TInt aButtonId )
       
    83     {
       
    84     if ( aButtonId == KErrTimedOut )
       
    85         {
       
    86         return ETrue;
       
    87         }
       
    88     return CAknFloatingPointQueryDialog::OkToExitL( aButtonId );
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CSyncMLTimedNumberQueryDialog::TimerExpired
       
    93 // -----------------------------------------------------------------------------
       
    94 //
       
    95 void CSyncMLTimedNumberQueryDialog::TimerExpired()
       
    96     {
       
    97     if ( iTimer )
       
    98         {
       
    99         iTimer->Cancel();
       
   100         delete iTimer;
       
   101         iTimer = NULL;
       
   102         iTimeout = KSyncMLNNoTimeout;
       
   103         }
       
   104     TRAPD( err, TryExitL( KErrTimedOut ) );
       
   105     
       
   106     if ( err != KErrNone )
       
   107         {
       
   108         FTRACE( FPrint(
       
   109             _L("[SmlNotif]\t CSyncMLTimedNumberQueryDialog::TimerExpired() \
       
   110              TryExitL returned %d"), err ) );
       
   111         }
       
   112     }
       
   113     
       
   114 // -----------------------------------------------------------------------------
       
   115 // CSyncMLTimedNumberQueryDialog::PostLayoutDynInitL
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CSyncMLTimedNumberQueryDialog::PostLayoutDynInitL()
       
   119     {
       
   120     if ( iTimeout > KSyncMLNNoTimeout )
       
   121         {
       
   122         iTimer = CSyncMLQueryTimer::NewL( this );
       
   123         iTimer->After( iTimeout * KSyncMLuSecsInSec );
       
   124         }
       
   125     CAknFloatingPointQueryDialog::PostLayoutDynInitL();
       
   126     }
       
   127     
       
   128 // -----------------------------------------------------------------------------
       
   129 // CSyncMLTimedNumberQueryDialog::NeedToDismissQueryL
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 TBool CSyncMLTimedNumberQueryDialog::NeedToDismissQueryL( const TKeyEvent& aKeyEvent )
       
   133     {
       
   134     if (aKeyEvent.iCode == EKeyNo)
       
   135         {
       
   136         
       
   137           iKeypress = ETrue;
       
   138           DismissQueryL();
       
   139           return ETrue;
       
   140             
       
   141         }
       
   142     return EFalse;
       
   143     }
       
   144     
       
   145 // -----------------------------------------------------------------------------
       
   146 // CSyncMLTimedNumberQueryDialog::DismissQueryL
       
   147 // -----------------------------------------------------------------------------
       
   148 //
       
   149 void CSyncMLTimedNumberQueryDialog::DismissQueryL()
       
   150 	{
       
   151 	 TryExitL(EEikBidCancel);
       
   152 	}
       
   153 
       
   154 
       
   155 //  End of File