15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
18 |
18 |
19 |
19 |
|
20 #include <AknGlobalNote.h> |
|
21 #include <avkon.rsg> |
|
22 #include <bautils.h> |
|
23 #include <data_caging_path_literals.hrh> |
|
24 #include <iaupdater.rsg> |
|
25 #include <StringLoader.h> |
|
26 #include <AknUtils.h> //For AknTextUtils |
|
27 |
20 #include "iaupdaterdialog.h" |
28 #include "iaupdaterdialog.h" |
21 #include "iaupdaterdefs.h" |
29 #include "iaupdaterdefs.h" |
22 #include "iaupdatercancelobserver.h" |
30 #include "iaupdatercancelobserver.h" |
23 #include "iaupdatedebug.h" |
31 #include "iaupdatedebug.h" |
24 |
32 |
25 #include <hbtextresolversymbian.h> |
|
26 |
|
27 |
|
28 _LIT(KFilename, "iaupdate.ts"); |
|
29 _LIT(KPath, "z://data"); |
|
30 _LIT(KInstalling, "txt_software_info_installing_1"); |
|
31 |
33 |
32 // ======== LOCAL FUNCTIONS ======== |
34 // ======== LOCAL FUNCTIONS ======== |
33 |
35 |
34 // ======== MEMBER FUNCTIONS ======== |
36 // ======== MEMBER FUNCTIONS ======== |
35 |
37 |
37 // ----------------------------------------------------------------------------- |
39 // ----------------------------------------------------------------------------- |
38 // CIAUpdaterDialog::CIAUpdaterDialog |
40 // CIAUpdaterDialog::CIAUpdaterDialog |
39 // C++ default constructor |
41 // C++ default constructor |
40 // ----------------------------------------------------------------------------- |
42 // ----------------------------------------------------------------------------- |
41 // |
43 // |
42 CIAUpdaterDialog::CIAUpdaterDialog( MIAUpdaterCancelObserver& aObserver ) |
44 CIAUpdaterDialog::CIAUpdaterDialog( RFs& aFs, |
43 : iObserver ( &aObserver ) |
45 MIAUpdaterCancelObserver& aObserver ) |
44 { |
46 : CActive( CActive::EPriorityStandard ), |
45 |
47 iFs( aFs ), |
46 } |
48 iObserver ( &aObserver ) |
47 |
49 { |
|
50 CActiveScheduler::Add( this ); |
|
51 } |
48 |
52 |
49 |
53 |
50 // ----------------------------------------------------------------------------- |
54 // ----------------------------------------------------------------------------- |
51 // CIAUpdaterDialog::NewL |
55 // CIAUpdaterDialog::NewL |
52 // Two-phased constructor. |
56 // Two-phased constructor. |
53 // ----------------------------------------------------------------------------- |
57 // ----------------------------------------------------------------------------- |
54 // |
58 // |
55 CIAUpdaterDialog* CIAUpdaterDialog::NewL( MIAUpdaterCancelObserver& aObserver ) |
59 CIAUpdaterDialog* CIAUpdaterDialog::NewL( RFs& aFs, |
|
60 MIAUpdaterCancelObserver& aObserver ) |
56 { |
61 { |
57 CIAUpdaterDialog* self = |
62 CIAUpdaterDialog* self = |
58 CIAUpdaterDialog::NewLC( aObserver ); |
63 CIAUpdaterDialog::NewLC( aFs, aObserver ); |
59 CleanupStack::Pop( self ); |
64 CleanupStack::Pop( self ); |
60 return self; |
65 return self; |
61 } |
66 } |
62 |
67 |
63 |
68 |
64 // ----------------------------------------------------------------------------- |
69 // ----------------------------------------------------------------------------- |
65 // CIAUpdaterDialog::NewLC |
70 // CIAUpdaterDialog::NewLC |
66 // Two-phased constructor. |
71 // Two-phased constructor. |
67 // ----------------------------------------------------------------------------- |
72 // ----------------------------------------------------------------------------- |
68 // |
73 // |
69 CIAUpdaterDialog* CIAUpdaterDialog::NewLC( MIAUpdaterCancelObserver& aObserver ) |
74 CIAUpdaterDialog* CIAUpdaterDialog::NewLC( RFs& aFs, |
|
75 MIAUpdaterCancelObserver& aObserver ) |
70 { |
76 { |
71 CIAUpdaterDialog* self = |
77 CIAUpdaterDialog* self = |
72 new( ELeave ) CIAUpdaterDialog( aObserver ); |
78 new( ELeave ) CIAUpdaterDialog( aFs, aObserver ); |
73 CleanupStack::PushL( self ); |
79 CleanupStack::PushL( self ); |
74 self->ConstructL(); |
80 self->ConstructL(); |
75 return self; |
81 return self; |
76 } |
82 } |
77 |
83 |
84 void CIAUpdaterDialog::ConstructL() |
90 void CIAUpdaterDialog::ConstructL() |
85 { |
91 { |
86 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ConstructL begin"); |
92 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ConstructL begin"); |
87 |
93 |
88 // Get resource file path |
94 // Get resource file path |
89 iIsResolverSuccess = HbTextResolverSymbian::Init(KFilename, KPath); |
95 TFileName fileName; |
90 |
96 fileName.Copy( TParsePtrC( RProcess().FileName() ).Drive() ); |
|
97 fileName.Append( KDC_APP_RESOURCE_DIR ); |
|
98 fileName.Append( IAUpdaterDefs::KIAUpdaterResourceFile ); |
|
99 |
|
100 // Get language of resource file |
|
101 BaflUtils::NearestLanguageFile( iFs, fileName ); |
|
102 |
|
103 // Open resource file |
|
104 iResourceFile.OpenL( iFs, fileName ); |
|
105 iResourceFile.ConfirmSignatureL(); |
|
106 |
91 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ConstructL end"); |
107 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ConstructL end"); |
92 } |
108 } |
93 |
109 |
94 |
110 |
95 // ----------------------------------------------------------------------------- |
111 // ----------------------------------------------------------------------------- |
97 // C++ Destructor |
113 // C++ Destructor |
98 // ----------------------------------------------------------------------------- |
114 // ----------------------------------------------------------------------------- |
99 // |
115 // |
100 CIAUpdaterDialog::~CIAUpdaterDialog() |
116 CIAUpdaterDialog::~CIAUpdaterDialog() |
101 { |
117 { |
102 DestroyGlobalWaitNote(); |
118 Cancel(); |
|
119 delete iNote; |
|
120 iResourceFile.Close(); |
103 } |
121 } |
104 |
122 |
105 |
123 |
106 // ----------------------------------------------------------------------------- |
124 // ----------------------------------------------------------------------------- |
107 // CIAUpdaterDialog::ShowWaitingNoteL |
125 // CIAUpdaterDialog::ShowWaitingNoteL |
108 // Show global waiting note during installing. |
126 // Show global waiting note during installing. |
109 // ----------------------------------------------------------------------------- |
127 // ----------------------------------------------------------------------------- |
110 // |
128 // |
111 void CIAUpdaterDialog::ShowWaitingNoteL( const TDesC& aName, TInt /*aIndex*/, TInt /*aTotalCount*/ ) |
129 void CIAUpdaterDialog::ShowWaitingNoteL( const TDesC& aName, TInt aIndex, TInt aTotalCount ) |
112 { |
130 { |
113 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ShowWaitingNoteL begin"); |
131 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ShowWaitingNoteL begin"); |
114 |
132 if ( iNoteId == 0 ) |
115 DestroyGlobalWaitNote(); |
133 { |
116 |
134 IAUPDATE_TRACE("[IAUpdater] Creating global waiting note."); |
117 iGlobalWaitNote = CHbDeviceProgressDialogSymbian::NewL( |
135 |
118 CHbDeviceProgressDialogSymbian::EWaitDialog ); |
136 // Get localiced string from resc. file. |
119 |
137 HBufC* string = ReadResourceLC( R_IAUPDATER_INSTALLING ); |
120 // loc: Load string |
138 |
121 iGlobalResource = HbTextResolverSymbian::LoadL( KInstalling, aName ); |
139 HBufC* temp1 = HBufC::NewLC( string->Length() + aName.Length() ); |
122 if ( iGlobalResource ) |
140 TPtr temp1Ptr = temp1->Des(); |
123 iGlobalWaitNote->SetTextL( iGlobalResource->Des() ); |
141 |
124 |
142 // Add pkg's name to string (U0). |
125 // Icon ? |
143 StringLoader::Format( temp1Ptr, *string, 0, aName ); |
126 //iGlobalWaitNote->SetIconNameL(const TDesC& aIconName); |
144 |
127 |
145 // Increase buffer length for the number. |
128 // Button ? |
146 HBufC* temp2 = |
129 iGlobalWaitNote->SetButton(ETrue); |
147 HBufC::NewLC( temp1->Length() + IAUpdaterDefs::KIAUpdaterParamLen ); |
130 |
148 TPtr temp2Ptr = temp2->Des(); |
131 iGlobalWaitNote->SetObserver( this ); |
149 |
132 iGlobalWaitNote->SetAutoClose(EFalse); |
150 // Add index number to string (N1) |
133 iGlobalWaitNote->ShowL(); |
151 StringLoader::Format( temp2Ptr, *temp1, 1, aIndex ); |
134 |
152 |
|
153 // Increase buffer length for the number. |
|
154 HBufC* finalString = |
|
155 HBufC::NewLC( temp2->Length() + IAUpdaterDefs::KIAUpdaterParamLen ); |
|
156 TPtr finalPtr = finalString->Des(); |
|
157 |
|
158 // Add max count number to string (N2) |
|
159 StringLoader::Format( finalPtr, *temp2, 2, aTotalCount ); |
|
160 |
|
161 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( finalPtr ); |
|
162 if ( !iNote ) |
|
163 { |
|
164 iNote = CAknGlobalNote::NewL(); |
|
165 iNote->SetSoftkeys( R_AVKON_SOFTKEYS_CANCEL ); |
|
166 } |
|
167 |
|
168 IAUPDATE_TRACE("[IAUpdater] Showing global waiting note."); |
|
169 iNoteId = iNote->ShowNoteL( iStatus, EAknGlobalWaitNote, *finalString ); |
|
170 SetActive(); |
|
171 |
|
172 CleanupStack::PopAndDestroy( finalString ); |
|
173 CleanupStack::PopAndDestroy( temp2 ); |
|
174 CleanupStack::PopAndDestroy( temp1 ); |
|
175 CleanupStack::PopAndDestroy( string ); |
|
176 } |
135 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ShowWaitingNoteL end"); |
177 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::ShowWaitingNoteL end"); |
136 } |
178 } |
137 |
179 |
138 |
180 |
139 // ----------------------------------------------------------------------------- |
181 // ----------------------------------------------------------------------------- |
142 // ----------------------------------------------------------------------------- |
184 // ----------------------------------------------------------------------------- |
143 // |
185 // |
144 void CIAUpdaterDialog::CancelWaitingNoteL() |
186 void CIAUpdaterDialog::CancelWaitingNoteL() |
145 { |
187 { |
146 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::CancelWaitingNoteL begin"); |
188 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::CancelWaitingNoteL begin"); |
147 |
189 |
148 DestroyGlobalWaitNote(); |
190 if ( iNoteId != 0 ) |
149 |
191 { |
|
192 IAUPDATE_TRACE("[IAUpdater] Cancel waiting note."); |
|
193 iNote->CancelNoteL( iNoteId ); |
|
194 iNoteId = 0; |
|
195 } |
|
196 |
150 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::CancelWaitingNoteL end"); |
197 IAUPDATE_TRACE("[IAUpdater] CIAUpdaterDialog::CancelWaitingNoteL end"); |
151 } |
198 } |
152 |
199 |
153 void CIAUpdaterDialog::ProgressDialogCancelled( |
200 |
154 const CHbDeviceProgressDialogSymbian* /*aProgressDialog*/ ) |
201 // ----------------------------------------------------------------------------- |
155 { |
202 // CIAUpdaterDialog::LoadResourceLC |
156 |
203 // Read resource string. |
157 iObserver->UserCancel(); |
204 // ----------------------------------------------------------------------------- |
158 |
205 // |
159 } |
206 HBufC* CIAUpdaterDialog::ReadResourceLC( TInt aResourceId ) |
160 |
207 { |
161 void CIAUpdaterDialog::ProgressDialogClosed( |
208 TResourceReader reader; |
162 const CHbDeviceProgressDialogSymbian* /*aProgressDialog*/ ) |
209 HBufC8* buff = iResourceFile.AllocReadLC( aResourceId ); |
163 { |
210 reader.SetBuffer( buff ); |
164 |
211 HBufC* text = reader.ReadHBufCL(); |
165 } |
212 CleanupStack::PopAndDestroy( buff ); |
166 |
213 CleanupStack::PushL( text ); |
167 // ----------------------------------------------------------------------------- |
214 |
168 // CIAUpdaterDialog::DestroyGlobalWaitNote |
215 return text; |
169 // ----------------------------------------------------------------------------- |
216 } |
170 void CIAUpdaterDialog::DestroyGlobalWaitNote() |
217 |
171 { |
218 |
172 if ( iGlobalWaitNote ) |
219 // --------------------------------------------------------------------------- |
|
220 // CIAUpdaterDialog:::DoCancel |
|
221 // |
|
222 // --------------------------------------------------------------------------- |
|
223 // |
|
224 void CIAUpdaterDialog::DoCancel() |
|
225 { |
|
226 TRAP_IGNORE( CancelWaitingNoteL() ); |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // CIAUpdateNetworkRegistration::RunL() |
|
231 // |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 void CIAUpdaterDialog::RunL() |
|
235 { |
|
236 IAUPDATE_TRACE_1("[IAUpdater] CIAUpdaterDialog::RunL() iStatus : %d", iStatus.Int() ); |
|
237 iNoteId = 0; |
|
238 if ( iStatus.Int() == EAknSoftkeyCancel ) |
173 { |
239 { |
174 iGlobalWaitNote->Close(); |
240 iObserver->UserCancel(); |
175 delete iGlobalWaitNote; |
|
176 iGlobalWaitNote = NULL; |
|
177 delete iGlobalResource; |
|
178 iGlobalResource = NULL; |
|
179 } |
241 } |
180 } |
242 else |
181 |
243 { |
|
244 iObserver->UserExit(); |
|
245 } |
|
246 } |
|
247 |
|
248 // ======== GLOBAL FUNCTIONS ======== |
|
249 |
182 // EOF |
250 // EOF |