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