videocollection/hgmyvideos/src/vcxhgtelephonyclient.cpp
changeset 0 96612d01cf9f
child 1 6711b85517b7
equal deleted inserted replaced
-1:000000000000 0:96612d01cf9f
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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 the License "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 a telephony client.*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <mmtsy_names.h>
       
    22 #include <SecUi.h>
       
    23 #include <SecUiSecurityHandler.h>
       
    24 
       
    25 #include "vcxhgtelephonyclient.h"
       
    26 
       
    27 // CONSTANTS
       
    28 const TInt KTimeBeforeRetryingServerConnection = 50000;
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS =============================
       
    31 
       
    32 // ---------------------------------------------------------------------------
       
    33 // CVcxHgTelephonyClient::CVcxHgTelephonyClient()
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 CVcxHgTelephonyClient::CVcxHgTelephonyClient()
       
    37      : iPhoneConnected( EFalse )
       
    38     {
       
    39     }
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CVcxHgTelephonyClient::~CVcxHgTelephonyClient()
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CVcxHgTelephonyClient::~CVcxHgTelephonyClient()
       
    46     {
       
    47     if ( iPhoneConnected )
       
    48         {
       
    49         // Close phone
       
    50         if ( iPhone.SubSessionHandle() )
       
    51             {
       
    52             iPhone.Close();
       
    53             }
       
    54 
       
    55         // Close ETel connection
       
    56         if ( iServer.Handle() )
       
    57             {
       
    58             iServer.UnloadPhoneModule( KMmTsyModuleName );
       
    59             iServer.Close();
       
    60             }
       
    61         }
       
    62     }
       
    63     
       
    64 // ---------------------------------------------------------------------------
       
    65 // CVcxHgTelephonyClient::CheckLockCodeL()
       
    66 // ---------------------------------------------------------------------------
       
    67 //   
       
    68 TBool CVcxHgTelephonyClient::CheckLockCodeL()
       
    69     {
       
    70     TBool lockCodeAccepted = EFalse ;
       
    71     
       
    72     if ( !iPhoneConnected )
       
    73         {
       
    74         // Connect to ETel server
       
    75         // All server connections are retried because occasional
       
    76         // fails on connections are possible, at least on some servers.
       
    77         TInt err = iServer.Connect();
       
    78         if ( err != KErrNone )
       
    79             {
       
    80             User::After( KTimeBeforeRetryingServerConnection );
       
    81             TInt err = iServer.Connect();
       
    82             }
       
    83         User::LeaveIfError( err );
       
    84         User::LeaveIfError( iServer.SetExtendedErrorGranularity(
       
    85             RTelServer::EErrorExtended ) );
       
    86 
       
    87         // Load TSY.
       
    88         err = iServer.LoadPhoneModule( KMmTsyModuleName );
       
    89         if ( KErrAlreadyExists != err )
       
    90             {
       
    91             // May also return KErrAlreadyExists if something else
       
    92             // has already loaded the TSY module. And that is
       
    93             // not an error.
       
    94             User::LeaveIfError( err );
       
    95             }
       
    96 
       
    97         // Open phones
       
    98         User::LeaveIfError( iPhone.Open( iServer, KMmTsyPhoneName ) );
       
    99         iPhoneConnected = ETrue;
       
   100         }
       
   101 
       
   102 #ifndef __WINS__
       
   103     // Initialize sec ui.
       
   104     CSecurityHandler* handler = new( ELeave ) CSecurityHandler( iPhone );
       
   105     CleanupStack::PushL( handler );
       
   106     TSecUi::InitializeLibL();
       
   107 
       
   108     lockCodeAccepted = handler->AskSecCodeL();
       
   109 
       
   110     // Uninitialize security ui.
       
   111     CleanupStack::PopAndDestroy( handler );
       
   112     TSecUi::UnInitializeLib();
       
   113 #else
       
   114     lockCodeAccepted = ETrue;
       
   115 #endif
       
   116 
       
   117     return lockCodeAccepted;
       
   118     }
       
   119