1 /* |
|
2 * Copyright (c) 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 "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 the CVmbxETelConnection class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <mmtsy_names.h> |
|
21 |
|
22 #include "vmbxlogger.h" |
|
23 #include "vmbxetelconnection.h" |
|
24 |
|
25 // CONSTANTS |
|
26 // ETel connections attemps |
|
27 const TInt KTriesToConnectServer( 7 ); |
|
28 // time between ETel connections attemps |
|
29 const TInt KTimeBeforeRetryingServerConnection( 100000 ); |
|
30 // Index to the first phone info |
|
31 const TInt KFirstPhoneIndex = 0; |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS ============================= |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CVmbxETelConnection::CVmbxETelConnection |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CVmbxETelConnection::CVmbxETelConnection() |
|
42 { |
|
43 VMBLOGSTRING( "VMBX: CVmbxETelConnection::CVmbxETelConnection <=>" ); |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CVmbxETelConnection::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CVmbxETelConnection::ConstructL() |
|
52 { |
|
53 VMBLOGSTRING( "VMBX: CVmbxETelConnection::ConstructL =>" ); |
|
54 TInt errorCode( KErrNone ); |
|
55 TInt thisTry( 0 ); |
|
56 RTelServer::TPhoneInfo info; |
|
57 // connect to ETel server |
|
58 while ( ( errorCode = iTelServer.Connect() ) != KErrNone && |
|
59 ( thisTry++ ) <= KTriesToConnectServer ) |
|
60 { |
|
61 User::After( KTimeBeforeRetryingServerConnection ); |
|
62 } |
|
63 VMBLOGSTRING2( "VMBX: CVmbxETelConnection::ConstructL: errorCode %I", |
|
64 errorCode ); |
|
65 User::LeaveIfError( errorCode ); |
|
66 |
|
67 // load TSY |
|
68 errorCode = iTelServer.LoadPhoneModule( KMmTsyModuleName ); |
|
69 VMBLOGSTRING2( "VMBX: CVmbxETelConnection::ConstructL: err%I", errorCode ); |
|
70 if ( KErrNone != errorCode && KErrAlreadyExists != errorCode ) |
|
71 { |
|
72 User::Leave( errorCode ); |
|
73 } |
|
74 |
|
75 // This enables extended errors from low level which are needed |
|
76 // to get detailed information when saving contacts |
|
77 TInt errExtrnded = iTelServer.SetExtendedErrorGranularity( |
|
78 RTelServer::EErrorExtended ); |
|
79 VMBLOGSTRING2( "VMBX: CVmbxETelConnection::ConstructL: errExtrnded %I", |
|
80 errExtrnded ); |
|
81 User::LeaveIfError( errExtrnded ); |
|
82 // get info about default phone |
|
83 TInt errGetInfo = iTelServer.GetPhoneInfo( KFirstPhoneIndex, info ); |
|
84 VMBLOGSTRING2( "VMBX: CVmbxETelConnection::ConstructL: errGetInfo %I", |
|
85 errGetInfo ); |
|
86 User::LeaveIfError( errGetInfo ); |
|
87 |
|
88 TInt errInfoName = iPhone.Open( iTelServer, info.iName ); |
|
89 VMBLOGSTRING2( "VMBX: CVmbxETelConnection::ConstructL: errInfoName %I", |
|
90 errInfoName ); |
|
91 User::LeaveIfError( errInfoName ); |
|
92 |
|
93 VMBLOGSTRING( "VMBX: CVmbxETelConnection::ConstructL <=" ); |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------------------------- |
|
97 // CVmbxETelConnection::NewL |
|
98 // Two-phased constructor. |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 CVmbxETelConnection* CVmbxETelConnection::NewL() |
|
102 { |
|
103 VMBLOGSTRING( "VMBX: CVmbxETelConnection::NewL =>" ); |
|
104 CVmbxETelConnection* self = new( ELeave ) CVmbxETelConnection(); |
|
105 CleanupStack::PushL( self ); |
|
106 self->ConstructL(); |
|
107 CleanupStack::Pop(); |
|
108 VMBLOGSTRING( "VMBX: CVmbxETelConnection::NewL <=" ); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CVmbxETelConnection::~CVmbxETelConnection() |
|
114 // Destructor |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 CVmbxETelConnection::~CVmbxETelConnection() |
|
118 { |
|
119 VMBLOGSTRING( "VMBX: CVmbxETelConnection::~CVmbxETelConnection =>" ); |
|
120 // close ETel connection |
|
121 iPhone.Close(); |
|
122 iTelServer.Close(); |
|
123 VMBLOGSTRING( "VMBX: CVmbxETelConnection::~CVmbxETelConnection <=" ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CVmbxETelConnection::TelServer |
|
128 // Returns a reference to the ETel RTelServer |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 RTelServer& CVmbxETelConnection::TelServer() |
|
132 { |
|
133 VMBLOGSTRING( "VMBX: CVmbxETelConnection::TelServer <=>" ); |
|
134 return iTelServer; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CVmbxETelConnection::Phone |
|
139 // Returns a reference to the ETel RMobilePhone |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 RMobilePhone& CVmbxETelConnection::Phone() |
|
143 { |
|
144 VMBLOGSTRING( "VMBX: CVmbxETelConnection::Phone <=>" ); |
|
145 return iPhone; |
|
146 } |
|
147 |
|
148 // End of file |
|