|
1 /* |
|
2 * Copyright (c) 2005-2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "CVPbkSimPhone.h" |
|
21 |
|
22 #include <VPbkSimStoreTemplateFunctions.h> |
|
23 #include <MVPbkSimPhoneObserver.h> |
|
24 #include <VPbkSimServerOpCodes.h> |
|
25 |
|
26 // MEMBER FUNCTIONS |
|
27 CVPbkSimPhone::CVPbkSimPhone() |
|
28 : CActive(CActive::EPriorityStandard) |
|
29 { |
|
30 } |
|
31 |
|
32 void CVPbkSimPhone::ConstructL() |
|
33 { |
|
34 CActiveScheduler::Add(this); |
|
35 } |
|
36 |
|
37 CVPbkSimPhone* CVPbkSimPhone::NewL() |
|
38 { |
|
39 CVPbkSimPhone* self = new (ELeave)CVPbkSimPhone(); |
|
40 CleanupStack::PushL(self); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop(self); |
|
43 return self; |
|
44 } |
|
45 |
|
46 CVPbkSimPhone::~CVPbkSimPhone() |
|
47 { |
|
48 Cancel(); |
|
49 iObservers.Close(); |
|
50 iSimStore.Close(); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CVPbkSimPhone::AddObserverL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CVPbkSimPhone::AddObserverL( MVPbkSimPhoneObserver& aObserver ) |
|
58 { |
|
59 if ( iObservers.Find( &aObserver ) == KErrNotFound ) |
|
60 { |
|
61 iObservers.AppendL( &aObserver ); |
|
62 } |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CVPbkSimPhone::RemoveObserver |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CVPbkSimPhone::RemoveObserver( MVPbkSimPhoneObserver& aObserver ) |
|
70 { |
|
71 TInt index = iObservers.Find( &aObserver ); |
|
72 if ( index != KErrNotFound ) |
|
73 { |
|
74 iObservers.Remove( index ); |
|
75 } |
|
76 } |
|
77 |
|
78 void CVPbkSimPhone::RunL() |
|
79 { |
|
80 if (iStatus.Int() == KErrNone) |
|
81 { |
|
82 switch(iEventData.iEvent) |
|
83 { |
|
84 case EVPbkSimPhoneOpen: |
|
85 { |
|
86 VPbkSimStoreImpl::SendObserverMessageR( |
|
87 iObservers, |
|
88 &MVPbkSimPhoneObserver::PhoneOpened, |
|
89 *this ); |
|
90 break; |
|
91 } |
|
92 case EVPbkSimPhoneServiceTableUpdated: |
|
93 { |
|
94 VPbkSimStoreImpl::SendObserverMessageR( |
|
95 iObservers, |
|
96 &MVPbkSimPhoneObserver::ServiceTableUpdated, |
|
97 iEventData.iData ); |
|
98 break; |
|
99 } |
|
100 case EVPbkSimPhoneFdnStatusChanged: |
|
101 { |
|
102 VPbkSimStoreImpl::SendObserverMessageR( |
|
103 iObservers, |
|
104 &MVPbkSimPhoneObserver::FixedDiallingStatusChanged, |
|
105 iEventData.iData ); |
|
106 break; |
|
107 } |
|
108 case EVPbkSimPhoneError: // FALLTHROUGH |
|
109 default: |
|
110 { |
|
111 // iEventData.iData contains the error id |
|
112 // iEventData.iOpData contains the error value |
|
113 MVPbkSimPhoneObserver::TErrorIdentifier id = |
|
114 static_cast<MVPbkSimPhoneObserver::TErrorIdentifier>( |
|
115 iEventData.iData ); |
|
116 VPbkSimStoreImpl::SendObserverMessageRVV( |
|
117 iObservers, |
|
118 &MVPbkSimPhoneObserver::PhoneError, |
|
119 *this, |
|
120 id, |
|
121 iEventData.iOpData); |
|
122 break; |
|
123 } |
|
124 } |
|
125 } |
|
126 else |
|
127 { |
|
128 VPbkSimStoreImpl::SendObserverMessageRVV( |
|
129 iObservers, |
|
130 &MVPbkSimPhoneObserver::PhoneError, |
|
131 *this, |
|
132 MVPbkSimPhoneObserver::ESystem, |
|
133 iStatus.Int() ); |
|
134 } |
|
135 |
|
136 // start listening events |
|
137 iSimStore.ListenToStoreEvents( iStatus, iEventData ); |
|
138 SetActive(); |
|
139 } |
|
140 |
|
141 TInt CVPbkSimPhone::RunError(TInt aError) |
|
142 { |
|
143 VPbkSimStoreImpl::SendObserverMessageRVV( |
|
144 iObservers, |
|
145 &MVPbkSimPhoneObserver::PhoneError, |
|
146 *this, |
|
147 MVPbkSimPhoneObserver::ESystem, |
|
148 aError ); |
|
149 |
|
150 return KErrNone; |
|
151 } |
|
152 |
|
153 void CVPbkSimPhone::DoCancel() |
|
154 { |
|
155 iSimStore.CancelAsyncRequest( EVPbkSimSrvStoreEventNotification ); |
|
156 } |
|
157 |
|
158 void CVPbkSimPhone::OpenL( MVPbkSimPhoneObserver& aObserver ) |
|
159 { |
|
160 AddObserverL(aObserver); |
|
161 if ( iSimStore.Handle() ) |
|
162 { |
|
163 User::Leave( KErrInUse ); |
|
164 } |
|
165 // Connect to sim store server |
|
166 iSimStore.ConnectToServerL(); |
|
167 // Start listening to phone events |
|
168 iSimStore.ListenToStoreEvents( iStatus, iEventData ); |
|
169 // Open the phone |
|
170 iSimStore.OpenPhoneL(); |
|
171 SetActive(); |
|
172 } |
|
173 |
|
174 void CVPbkSimPhone::Close( MVPbkSimPhoneObserver& aObserver ) |
|
175 { |
|
176 if ( iSimStore.Handle() ) |
|
177 { |
|
178 iSimStore.ClosePhone(); |
|
179 } |
|
180 RemoveObserver(aObserver); |
|
181 } |
|
182 |
|
183 TBool CVPbkSimPhone::USimAccessSupported() const |
|
184 { |
|
185 return iSimStore.USimAccessSupported(); |
|
186 } |
|
187 |
|
188 TUint32 CVPbkSimPhone::ServiceTable() const |
|
189 { |
|
190 return iSimStore.ServiceTable(); |
|
191 } |
|
192 |
|
193 MVPbkSimPhone::TFDNStatus CVPbkSimPhone::FixedDialingStatus() const |
|
194 { |
|
195 return iSimStore.FixedDialingStatus(); |
|
196 } |
|
197 |
|
198 // End of file |