|
1 /* |
|
2 * Copyright (c) 2000 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: CSCPUserInf implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "SCPUserInf.h" |
|
19 #include <SCPTimestampPluginLang.rsg> |
|
20 #include <AknGlobalConfirmationQuery.h> |
|
21 //#include <AknNoteDialog.h> |
|
22 #include <aknglobalnote.h> |
|
23 #include "SCPDebug.h" |
|
24 |
|
25 #include <hal.h> |
|
26 // For wipe |
|
27 #include <StarterClient.h> |
|
28 #include <SysLangUtil.h> |
|
29 #include <rfsClient.h> |
|
30 #include "DMUtilClient.h" |
|
31 CSCPUserInf::CSCPUserInf() : |
|
32 CActive(EPriorityStandard) // Standard priority |
|
33 { |
|
34 } |
|
35 |
|
36 CSCPUserInf* CSCPUserInf::NewLC() |
|
37 { |
|
38 CSCPUserInf* self = new (ELeave) CSCPUserInf(); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CSCPUserInf* CSCPUserInf::NewL() |
|
45 { |
|
46 CSCPUserInf* self = CSCPUserInf::NewLC(); |
|
47 CleanupStack::Pop(); // self; |
|
48 return self; |
|
49 } |
|
50 |
|
51 void CSCPUserInf::ConstructL() |
|
52 { |
|
53 //User::LeaveIfError(iTimer.CreateLocal()); // Initialize timer |
|
54 Dprint( (_L("CSCPUserInf::ConstructL()") )); |
|
55 CActiveScheduler::Add(this); // Add to scheduler |
|
56 } |
|
57 |
|
58 CSCPUserInf::~CSCPUserInf() |
|
59 { |
|
60 Cancel(); // Cancel any request, if outstanding |
|
61 //iTimer.Close(); // Destroy the RTimer object |
|
62 // Delete instance variables if any |
|
63 if (idispText) |
|
64 delete idispText; |
|
65 } |
|
66 |
|
67 void CSCPUserInf::DoCancel() |
|
68 { |
|
69 //iTimer.Cancel(); |
|
70 } |
|
71 |
|
72 void CSCPUserInf::StartL(TDesC& aString) |
|
73 { |
|
74 idispText = HBufC16::NewL( aString.Length() ); |
|
75 idispText->Des().Append(aString); |
|
76 Cancel(); // Cancel any request, just to be sure |
|
77 iState = EGlobalConf; |
|
78 Dprint( (_L("CSCPUserInf::StartL()") )); |
|
79 TRequestStatus* aStatus = &iStatus; |
|
80 User::RequestComplete(aStatus, KErrNone); |
|
81 SetActive(); // Tell scheduler a request is active |
|
82 } |
|
83 |
|
84 void CSCPUserInf::DoRfsL() |
|
85 { |
|
86 Cancel(); // Cancel any request, just to be sure |
|
87 iState = ERfs; |
|
88 Dprint( (_L("CSCPUserInf::DoRfsL()") )); |
|
89 TRequestStatus* aStatus = &iStatus; |
|
90 User::RequestComplete(aStatus, KErrNone); |
|
91 // This will give the control back to SecUi |
|
92 SetActive(); // Tell scheduler a request is active |
|
93 } |
|
94 |
|
95 void CSCPUserInf::RunL() |
|
96 { |
|
97 |
|
98 Dprint( (_L("CSCPUserInf::RunL()") )); |
|
99 if (iState == EGlobalConf) |
|
100 { |
|
101 Dprint( (_L("CSCPUserInf::EGlobalConf") )); |
|
102 TRAP_IGNORE( |
|
103 CAknGlobalConfirmationQuery* note = CAknGlobalConfirmationQuery::NewLC(); |
|
104 TPtr16 bufDes = idispText->Des(); |
|
105 TRequestStatus status; |
|
106 note->ShowConfirmationQueryL(status, |
|
107 bufDes, |
|
108 R_AVKON_SOFTKEYS_OK_EMPTY, |
|
109 R_QGN_NOTE_WARNING_ANIM ); |
|
110 Dprint( (_L("CSCPUserInf::WaitforReq") )); |
|
111 User::WaitForRequest( status ); |
|
112 Dprint( (_L("CSCPUserInf::WaitforReq done") )); |
|
113 CleanupStack::PopAndDestroy( note ); |
|
114 ); |
|
115 } |
|
116 else if (iState == ERfs) |
|
117 { |
|
118 Dprint( (_L("CSCPUserInf::ERfs") )); |
|
119 // Mark MMC card to be formatted also in bootup |
|
120 RDMUtil util; |
|
121 if ( util.Connect() == KErrNone ) |
|
122 { |
|
123 TInt err = util.MarkMMCWipe(); |
|
124 Dprint( (_L("CSCPUserInf::rfsClient.markmmc for wipe") )); |
|
125 if( err != KErrNone ) |
|
126 { |
|
127 // even if not successfull we try to reset as much as possible -> continue |
|
128 Dprint( ( _L( "CSCPUserInf::WipeDeviceL(): FAILED to mark MMC wipe: %d"), err ) ); |
|
129 } |
|
130 util.Close(); |
|
131 } |
|
132 |
|
133 // In case of deep level RFS, set the default language code |
|
134 // here, before RFS reboot. |
|
135 |
|
136 TInt language( 0 ); |
|
137 Dprint( (_L("CSCPUserInf::Language") )); |
|
138 // If default language is not found, we reset anyway |
|
139 if ( SysLangUtil::GetDefaultLanguage( language ) == KErrNone ) |
|
140 { |
|
141 HAL::Set( HALData::ELanguageIndex, language ); |
|
142 Dprint( (_L("CSCPUserInf::HAL,set") )); |
|
143 } |
|
144 |
|
145 // Reboot with RFS reason |
|
146 Dprint( (_L("CSCPUserInf::rfsClient.Reboot with RFS reason") )); |
|
147 RStarterSession startersession; |
|
148 if( startersession.Connect() == KErrNone ) |
|
149 { |
|
150 startersession.Reset( RStarterSession::EDeepRFSReset ); |
|
151 Dprint( (_L("CSCPUserInf::rfsClient.starter reset") )); |
|
152 startersession.Close(); |
|
153 } |
|
154 |
|
155 TInt ret; |
|
156 if ( ret != KErrNone ) |
|
157 { |
|
158 Dprint( ( _L( "CSCPUserInf::WipeDeviceL(): Rfs FAILED: %d"), ret ) ); |
|
159 } |
|
160 Dprint( (_L("CSCPUserInf::out of ERfs") )); |
|
161 } |
|
162 } |
|
163 |
|
164 TInt CSCPUserInf::RunError(TInt aError) |
|
165 { |
|
166 return aError; |
|
167 } |