|
1 /* |
|
2 * Copyright (c) 2002 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: Implementation of CPhoneSettingsTestUtilities class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <etelmm.h> |
|
22 #include <MmTsy_names.h> |
|
23 #include "PSetConstants.h" |
|
24 #include "PhoneSettingsTestUtilities.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CPhoneSettingsTestUtilities::CPhoneSettingsTestUtilities |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CPhoneSettingsTestUtilities::CPhoneSettingsTestUtilities() |
|
35 { |
|
36 } |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CPhoneSettingsTestUtilities::ConstructL |
|
40 // Symbian 2nd phase constructor can leave. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 void CPhoneSettingsTestUtilities::ConstructL() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CPhoneSettingsTestUtilities::NewL |
|
49 // Two-phased constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CPhoneSettingsTestUtilities* CPhoneSettingsTestUtilities::NewL() |
|
53 |
|
54 { |
|
55 CPhoneSettingsTestUtilities* self = new (ELeave) CPhoneSettingsTestUtilities; |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop(); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // Destructor |
|
63 CPhoneSettingsTestUtilities::~CPhoneSettingsTestUtilities() |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPhoneSettingsTestUtilities::OpenPhone |
|
69 // Initilizes given RTelServer, RMobilePhone and RMobileLine objects |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CPhoneSettingsTestUtilities::OpenPhoneL( |
|
73 RTelServer& aTelServer, |
|
74 RMobilePhone& aPhone, |
|
75 RMobileLine& aLine) |
|
76 { |
|
77 // ConnectServer |
|
78 TInt err = KErrNone; |
|
79 for ( TInt a = 0 ; a < KPSetRetryCount ; a++ ) |
|
80 { |
|
81 err = aTelServer.Connect(); |
|
82 |
|
83 if ( err == KErrNone ) |
|
84 { |
|
85 break; |
|
86 } |
|
87 User::After( KPSetRetryTimeout ); |
|
88 } |
|
89 if ( err == KErrNone ) |
|
90 { |
|
91 aTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
92 } |
|
93 |
|
94 // Load phone |
|
95 User::LeaveIfError( |
|
96 aTelServer.SetExtendedErrorGranularity( RTelServer::EErrorExtended ) ); |
|
97 TInt numPhones; |
|
98 |
|
99 User::LeaveIfError( aTelServer.EnumeratePhones( numPhones ) ); |
|
100 if ( !numPhones ) |
|
101 { |
|
102 User::Leave( KErrGeneral ); |
|
103 } |
|
104 |
|
105 // Match phone name to correct one |
|
106 RTelServer::TPhoneInfo phoneInfo; |
|
107 TName matchTsyName; |
|
108 TInt i = 0; |
|
109 for ( ; i < numPhones; i++ ) |
|
110 { |
|
111 User::LeaveIfError( aTelServer.GetTsyName( i, matchTsyName ) ); |
|
112 if ( matchTsyName.CompareF( KMmTsyModuleName ) == 0 ) |
|
113 { |
|
114 User::LeaveIfError( aTelServer.GetPhoneInfo( i, phoneInfo ) ); |
|
115 break; |
|
116 } |
|
117 } |
|
118 if ( i == numPhones ) |
|
119 { |
|
120 User::Leave( KErrGeneral ); |
|
121 } |
|
122 |
|
123 User::LeaveIfError( aPhone.Open( aTelServer, phoneInfo.iName ) ); |
|
124 User::LeaveIfError( aLine.Open( aPhone, KMmTsyVoice1LineName ) ); |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CPhoneSettingsTestUtilities::ClosePhoneL |
|
129 // Closes given RTelServer, RMobilePhone and RMobileLine objects. |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 void CPhoneSettingsTestUtilities::ClosePhoneL( |
|
133 RTelServer& aTelServer, |
|
134 RMobilePhone& aPhone, |
|
135 RMobileLine& aLine) |
|
136 { |
|
137 aLine.Close(); |
|
138 aPhone.Close(); |
|
139 aTelServer.Close(); |
|
140 } |
|
141 |
|
142 |
|
143 // End of File |