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