|
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: A command that completes when TSY cache is ready |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CCacheReadyNotificationCmd.h" |
|
22 |
|
23 #include "CCustomStore.h" |
|
24 #include "CCacheStatusCmd.h" |
|
25 #include "VPbkSimStoreImplError.h" |
|
26 |
|
27 // From VPbkEng |
|
28 #include <VPbkDebug.h> |
|
29 |
|
30 namespace VPbkSimStoreImpl { |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CCacheReadyNotificationCmd::CCacheReadyNotificationCmd |
|
36 // C++ default constructor can NOT contain any code, that |
|
37 // might leave. |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CCacheReadyNotificationCmd::CCacheReadyNotificationCmd( CCustomStore& aStore, |
|
41 RMmCustomAPI::TPndCacheStatus& aCacheStatus, |
|
42 CCacheStatusCmd& aCacheStatusCmd ) |
|
43 : CActive( EPriorityStandard), |
|
44 iStore( aStore ), |
|
45 iCacheStatus( aCacheStatus ), |
|
46 iCacheStatusCmd( aCacheStatusCmd ) |
|
47 { |
|
48 CActiveScheduler::Add( this ); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CCacheReadyNotificationCmd::NewLC |
|
53 // Two-phased constructor. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CCacheReadyNotificationCmd* CCacheReadyNotificationCmd::NewLC( |
|
57 CCustomStore& aStore, |
|
58 RMmCustomAPI::TPndCacheStatus& aCacheStatus, |
|
59 CCacheStatusCmd& aCacheStatusCmd ) |
|
60 { |
|
61 CCacheReadyNotificationCmd* self = |
|
62 new( ELeave ) CCacheReadyNotificationCmd( aStore, aCacheStatus, |
|
63 aCacheStatusCmd ); |
|
64 CleanupStack::PushL( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // Destructor |
|
70 CCacheReadyNotificationCmd::~CCacheReadyNotificationCmd() |
|
71 { |
|
72 CancelCmd(); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CCacheReadyNotificationCmd::Execute |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 void CCacheReadyNotificationCmd::Execute() |
|
80 { |
|
81 __ASSERT_DEBUG( iObserver, |
|
82 VPbkSimStoreImpl::Panic( EPreCondCCacheReadyNotificationCmdExecute ) ); |
|
83 |
|
84 iStore.CustomAPI().NotifyPndCacheReady( iStatus, iETelStoreName ); |
|
85 |
|
86 SetActive(); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CCacheReadyNotificationCmd::AddObserverL |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CCacheReadyNotificationCmd::AddObserverL( |
|
94 MVPbkSimCommandObserver& aObserver ) |
|
95 { |
|
96 __ASSERT_DEBUG( !iObserver, VPbkSimStoreImpl::Panic( |
|
97 EPreCondCCacheReadyNotificationCmdAddObserverL ) ); |
|
98 iObserver = &aObserver; |
|
99 } |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CCacheReadyNotificationCmd::CancelCmd |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CCacheReadyNotificationCmd::CancelCmd() |
|
106 { |
|
107 CActive::Cancel(); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CCacheReadyNotificationCmd::RunL |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CCacheReadyNotificationCmd::RunL() |
|
115 { |
|
116 TInt result = iStatus.Int(); |
|
117 |
|
118 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
119 "VPbkSimStoreImpl: RMmCustomAPI::NotifyPndCacheReady h%d complete %d,\ |
|
120 for store=%S"),iStore.CustomAPI().SubSessionHandle(), |
|
121 result,&iETelStoreName); |
|
122 |
|
123 if ( iETelStoreName.Compare( iStore.ETelName() ) == 0 ) |
|
124 { |
|
125 // Notification about target store, inform observer about results |
|
126 if ( result == KErrNone ) |
|
127 { |
|
128 iCacheStatus = RMmCustomAPI::ECacheReady; |
|
129 iObserver->CommandDone( *this ); |
|
130 } |
|
131 else |
|
132 { |
|
133 iObserver->CommandError( *this, result ); |
|
134 } |
|
135 } |
|
136 else |
|
137 { |
|
138 // Notification for different store, continue listening |
|
139 Execute(); |
|
140 // We must also get the current status because it can be that |
|
141 // TSY is just getting the cache ready and our new |
|
142 // NotifyPndCacheReady never completes. |
|
143 // The order of requests is important, first notification, then |
|
144 // current state because if notication jams then we get "cache ready" |
|
145 // from state request and can proceed. |
|
146 iCacheStatusCmd.CancelCmd(); |
|
147 iCacheStatusCmd.Execute(); |
|
148 } |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CCacheReadyNotificationCmd::DoCancel |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CCacheReadyNotificationCmd::DoCancel() |
|
156 { |
|
157 VPBK_DEBUG_PRINT(VPBK_DEBUG_STRING( |
|
158 "VPbkSimStoreImpl: RMmCustomAPI::NotifyPndCacheReady h%d Cancel"), |
|
159 iStore.CustomAPI().SubSessionHandle()); |
|
160 iStore.CustomAPI().CancelAsyncRequest( ECustomNotifyPndCacheReadyIPC ); |
|
161 } |
|
162 } // namespace VPbkSimStoreImpl |
|
163 |
|
164 // End of File |