|
1 /* |
|
2 * Copyright (c) 2003 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: |
|
15 * Definition of class CBrowserTelServiceEtelWatcher. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 //INCLUDE FILES |
|
22 // Const file name for make call |
|
23 #include <mmtsy_names.h> |
|
24 |
|
25 #include "BrowserTelServiceEtelWatcher.h" |
|
26 |
|
27 |
|
28 |
|
29 // ================= MEMBER FUNCTIONS ======================= |
|
30 |
|
31 //----------------------------------------------------------------------------- |
|
32 // CBrowserTelServiceEtelWatcher::NewLC() |
|
33 //----------------------------------------------------------------------------- |
|
34 // |
|
35 CBrowserTelServiceEtelWatcher* CBrowserTelServiceEtelWatcher::NewLC( |
|
36 MBrowserTelServiceEtelWatcherObserver* aObserver ) |
|
37 { |
|
38 CBrowserTelServiceEtelWatcher* self = |
|
39 new( ELeave ) CBrowserTelServiceEtelWatcher; |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL( aObserver ); |
|
42 return self; |
|
43 } |
|
44 |
|
45 //----------------------------------------------------------------------------- |
|
46 // CBrowserTelServiceEtelWatcher::NewL() |
|
47 //----------------------------------------------------------------------------- |
|
48 // |
|
49 CBrowserTelServiceEtelWatcher* CBrowserTelServiceEtelWatcher::NewL( |
|
50 MBrowserTelServiceEtelWatcherObserver* aObserver ) |
|
51 { |
|
52 CBrowserTelServiceEtelWatcher* self = |
|
53 CBrowserTelServiceEtelWatcher::NewLC( aObserver ); |
|
54 CleanupStack::Pop(); |
|
55 return self; |
|
56 } |
|
57 |
|
58 //----------------------------------------------------------------------------- |
|
59 // CBrowserTelServiceEtelWatcher::ConstructL() |
|
60 //----------------------------------------------------------------------------- |
|
61 // |
|
62 void CBrowserTelServiceEtelWatcher::ConstructL( |
|
63 MBrowserTelServiceEtelWatcherObserver* aObserver ) |
|
64 { |
|
65 iObserver = aObserver; |
|
66 |
|
67 #ifndef __WINS__ |
|
68 RTelServer::TPhoneInfo info; |
|
69 RPhone::TLineInfo lineInfo; |
|
70 |
|
71 // Connect to the telephony server and load the TSY. |
|
72 User::LeaveIfError( iRTelServer.Connect() ); |
|
73 User::LeaveIfError( iRTelServer.LoadPhoneModule( KMmTsyModuleName ) ); |
|
74 // Get the details for the first (and only) phone. |
|
75 User::LeaveIfError( iRTelServer.GetPhoneInfo( 0, info ) ); |
|
76 // Open the phone. |
|
77 User::LeaveIfError( iRPhone.Open( iRTelServer, info.iName ) ); |
|
78 // Get the information for the voice line, line 0. |
|
79 User::LeaveIfError( iRPhone.GetLineInfo( 0, lineInfo ) ); |
|
80 // Open the line. iName will now be "VoiceLine1". |
|
81 User::LeaveIfError( iRLine.Open( iRPhone, lineInfo.iName ) ); |
|
82 |
|
83 CActiveScheduler::Add( this ); |
|
84 #endif // __WINS__ |
|
85 } |
|
86 |
|
87 //----------------------------------------------------------------------------- |
|
88 // Default C++ constructor |
|
89 //----------------------------------------------------------------------------- |
|
90 // |
|
91 CBrowserTelServiceEtelWatcher::CBrowserTelServiceEtelWatcher() : |
|
92 CActive( EPriorityNormal ) |
|
93 { |
|
94 } |
|
95 |
|
96 //----------------------------------------------------------------------------- |
|
97 // Destructor |
|
98 //----------------------------------------------------------------------------- |
|
99 // |
|
100 CBrowserTelServiceEtelWatcher::~CBrowserTelServiceEtelWatcher() |
|
101 { |
|
102 #ifndef __WINS__ |
|
103 // Cancle current activity |
|
104 Cancel(); |
|
105 |
|
106 // Close all open sessions |
|
107 iRLine.Close(); |
|
108 iRPhone.Close(); |
|
109 iRTelServer.Close(); |
|
110 #endif // __WINS__ |
|
111 } |
|
112 |
|
113 //----------------------------------------------------------------------------- |
|
114 // CBrowserTelServiceEtelWatcher::NotifyOnEtelStatusChangeL() |
|
115 //----------------------------------------------------------------------------- |
|
116 // |
|
117 void CBrowserTelServiceEtelWatcher::NotifyOnEtelStatusChangeL() |
|
118 { |
|
119 #ifndef __WINS__ |
|
120 if( !IsActive() ) |
|
121 { |
|
122 // Request notification about a change in line status |
|
123 iRLine.NotifyStatusChange( iStatus,iCallStatus ); |
|
124 SetActive(); |
|
125 } |
|
126 #endif |
|
127 } |
|
128 |
|
129 //----------------------------------------------------------------------------- |
|
130 // CBrowserTelServiceEtelWatcher::NotifyOnEtelStatusChangeCancel() |
|
131 //----------------------------------------------------------------------------- |
|
132 // |
|
133 void CBrowserTelServiceEtelWatcher::NotifyOnEtelStatusChangeCancel() |
|
134 { |
|
135 #ifndef __WINS__ |
|
136 Cancel(); |
|
137 #endif |
|
138 } |
|
139 |
|
140 //----------------------------------------------------------------------------- |
|
141 // CBrowserTelServiceEtelWatcher::RunL() |
|
142 //----------------------------------------------------------------------------- |
|
143 // |
|
144 void CBrowserTelServiceEtelWatcher::RunL() |
|
145 { |
|
146 if( iStatus.Int() == KErrNone ) |
|
147 { |
|
148 if( iCallStatus == RCall::EStatusIdle ) |
|
149 { // We are only interested in idle state, which occures |
|
150 // when the call has been hung up |
|
151 iObserver->BrowserTelServiceEtelWatcherEvent( iCallStatus ); |
|
152 } |
|
153 |
|
154 // Renew the notification request, |
|
155 iRLine.NotifyStatusChange( iStatus,iCallStatus ); |
|
156 SetActive(); |
|
157 } |
|
158 } |
|
159 |
|
160 //----------------------------------------------------------------------------- |
|
161 // CBrowserTelServiceEtelWatcher::DoCancel() |
|
162 //----------------------------------------------------------------------------- |
|
163 // |
|
164 void CBrowserTelServiceEtelWatcher::DoCancel() |
|
165 { |
|
166 iRLine.NotifyStatusChangeCancel(); |
|
167 } |