wvuing/wvuiave/AppSrc/CCASplashScreen.cpp
branchRCL_3
changeset 13 a941bc465d9f
parent 0 094583676ce7
equal deleted inserted replaced
12:6ca72c0fe49a 13:a941bc465d9f
       
     1 /*
       
     2 * Copyright (c) 2006-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:  AppUi class of application
       
    15 *  Since			 : 3.2
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include  "CCASplashScreen.h"
       
    22 #include  "CCASplashScreenControl.h"
       
    23 #include  "CCAAppUi.h"
       
    24 
       
    25 CCASplashScreen* CCASplashScreen::NewL( CCAAppUi* aAppUi )
       
    26     {
       
    27     CCASplashScreen* self = CCASplashScreen::NewLC( aAppUi );
       
    28     CleanupStack::Pop(); //self
       
    29 
       
    30     return self;
       
    31 
       
    32     }
       
    33 
       
    34 CCASplashScreen* CCASplashScreen::NewLC( CCAAppUi* aAppUi )
       
    35     {
       
    36     CCASplashScreen* self = new ( ELeave ) CCASplashScreen( aAppUi );
       
    37     CleanupStack::PushL( self );
       
    38     self->ConstructL();
       
    39 
       
    40     return self;
       
    41     }
       
    42 
       
    43 CCASplashScreen::CCASplashScreen( CCAAppUi* aAppUi )
       
    44         : CActive( EPriorityStandard ), iSplashControl( NULL ), iAppUi( aAppUi )
       
    45     {
       
    46     CActiveScheduler::Add( this );
       
    47     }
       
    48 
       
    49 void CCASplashScreen::ConstructL()
       
    50     {
       
    51     User::LeaveIfError( iTimer.CreateLocal() );
       
    52     }
       
    53 
       
    54 CCASplashScreen::~CCASplashScreen()
       
    55     {
       
    56     Cancel();
       
    57     iTimer.Close();
       
    58 
       
    59     iSplashScreenListener = NULL;
       
    60     SplashScreenDismissed();
       
    61 
       
    62     }
       
    63 
       
    64 void CCASplashScreen::ShowSplashScreenL( MCASplashScreenObserver* aSplashScreenListener,
       
    65                                          const TInt& aTime,
       
    66                                          CGulIcon* aSplashImage,
       
    67                                          /*MNcdSkinData* aSkinData,*/
       
    68                                          TBool aDismissable  )
       
    69     {
       
    70     Cancel();		// Cancel any request, just to be sure
       
    71 
       
    72     iSplashScreenListener = aSplashScreenListener;
       
    73 
       
    74     if ( !iSplashControl )
       
    75         {
       
    76         CleanupStack::PushL( aSplashImage );
       
    77 
       
    78         CCASplashScreenControl* tmpSplashControl =
       
    79             CCASplashScreenControl::NewLC( *this );
       
    80 
       
    81         iAppUi->AddToStackL( tmpSplashControl );
       
    82 
       
    83         CleanupStack::Pop( tmpSplashControl );
       
    84 
       
    85         CleanupStack::Pop( aSplashImage );
       
    86 
       
    87         iSplashControl = tmpSplashControl;
       
    88         }
       
    89 
       
    90     iSplashControl->ShowSplashScreen( aSplashImage,/* aSkinData,*/ aDismissable );
       
    91 
       
    92     // after aSplashTime go to RunL and remove splash screen from the view
       
    93     iTimer.After( iStatus, aTime * 1000000 );
       
    94     SetActive();	// Tell scheduler a request is active
       
    95     /*
       
    96         // get current time (microseconds since 0AD nominal Gregorian)
       
    97     	TTime time;
       
    98     	time.HomeTime();
       
    99 
       
   100     	// add 3 seconds to the time
       
   101     	TTimeIntervalSeconds timeIntervalSeconds(3);
       
   102     	time += timeIntervalSeconds;
       
   103 
       
   104     	TRequestStatus timerStatus;
       
   105     	// issue and wait
       
   106     	iTimer.At(timerStatus,time);
       
   107     	User::WaitForRequest(timerStatus);
       
   108     */
       
   109     }
       
   110 
       
   111 void CCASplashScreen::RunL()
       
   112     {
       
   113     SplashScreenDismissed();
       
   114     }
       
   115 
       
   116 TInt CCASplashScreen::RunError( TInt aError )
       
   117     {
       
   118     return aError;
       
   119     }
       
   120 
       
   121 void CCASplashScreen::DoCancel()
       
   122     {
       
   123     iTimer.Cancel();
       
   124     }
       
   125 
       
   126 void CCASplashScreen::SplashScreenDismissed()
       
   127     {
       
   128     // remove splashscreen by destroying the control
       
   129     if ( iSplashControl )
       
   130         {
       
   131         iSplashControl->MakeVisible( EFalse );
       
   132         iAppUi->RemoveFromStack( iSplashControl );
       
   133         delete iSplashControl;
       
   134         iSplashControl = NULL;
       
   135         }
       
   136 
       
   137     // Inform the listener.
       
   138     if ( iSplashScreenListener )
       
   139         {
       
   140         iSplashScreenListener->SplashScreenShowed();
       
   141         iSplashScreenListener = NULL;
       
   142         }
       
   143     }
       
   144 
       
   145 void CCASplashScreen::DismissSplashScreen()
       
   146     {
       
   147     // Cancel outstanding requests
       
   148     Cancel();
       
   149 
       
   150     // Make a request and complete it
       
   151     // Call is made to RunL() and splash screen will be taken care of
       
   152     iStatus = KRequestPending;
       
   153     TRequestStatus* tmp = &iStatus;
       
   154     SetActive();
       
   155     User::RequestComplete( tmp, KErrNone );
       
   156     iAppUi->HandleCommandL( EAknCmdExit );
       
   157     }
       
   158 
       
   159 // End of File
       
   160 //
       
   161 //