1 /* |
|
2 * ============================================================================ |
|
3 * Name : SimLockTelephonyProxy.cpp |
|
4 * Part of : Sim Lock UI Telephony Proxy |
|
5 * Description : Wrap asynchronous calls to Core Telephony |
|
6 * Version : |
|
7 * |
|
8 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
9 * All rights reserved. |
|
10 * This component and the accompanying materials are made available |
|
11 * under the terms of "Eclipse Public License v1.0" |
|
12 * which accompanies this distribution, and is available |
|
13 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
14 * |
|
15 * Initial Contributors: |
|
16 * Nokia Corporation - initial contribution. |
|
17 * |
|
18 * Contributors: |
|
19 * |
|
20 * Description: Build info file for Ado domain appinstall |
|
21 * ============================================================================ |
|
22 */ |
|
23 |
|
24 // System Includes |
|
25 #include <Etel3rdParty.h> // CTelephony |
|
26 |
|
27 // User Includes |
|
28 #include "SimLockTelephonyProxy.h" |
|
29 #include "SimLockUi.pan" |
|
30 |
|
31 |
|
32 TInt KSimLockProxyTimeout = 5000000; // 5 seconds |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // CSimLockDataHandlingDelegate::NewL |
|
36 // --------------------------------------------------------------------------- |
|
37 CSimLockTelephonyProxy* CSimLockTelephonyProxy::NewL() |
|
38 { |
|
39 CSimLockTelephonyProxy* self = new ( ELeave ) CSimLockTelephonyProxy(); |
|
40 CleanupStack::PushL( self ); |
|
41 self->ConstructL(); |
|
42 CleanupStack::Pop( self ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CSimLockTelephonyProxy::CSimLockTelephonyProxy |
|
48 // --------------------------------------------------------------------------- |
|
49 CSimLockTelephonyProxy::~CSimLockTelephonyProxy() |
|
50 { |
|
51 Cancel(); |
|
52 delete iTelephony; |
|
53 delete iSchedulerWait; |
|
54 delete iTimer; |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CSimLockTelephonyProxy::IsCallInProgress |
|
59 // --------------------------------------------------------------------------- |
|
60 TBool CSimLockTelephonyProxy::IsCallInProgress() |
|
61 { |
|
62 iTelephony->GetIndicator( iStatus, iIndicatorPackage ); |
|
63 CompleteRequestWithTimeout(); |
|
64 |
|
65 if ( iStatus != KErrNone ) |
|
66 { |
|
67 // If there is an error obtaining status, assume no call in progress |
|
68 } |
|
69 else if ( iIndicators.iIndicator & CTelephony::KIndCallInProgress ) |
|
70 { |
|
71 return ETrue; |
|
72 } |
|
73 |
|
74 return EFalse; |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CSimLockTelephonyProxy::RunL |
|
79 // --------------------------------------------------------------------------- |
|
80 void CSimLockTelephonyProxy::RunL() |
|
81 { |
|
82 // Stop the current run sequence so we can continue execution in a |
|
83 // synchronous fashion |
|
84 iSchedulerWait->AsyncStop(); |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CSimLockTelephonyProxy::DoCancel |
|
89 // --------------------------------------------------------------------------- |
|
90 void CSimLockTelephonyProxy::DoCancel() |
|
91 { |
|
92 // Cancel outstanding request |
|
93 iTelephony->CancelAsync( CTelephony::EGetIndicatorCancel ); |
|
94 iSchedulerWait->AsyncStop(); |
|
95 } |
|
96 |
|
97 // --------------------------------------------------------------------------- |
|
98 // CSimLockTelephonyProxy::CSimLockTelephonyProxy |
|
99 // --------------------------------------------------------------------------- |
|
100 CSimLockTelephonyProxy::CSimLockTelephonyProxy() |
|
101 : CActive( EPriorityStandard ), |
|
102 iIndicatorPackage( iIndicators ) |
|
103 { |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // CSimLockTelephonyProxy::ConstructL |
|
108 // --------------------------------------------------------------------------- |
|
109 void CSimLockTelephonyProxy::ConstructL() |
|
110 { |
|
111 CActiveScheduler::Add( this ); |
|
112 iSchedulerWait = new ( ELeave ) CActiveSchedulerWait; |
|
113 iTelephony = CTelephony::NewL(); |
|
114 iTimer = CPeriodic::NewL(EPriorityHigh); |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CSimLockTelephonyProxy::TimerElapsed |
|
119 // --------------------------------------------------------------------------- |
|
120 TInt CSimLockTelephonyProxy::TimerElapsed(TAny* aClientObject) |
|
121 { |
|
122 CSimLockTelephonyProxy* clientObject = static_cast<CSimLockTelephonyProxy*>(aClientObject); |
|
123 |
|
124 // Timeout timer has elapsed. An asynchronous request timed out. |
|
125 ASSERT(0); |
|
126 |
|
127 // Cancel original request |
|
128 clientObject->Cancel(); |
|
129 return 0; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CSimLockTelephonyProxy::CompleteRequestWithTimeout |
|
134 // --------------------------------------------------------------------------- |
|
135 void CSimLockTelephonyProxy::CompleteRequestWithTimeout() |
|
136 { |
|
137 |
|
138 if ( iTimer->IsActive() ) |
|
139 { |
|
140 ASSERT(0); |
|
141 iTimer->Cancel(); |
|
142 } |
|
143 |
|
144 // Start timer with KSimLockProxyTimeout to protect against requests that |
|
145 // do not complete for some reason. |
|
146 iTimer->Start(KSimLockProxyTimeout,0,TCallBack(&TimerElapsed, this)); |
|
147 |
|
148 SetActive(); |
|
149 |
|
150 // Wait for request to complete. Response time is expected to be negligible. |
|
151 iSchedulerWait->Start(); |
|
152 |
|
153 iTimer->Cancel(); |
|
154 } |
|
155 |
|
156 // end of file |
|
157 |
|