syncmlfw/syncmlnotifier/src/SyncMLTimedMessageQuery.cpp
changeset 44 39aa16f3fdc2
parent 43 c8e5c3d81b42
child 53 b3a7d8e28262
child 57 f5b689a4f7a2
equal deleted inserted replaced
43:c8e5c3d81b42 44:39aa16f3fdc2
     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 "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 "SyncMLTimedMessageQuery.h"
       
    22 #include "SyncMLNotifDebug.h"
       
    23 
       
    24 // CONSTANTS
       
    25 const TInt  KSyncMLuSecsInSec   = 1000000; // Microseconds in a second
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CSyncMLTimedMessageQuery::CSyncMLTimedMessageQuery
       
    31 // C++ default constructor can NOT contain any code, that
       
    32 // might leave.
       
    33 // -----------------------------------------------------------------------------
       
    34 //
       
    35 CSyncMLTimedMessageQuery::CSyncMLTimedMessageQuery( TInt aTimeout )
       
    36     : iTimeout( aTimeout )
       
    37     {
       
    38     }
       
    39 
       
    40 // -----------------------------------------------------------------------------
       
    41 // CSyncMLTimedMessageQuery::NewL
       
    42 // Two-phased constructor.
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 CSyncMLTimedMessageQuery* CSyncMLTimedMessageQuery::NewL( const TDesC& aMessage,
       
    46                                                                 TInt  aTimeout )
       
    47     {
       
    48     CSyncMLTimedMessageQuery* self =
       
    49         new( ELeave ) CSyncMLTimedMessageQuery ( aTimeout );
       
    50     
       
    51     CleanupStack::PushL( self );
       
    52     self->SetMessageTextL( aMessage );
       
    53     CleanupStack::Pop( self );
       
    54 
       
    55     return self;
       
    56     }
       
    57 
       
    58     
       
    59 // Destructor
       
    60 CSyncMLTimedMessageQuery::~CSyncMLTimedMessageQuery()
       
    61     {
       
    62     if ( iTimer )
       
    63         {
       
    64         iTimer->Cancel();
       
    65         delete iTimer;
       
    66         iTimer = NULL;
       
    67         }
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CSyncMLTimedMessageQuery::OkToExitL
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 TBool CSyncMLTimedMessageQuery::OkToExitL( TInt aButtonId )
       
    75     {
       
    76     if ( aButtonId == KErrTimedOut )
       
    77         {
       
    78         return ETrue;
       
    79         }
       
    80     return CAknQueryDialog::OkToExitL( aButtonId );
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CSyncMLTimedMessageQuery::TimerExpired
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void CSyncMLTimedMessageQuery::TimerExpired()
       
    88     {
       
    89     if ( iTimer )
       
    90         {
       
    91         iTimer->Cancel();
       
    92         delete iTimer;
       
    93         iTimer = NULL;
       
    94         iTimeout = KSyncMLNNoTimeout;
       
    95         }
       
    96     TRAPD( err, TryExitL( KErrTimedOut ) );
       
    97     
       
    98     if ( err != KErrNone )
       
    99         {
       
   100         FTRACE( FPrint(
       
   101             _L("[SmlNotif]\t CSyncMLTimedMessageQuery::TimerExpired() TryExitL returned %d"),
       
   102             err ) );
       
   103         }
       
   104     }
       
   105     
       
   106 // -----------------------------------------------------------------------------
       
   107 // CSyncMLTimedMessageQuery::PostLayoutDynInitL
       
   108 // -----------------------------------------------------------------------------
       
   109 //
       
   110 void CSyncMLTimedMessageQuery::PostLayoutDynInitL()
       
   111     {
       
   112     if ( iTimeout > KSyncMLNNoTimeout )
       
   113         {
       
   114         iTimer = CSyncMLQueryTimer::NewL( this );
       
   115         iTimer->After( iTimeout * KSyncMLuSecsInSec );
       
   116         }
       
   117     }
       
   118 
       
   119 
       
   120 //  End of File