securitydialogs/simlockui/src/SimLockUIDocument.cpp
branchRCL_3
changeset 22 03674e5abf46
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
       
     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 
       
    29 // User Include Files
       
    30 #include "simlockdatahandlingdelegate.h"
       
    31 #include "simlockisaserverdefinitions.h"
       
    32 #include "simlockuiappui.h"
       
    33 #include "simlockuidocument.h"
       
    34 
       
    35 // Local Constants
       
    36 const TInt KTriesToConnectServer( 2 );
       
    37 const TInt KTimeBeforeRetryingServerConnection( 50000 );
       
    38 static const TInt KPhoneInfoIndex( 0 );
       
    39 
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CSimLockUIDocument::NewL
       
    43 // ---------------------------------------------------------------------------
       
    44 CSimLockUIDocument* CSimLockUIDocument::NewL( CEikApplication& aApp )
       
    45     {
       
    46     CSimLockUIDocument* self = NewLC( aApp );
       
    47     CleanupStack::Pop( self );
       
    48     return self;
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CSimLockUIDocument::NewLC
       
    53 // ---------------------------------------------------------------------------
       
    54 CSimLockUIDocument* CSimLockUIDocument::NewLC( CEikApplication& aApp )
       
    55     {
       
    56     CSimLockUIDocument* self = new ( ELeave ) CSimLockUIDocument( aApp );
       
    57     CleanupStack::PushL( self );
       
    58     self->ConstructL();
       
    59     return self;
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------------------------
       
    63 // CSimLockUIDocument::~CSimLockUIDocument
       
    64 // ---------------------------------------------------------------------------
       
    65 CSimLockUIDocument::~CSimLockUIDocument()
       
    66     {
       
    67     // Close phone
       
    68     if ( iPhone.SubSessionHandle() )
       
    69         {
       
    70         iPhone.Close();
       
    71         }
       
    72 
       
    73     // Close custom phone
       
    74     if ( iCustomPhone.SubSessionHandle() )
       
    75         {
       
    76         iCustomPhone.Close();
       
    77         }
       
    78 
       
    79     // Close ETel connection
       
    80     if ( iServer.Handle() )
       
    81         {
       
    82         iServer.UnloadPhoneModule( KMmTsyModuleName );
       
    83         iServer.Close();
       
    84         }
       
    85 
       
    86     // Delete simlock delegate
       
    87     delete iSimLockDelegate;
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------------------------
       
    91 // CSimLockUIDocument::CreateAppUiL
       
    92 // ---------------------------------------------------------------------------
       
    93 CEikAppUi* CSimLockUIDocument::CreateAppUiL()
       
    94     {
       
    95     // Create the application user interface, and return a pointer to it,
       
    96     // the framework takes ownership of this object
       
    97     CEikAppUi* appUi = new(ELeave)CSimLockUIAppUi( *iSimLockDelegate );
       
    98     return appUi;
       
    99     }
       
   100 
       
   101 // ---------------------------------------------------------------------------
       
   102 // CSimLockUIDocument::ConstructL
       
   103 // ---------------------------------------------------------------------------
       
   104 void CSimLockUIDocument::ConstructL()
       
   105     {
       
   106     RTelServer::TPhoneInfo phoneInfo;
       
   107 
       
   108     TInt error( KErrGeneral );
       
   109 
       
   110     // Connect to ETel server
       
   111     // All server connections are tried to be made KTriesToConnectServer times because occasional
       
   112     // fails on connections are possible, at least on some servers.
       
   113     for ( TInt thisTry=0; thisTry<KTriesToConnectServer; thisTry++ )
       
   114         {
       
   115         error = iServer.Connect();
       
   116         if ( error == KErrNone )
       
   117             {
       
   118             break;
       
   119             }
       
   120             
       
   121         // Very small delay.  Does not have negative impact on UI.  Justifiable as workaround
       
   122         // for potential failure.
       
   123         User::After( KTimeBeforeRetryingServerConnection );
       
   124         }
       
   125     User::LeaveIfError( error );
       
   126 
       
   127     // load TSY module
       
   128     error = iServer.LoadPhoneModule( KMmTsyModuleName );
       
   129     if ( error != KErrAlreadyExists )
       
   130         {
       
   131         // May also return KErrAlreadyExists if something else
       
   132         // has already loaded the TSY module. And that is
       
   133         // not an error.
       
   134         User::LeaveIfError( error );
       
   135         }
       
   136 
       
   137     // Set TSY paramaters and open RPhone handle, then RMobilePhone handle
       
   138     User::LeaveIfError( iServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) );
       
   139     User::LeaveIfError( iServer.GetPhoneInfo( KPhoneInfoIndex, phoneInfo ) );
       
   140     User::LeaveIfError( iPhone.Open( iServer, phoneInfo.iName ) );
       
   141     User::LeaveIfError( iCustomPhone.Open( iPhone ) );
       
   142 
       
   143     // Create SimLock Data Handling Delegate
       
   144     iSimLockDelegate = CSimLockDataHandlingDelegate::NewL( iCustomPhone );
       
   145     }
       
   146 
       
   147 // ---------------------------------------------------------------------------
       
   148 // CSimLockUIDocument::CSimLockUIDocument
       
   149 // ---------------------------------------------------------------------------
       
   150 CSimLockUIDocument::CSimLockUIDocument( CEikApplication& aApp )
       
   151     : CAknDocument( aApp )
       
   152     {
       
   153     // no implementation required
       
   154     }
       
   155 
       
   156 // end of file.
       
   157