|
1 /* |
|
2 * Copyright (c) 2002-2008 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: This is the handler for various notifications related to |
|
15 * those SIM Application Toolkit proactive commands that |
|
16 * uses notifications to inform user about their actions. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include <e32base.h> |
|
24 #include <e32svr.h> |
|
25 #include "RSatUiSession.h" |
|
26 #include "MSatUiObserver.h" |
|
27 #include "SatSOpcodes.h" |
|
28 #include "CSatCNotifyHandler.h" |
|
29 #include "SatLog.h" |
|
30 |
|
31 // CONSTANTS |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CSatCNotifyHandler::CSatCNotifyHandler |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 //lint -e{1403, 1769} Can not be initialized, harmless. |
|
42 CSatCNotifyHandler::CSatCNotifyHandler( |
|
43 TInt aPriority, |
|
44 RSatUiSession* aSession ) : |
|
45 CActive( aPriority ), |
|
46 iSession( aSession ), |
|
47 iNotifyData(), |
|
48 iNotifyPckg( iNotifyData ), |
|
49 iNotifyRsp(), |
|
50 iNotifyRspPckg( iNotifyRsp ) |
|
51 { |
|
52 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::CSatCNotifyHandler calling" ) |
|
53 |
|
54 // Add to active scheduler. |
|
55 CActiveScheduler::Add( this ); |
|
56 |
|
57 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::CSatCNotifyHandler exiting" ) |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CSatCNotifyHandler::NewL |
|
62 // Two-phased constructor. |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CSatCNotifyHandler* CSatCNotifyHandler::NewL( |
|
66 RSatUiSession* aSat ) |
|
67 { |
|
68 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::NewL calling" ) |
|
69 |
|
70 // Perform construction. |
|
71 CSatCNotifyHandler* self = |
|
72 new ( ELeave ) CSatCNotifyHandler( EPriorityLow, aSat ); |
|
73 |
|
74 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::NewL exiting" ) |
|
75 return self; |
|
76 } |
|
77 |
|
78 // Destructor |
|
79 CSatCNotifyHandler::~CSatCNotifyHandler() |
|
80 { |
|
81 LOG( SIMPLE, |
|
82 "SATINTERNALCLIENT: CSatCNotifyHandler::~CSatCNotifyHandler calling" ) |
|
83 |
|
84 // Cancel any outstanding requests. |
|
85 Cancel(); |
|
86 iSession = NULL; |
|
87 |
|
88 LOG( SIMPLE, |
|
89 "SATINTERNALCLIENT: CSatCNotifyHandler::~CSatCNotifyHandler exiting" ) |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CSatCNotifyHandler::Start |
|
94 // Starts the handler. |
|
95 // (other items were commented in a header). |
|
96 // ----------------------------------------------------------------------------- |
|
97 // |
|
98 void CSatCNotifyHandler::Start() |
|
99 { |
|
100 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::Start calling" ) |
|
101 |
|
102 // Empty the IPC data |
|
103 TSatNotificationV1 temp; |
|
104 iNotifyData = temp; |
|
105 TSatNotificationRspV1 temp2; |
|
106 temp2.iAccepted = EFalse; |
|
107 temp2.iCommand = ESatSSendDataNotify; |
|
108 iNotifyRsp = temp2; |
|
109 |
|
110 // Request notification. |
|
111 TIpcArgs arguments( &iNotifyPckg ); |
|
112 |
|
113 // Pass the notification IPC package. |
|
114 iSession->CreateRequest( ESatSProactiveNotification, arguments, iStatus ); |
|
115 |
|
116 // Set this handler to active so that it can receive requests. |
|
117 SetActive(); |
|
118 |
|
119 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::Start exiting" ) |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CSatCNotifyHandler::RunL |
|
124 // Handles the command. |
|
125 // (other items were commented in a header). |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CSatCNotifyHandler::RunL() |
|
129 { |
|
130 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::RunL calling" ) |
|
131 |
|
132 // Check the status of the asnychronous operation |
|
133 if ( KErrNone != iStatus.Int() ) |
|
134 { |
|
135 LOG2( |
|
136 SIMPLE, |
|
137 "SATINTERNALCLIENT: CSatCNotifyHandler::RunL error: %d", |
|
138 iStatus.Int() ) |
|
139 |
|
140 // Renew the request |
|
141 Start(); |
|
142 } |
|
143 |
|
144 else |
|
145 { |
|
146 // This will contain the result of the user query. |
|
147 TBool userQuery( ETrue ); |
|
148 |
|
149 // This will contain EFalse if requested icon is not displayed. |
|
150 // And if icon is displayed, it contains ETrue. |
|
151 TBool requestedIconDisplayed( EFalse ); |
|
152 |
|
153 // This will contain the result that has the user pressed end key. |
|
154 TBool terminatedByUser( EFalse ); |
|
155 |
|
156 // Has to be casted to TInt before casting to TSatIconQualifier, because |
|
157 // GCC warns about the direct cast. |
|
158 const struct TSatIconId iconId = |
|
159 { |
|
160 iNotifyData.iIconId.iIdentifier, |
|
161 static_cast<TSatIconQualifier>( |
|
162 static_cast<TInt>( |
|
163 iNotifyData.iIconId.iIconQualifier ) ) |
|
164 }; |
|
165 |
|
166 // Send notification to UI |
|
167 TSatUiResponse response = iSession->SatUiObserver()->Notification( |
|
168 iNotifyData.iCommand, |
|
169 iNotifyData.iAlphaIdStatus, |
|
170 iNotifyData.iText, |
|
171 iconId, |
|
172 requestedIconDisplayed, |
|
173 iNotifyData.iControlResult ); |
|
174 |
|
175 // Check response |
|
176 if ( ESatSuccess != response ) |
|
177 { |
|
178 LOG( SIMPLE, |
|
179 "SATINTERNALCLIENT: CSatCNotifyHandler::RunL ESatSuccess != response" ) |
|
180 terminatedByUser = ETrue; |
|
181 } |
|
182 |
|
183 // Indicate SAT Server that notification is complete |
|
184 iNotifyRsp.iCommand = iNotifyData.iCommand; |
|
185 iNotifyRsp.iRequestedIconDisplayed = requestedIconDisplayed; |
|
186 iNotifyRsp.iSessionTerminatedByUser = terminatedByUser; |
|
187 iNotifyRsp.iAccepted = userQuery; |
|
188 |
|
189 // Pass the notification response IPC package. |
|
190 TIpcArgs arguments( &iNotifyRspPckg ); |
|
191 |
|
192 // Perform the IPC data transfer. |
|
193 iSession->CreateRequest( ESatSProactiveNotificationResponse, arguments ); |
|
194 |
|
195 Start(); |
|
196 } |
|
197 |
|
198 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::RunL exiting" ) |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CSatCNotifyHandler::DoCancel |
|
203 // Cancels the pending request. |
|
204 // (other items were commented in a header). |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 void CSatCNotifyHandler::DoCancel() |
|
208 { |
|
209 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::DoCancel calling" ) |
|
210 |
|
211 // Complete the request with cancel code. |
|
212 TRequestStatus* requestStatus = &iStatus; |
|
213 User::RequestComplete( requestStatus, KErrCancel ); |
|
214 |
|
215 LOG( SIMPLE, "SATINTERNALCLIENT: CSatCNotifyHandler::DoCancel exiting" ) |
|
216 } |
|
217 |
|
218 // End of File |