phoneclientserver/phoneserver/Src/Standard/CPhSrvPhoneController.cpp
changeset 46 2fa1fa551b0b
parent 42 35488577e233
child 48 78df25012fda
equal deleted inserted replaced
42:35488577e233 46:2fa1fa551b0b
     1 /*
       
     2 * Copyright (c) 2002-2004 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:  Phone Controller.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "cphsrvphonecontroller.h" 
       
    22 #include <mmtsy_names.h>
       
    23 
       
    24 
       
    25 // CONSTANTS
       
    26 #define KPhSrvTsyName KMmTsyModuleName
       
    27 
       
    28 const TInt KPhSrvTSYNameMaxLength( 80 );
       
    29 const TInt KPhSrvETelRetryCount = 7;
       
    30 const TInt KPhSrvETelRetryTimeout = 100000; // us
       
    31 
       
    32 
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CPhSrvPhoneController::~CPhSrvPhoneController
       
    38 // 
       
    39 // C++ destructor
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 /*****************************************************
       
    43 *   Series 60 Customer / ETel
       
    44 *   Series 60  ETel API
       
    45 *****************************************************/
       
    46 CPhSrvPhoneController::~CPhSrvPhoneController()
       
    47     {
       
    48     iCustomPhone.Close();
       
    49     iMobilePhone.Close();
       
    50     iETelServer.Close();
       
    51     }
       
    52 
       
    53 
       
    54 // -----------------------------------------------------------------------------
       
    55 // CPhSrvPhoneController::ConstructL
       
    56 // 
       
    57 // Symbian OS 2nd phase constructor
       
    58 // -----------------------------------------------------------------------------
       
    59 //
       
    60 /*****************************************************
       
    61 *   Series 60 Customer / ETel
       
    62 *   Series 60  ETel API
       
    63 *****************************************************/
       
    64 void CPhSrvPhoneController::ConstructL()
       
    65     {
       
    66     TInt err = KErrNone; 
       
    67     TInt phones = 0; // no phones.
       
    68 
       
    69 
       
    70     // Retry ETel connection if needed:
       
    71     for ( TInt a = 0 ; a < KPhSrvETelRetryCount ; a++ )
       
    72         {
       
    73         err = iETelServer.Connect();
       
    74         if ( err == KErrNone )
       
    75             {
       
    76             break;
       
    77             }
       
    78         User::After( KPhSrvETelRetryTimeout );
       
    79         }
       
    80     User::LeaveIfError( err );
       
    81 
       
    82     err = iETelServer.LoadPhoneModule(KPhSrvTsyName);
       
    83     if ( err != KErrNone && err != KErrAlreadyExists )
       
    84         {
       
    85         User::Leave( err );
       
    86         }
       
    87 
       
    88     RTelServer::TPhoneInfo info;
       
    89     TBuf< KPhSrvTSYNameMaxLength > tsyName;
       
    90     iETelServer.EnumeratePhones( phones );
       
    91 
       
    92     TInt i = 0; // index starts from zero.
       
    93     for (; i < phones ; i++ )
       
    94         {
       
    95         err = iETelServer.GetPhoneInfo( i, info );
       
    96         User::LeaveIfError( err );
       
    97 
       
    98         err = iETelServer.GetTsyName( i, tsyName );
       
    99         User::LeaveIfError( err );
       
   100 
       
   101         if ( !tsyName.CompareF( KPhSrvTsyName ) )
       
   102             {
       
   103             break;
       
   104             }
       
   105         }
       
   106 
       
   107     if ( i == phones )
       
   108         {
       
   109         User::Leave( KErrNotSupported );
       
   110         }
       
   111 
       
   112     User::LeaveIfError( 
       
   113         iETelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) );
       
   114 
       
   115     User::LeaveIfError( iMobilePhone.Open( iETelServer , info.iName ) );
       
   116 
       
   117     User::LeaveIfError( iCustomPhone.Open( iMobilePhone ) );
       
   118 
       
   119     }
       
   120 
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CPhSrvPhoneController::PhSrvETelServer
       
   124 // 
       
   125 // Access the ETel session.
       
   126 // -----------------------------------------------------------------------------
       
   127 //
       
   128 /*****************************************************
       
   129 *   Series 60 Customer / ETel
       
   130 *   Series 60  ETel API
       
   131 *****************************************************/
       
   132 RTelServer& CPhSrvPhoneController::PhSrvETelServer()
       
   133     {
       
   134     return iETelServer;
       
   135     }
       
   136 
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CPhSrvPhoneController::PhSrvMobilePhone
       
   140 // 
       
   141 // Access the GSM phone subsession.
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 /*****************************************************
       
   145 *   Series 60 Customer / ETel
       
   146 *   Series 60  ETel API
       
   147 *****************************************************/
       
   148 RMobilePhone& CPhSrvPhoneController::PhSrvMobilePhone()
       
   149     {
       
   150     return iMobilePhone;
       
   151     }
       
   152 
       
   153 
       
   154 // -----------------------------------------------------------------------------
       
   155 // CPhSrvPhoneController::PhSrvCustomPhone
       
   156 // 
       
   157 // Access the custom phone subsession.
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 /*****************************************************
       
   161 *   Series 60 Customer / ETel
       
   162 *   Series 60  ETel API
       
   163 *****************************************************/
       
   164 RMmCustomAPI& CPhSrvPhoneController::PhSrvCustomPhone()
       
   165     {
       
   166     return iCustomPhone;
       
   167     }
       
   168 
       
   169 // End of File