bearermanagement/mpm/src/mpmdialogbase.cpp
changeset 0 5a93021fdf25
child 71 9f263f780e41
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2008 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: MPM user dialog handling
       
    15 *
       
    16 */
       
    17 
       
    18 /**
       
    19 @file mpmdialogbase.cpp
       
    20 Mobility Policy Manager user dialog initiation.
       
    21 */
       
    22 
       
    23 // INCLUDE FILES
       
    24 #include "mpmdialogbase.h"
       
    25 
       
    26 // ============================= LOCAL FUNCTIONS ===============================
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // CMPMDialogBase::CMPMDialogBase
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CMPMDialogBase::CMPMDialogBase( CArrayPtrFlat<CMPMDialogBase>& aQueue )
       
    35     :   CActive( CActive::EPriorityStandard ),
       
    36         iQueue( aQueue )
       
    37     {
       
    38     CActiveScheduler::Add( this );
       
    39     }
       
    40 
       
    41 // -----------------------------------------------------------------------------
       
    42 // CMPMDialog::ConstructL
       
    43 // -----------------------------------------------------------------------------
       
    44 //
       
    45 void CMPMDialogBase::ConstructL()
       
    46     {
       
    47     // Start dialog immediately if the first one and otherwise
       
    48     // just append this dialog into the queue
       
    49     if ( iQueue.Count() == 0 ) 
       
    50         {
       
    51         MPMLOGSTRING2( "CMPMDialogBase<0x%x>::ConstructL() Display Dialog immediately", this )
       
    52         iQueue.AppendL( this );
       
    53         Start();
       
    54         }
       
    55     else
       
    56         {
       
    57         MPMLOGSTRING2( "CMPMDialog<0x%x>::ConstructL() Append Dialog to queue", this )
       
    58         iQueue.AppendL( this );
       
    59         }
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CMPMDialog::~CMPMDialog
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CMPMDialogBase::~CMPMDialogBase()
       
    67     {
       
    68     // Cancel everything first if we were running.
       
    69     //
       
    70     if ( iQueue.Count() > 0 && iQueue.At( 0 ) == this )
       
    71         {
       
    72         Cancel();
       
    73         MPMLOGSTRING2( "CMPMDialogBase::~CMPMDialogBase: deleted, Completing with code = %i", 
       
    74                        iStatus.Int() )
       
    75         // Remove this from the queue
       
    76         iQueue.Delete( 0 );
       
    77         // And if there are still pending dialogs, start the first one.
       
    78         if ( iQueue.Count() > 0 )
       
    79             {
       
    80             // Give pointer to this dialog in case
       
    81             // the starting dialog can utilize the
       
    82             // result from this dialog.
       
    83             iQueue.At(0)->Start( this );
       
    84             }
       
    85         }
       
    86     // We're not the first one. We can just delete ourselves.
       
    87     //
       
    88     else 
       
    89         {
       
    90         for ( TInt i = 0; i < iQueue.Count(); i++ )
       
    91             {
       
    92             if ( iQueue.At( i ) == this )
       
    93                 {
       
    94                 iQueue.Delete( i );
       
    95                 break;
       
    96                 }
       
    97             }
       
    98         }
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CMPMDialog::IsFirst
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 TBool CMPMDialogBase::IsFirst()
       
   106     {
       
   107     if ( iQueue.Count() == 0 )
       
   108         {
       
   109         return EFalse;
       
   110         }
       
   111     else
       
   112         {
       
   113         return iQueue.At( 0 ) == this;
       
   114         }
       
   115     }
       
   116 
       
   117 //  End of File