securitydialogs/simlockui/src/SimLockUIDocument.cpp
changeset 14 b75757c81051
parent 1 d5423fbb4f29
child 15 318c4eab2439
equal deleted inserted replaced
1:d5423fbb4f29 14:b75757c81051
     1 /*
       
     2 * ============================================================================
       
     3 *  Name        : SimLockUIDocument.cpp
       
     4 *  Part of     : Sim Lock UI Application
       
     5 *  Description : Implementation of Sim Lock UI Application
       
     6 *  Version     : 
       
     7 *  
       
     8 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
       
     9 * All rights reserved.
       
    10 * This component and the accompanying materials are made available
       
    11 * under the terms of "Eclipse Public License v1.0"
       
    12 * which accompanies this distribution, and is available
       
    13 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    14 *
       
    15 * Initial Contributors:
       
    16 * Nokia Corporation - initial contribution.
       
    17 *
       
    18 * Contributors:
       
    19 *
       
    20 * Description:   Build info file for Ado domain appinstall 
       
    21 *
       
    22 * ============================================================================
       
    23 */
       
    24 
       
    25 // System Include Files
       
    26 #include <RMmCustomAPI.h>           // RMmCustomAPI, RMobilePhone
       
    27 #include <MmTsy_names.h>            // KMmTsyModuleName
       
    28 #include <RMmCustomAPI.h>
       
    29 
       
    30 // User Include Files
       
    31 #include "SimLockDataHandlingDelegate.h"
       
    32 #include "SimLockISAServerDefinitions.h"
       
    33 #include "SimLockUIAppUi.h"
       
    34 #include "SimLockUIDocument.h"
       
    35 
       
    36 // Local Constants
       
    37 const TInt KTriesToConnectServer( 2 );
       
    38 const TInt KTimeBeforeRetryingServerConnection( 50000 );
       
    39 static const TInt KPhoneInfoIndex( 0 );
       
    40 
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CSimLockUIDocument::NewL
       
    44 // ---------------------------------------------------------------------------
       
    45 CSimLockUIDocument* CSimLockUIDocument::NewL( CEikApplication& aApp )
       
    46     {
       
    47     CSimLockUIDocument* self = NewLC( aApp );
       
    48     CleanupStack::Pop( self );
       
    49     return self;
       
    50     }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CSimLockUIDocument::NewLC
       
    54 // ---------------------------------------------------------------------------
       
    55 CSimLockUIDocument* CSimLockUIDocument::NewLC( CEikApplication& aApp )
       
    56     {
       
    57     CSimLockUIDocument* self = new ( ELeave ) CSimLockUIDocument( aApp );
       
    58     CleanupStack::PushL( self );
       
    59     self->ConstructL();
       
    60     return self;
       
    61     }
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CSimLockUIDocument::~CSimLockUIDocument
       
    65 // ---------------------------------------------------------------------------
       
    66 CSimLockUIDocument::~CSimLockUIDocument()
       
    67     {
       
    68     // Close phone
       
    69     if ( iPhone.SubSessionHandle() )
       
    70         {
       
    71         iPhone.Close();
       
    72         }
       
    73 
       
    74     // Close custom phone
       
    75     if ( iCustomPhone.SubSessionHandle() )
       
    76         {
       
    77         iCustomPhone.Close();
       
    78         }
       
    79 
       
    80     // Close ETel connection
       
    81     if ( iServer.Handle() )
       
    82         {
       
    83         iServer.UnloadPhoneModule( KMmTsyModuleName );
       
    84         iServer.Close();
       
    85         }
       
    86 
       
    87     // Delete simlock delegate
       
    88     delete iSimLockDelegate;
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CSimLockUIDocument::CreateAppUiL
       
    93 // ---------------------------------------------------------------------------
       
    94 CEikAppUi* CSimLockUIDocument::CreateAppUiL()
       
    95     {
       
    96     // Create the application user interface, and return a pointer to it,
       
    97     // the framework takes ownership of this object
       
    98     CEikAppUi* appUi = new(ELeave)CSimLockUIAppUi( *iSimLockDelegate );
       
    99     return appUi;
       
   100     }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CSimLockUIDocument::ConstructL
       
   104 // ---------------------------------------------------------------------------
       
   105 void CSimLockUIDocument::ConstructL()
       
   106     {
       
   107     RTelServer::TPhoneInfo phoneInfo;
       
   108 
       
   109     TInt error( KErrGeneral );
       
   110 
       
   111     // Connect to ETel server
       
   112     // All server connections are tried to be made KTriesToConnectServer times because occasional
       
   113     // fails on connections are possible, at least on some servers.
       
   114     for ( TInt thisTry=0; thisTry<KTriesToConnectServer; thisTry++ )
       
   115         {
       
   116         error = iServer.Connect();
       
   117         if ( error == KErrNone )
       
   118             {
       
   119             break;
       
   120             }
       
   121             
       
   122         // Very small delay.  Does not have negative impact on UI.  Justifiable as workaround
       
   123         // for potential failure.
       
   124         User::After( KTimeBeforeRetryingServerConnection );
       
   125         }
       
   126     User::LeaveIfError( error );
       
   127 
       
   128     // load TSY module
       
   129     error = iServer.LoadPhoneModule( KMmTsyModuleName );
       
   130     if ( error != KErrAlreadyExists )
       
   131         {
       
   132         // May also return KErrAlreadyExists if something else
       
   133         // has already loaded the TSY module. And that is
       
   134         // not an error.
       
   135         User::LeaveIfError( error );
       
   136         }
       
   137 
       
   138     // Set TSY paramaters and open RPhone handle, then RMobilePhone handle
       
   139     User::LeaveIfError( iServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) );
       
   140     User::LeaveIfError( iServer.GetPhoneInfo( KPhoneInfoIndex, phoneInfo ) );
       
   141     User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );
       
   142     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
       
   143 
       
   144     // Create SimLock Data Handling Delegate
       
   145     iSimLockDelegate = CSimLockDataHandlingDelegate::NewL( iCustomPhone );
       
   146     }
       
   147 
       
   148 // ---------------------------------------------------------------------------
       
   149 // CSimLockUIDocument::CSimLockUIDocument
       
   150 // ---------------------------------------------------------------------------
       
   151 CSimLockUIDocument::CSimLockUIDocument( CEikApplication& aApp )
       
   152     : CAknDocument( aApp )
       
   153     {
       
   154     // no implementation required
       
   155     }
       
   156 
       
   157 // end of file.
       
   158