13 // Description: |
13 // Description: |
14 // This file contains the implementation of the AT+CPWD command |
14 // This file contains the implementation of the AT+CPWD command |
15 // |
15 // |
16 // |
16 // |
17 |
17 |
18 |
|
19 #include <mmretrieve.h> // AO |
|
20 |
|
21 #include "cpwdcommandhandler.h" |
18 #include "cpwdcommandhandler.h" |
22 |
19 |
|
20 #include <mmretrieve.h> |
|
21 |
|
22 #include "atmisccmdpluginconsts.h" |
23 #include "debug.h" |
23 #include "debug.h" |
24 |
|
25 |
24 |
26 // password types |
25 // password types |
27 _LIT8(KATCPWDPS, "PS"); // Phone lock |
26 _LIT8(KATCPWDPS, "PS"); // Phone lock |
28 _LIT8(KATCPWDP2, "P2"); // PIN2 |
27 _LIT8(KATCPWDP2, "P2"); // PIN2 |
29 _LIT8(KATCPWDSC, "SC"); // PIN |
28 _LIT8(KATCPWDSC, "SC"); // PIN |
30 _LIT8(KATCPWDAB, "AB"); // All Barring code |
29 _LIT8(KATCPWDAB, "AB"); // All Barring code |
31 |
30 |
32 |
|
33 |
|
34 // strings for debugging trace |
31 // strings for debugging trace |
35 _LIT8(KDbgStr, "+CPWD: %s \r\n"); |
32 _LIT8(KDbgStr, "+CPWD: %s \r\n"); |
36 _LIT8(KDbgTDes, "+CPWD: %s%S\r\n"); |
33 _LIT8(KDbgTDes, "+CPWD: %s%S\r\n"); |
37 |
34 |
38 // constant for Set All barring code service - originally defined in mw/PSetConstants.h |
35 // constant for Set All barring code service - originally defined in mw/PSetConstants.h |
39 const TInt KPsetAllSSServices = 0; |
36 const TInt KPsetAllSSServices = 0; |
40 // Max buffer length for an MD5 digest - originally defined in SCPServerInterface.h |
|
41 const TInt KSCPMaxHashLength( 32 ); |
|
42 |
|
43 |
|
44 |
37 |
45 CCPWDCommandHandler* CCPWDCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) |
38 CCPWDCommandHandler* CCPWDCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) |
46 { |
39 { |
47 TRACE_FUNC_ENTRY |
40 TRACE_FUNC_ENTRY |
48 CCPWDCommandHandler* self = new (ELeave) CCPWDCommandHandler(aCallback, aATCmdParser, aPhone); |
41 CCPWDCommandHandler* self = new (ELeave) CCPWDCommandHandler(aCallback, aATCmdParser, aPhone); |
92 } |
85 } |
93 } |
86 } |
94 TRACE_FUNC_EXIT |
87 TRACE_FUNC_EXIT |
95 } |
88 } |
96 |
89 |
97 void CCPWDCommandHandler::HandleCommandCancel() |
|
98 { |
|
99 TRACE_FUNC_ENTRY |
|
100 Cancel(); |
|
101 TRACE_FUNC_EXIT |
|
102 } |
|
103 |
|
104 |
|
105 void CCPWDCommandHandler::ChangePassword() |
90 void CCPWDCommandHandler::ChangePassword() |
106 { |
91 { |
107 TRACE_FUNC_ENTRY |
92 TRACE_FUNC_ENTRY |
108 |
93 |
109 // Get parameters from AT command |
94 // Get parameters from AT command |
110 TInt ret1; |
95 TPtrC8 passwordType; |
111 TInt ret2; |
96 TPtrC8 oldPassword; |
112 TInt ret3; |
97 TPtrC8 newPassword; |
113 TPtrC8 passwordType = iATCmdParser.NextTextParam(ret1); |
98 TInt ret1 = iATCmdParser.NextTextParam(passwordType); |
114 TPtrC8 oldPassword = iATCmdParser.NextTextParam(ret2); |
99 TInt ret2 = iATCmdParser.NextTextParam(oldPassword); |
115 TPtrC8 newPassword = iATCmdParser.NextTextParam(ret3); |
100 TInt ret3 = iATCmdParser.NextTextParam(newPassword); |
116 |
101 |
117 if(ret1 != KErrNone || ret2 != KErrNone || ret3 != KErrNone |
102 if(ret1 != KErrNone || ret2 != KErrNone || ret3 != KErrNone |
118 || iATCmdParser.NextParam().Compare(KNullDesC8) != 0) |
103 || iATCmdParser.NextParam().Length() != 0) |
119 { |
104 { |
120 Trace(KDbgStr, "invalid arguments"); |
105 Trace(KDbgStr, "invalid arguments"); |
121 iCallback->CreateReplyAndComplete( EReplyTypeError); |
106 iCallback->CreateReplyAndComplete( EReplyTypeError); |
122 TRACE_FUNC_EXIT |
107 TRACE_FUNC_EXIT |
123 return; |
108 return; |
124 } |
109 } |
125 |
110 |
126 if(passwordType.Compare(KATCPWDPS) == 0) // Phone lock |
111 if(passwordType.CompareF(KATCPWDPS) == 0) // Phone lock |
127 { |
112 { |
128 // "PS" PH-SIM (lock PHone to SIM/UICC card) (MT asks password when other than current SIM/UICC card |
113 // "PS" PH-SIM (lock PHone to SIM/UICC card) (MT asks password when other than current SIM/UICC card |
129 // inserted; MT may remember certain amount of previously used cards thus not requiring password when they |
114 // inserted; MT may remember certain amount of previously used cards thus not requiring password when they |
130 // are inserted) |
115 // are inserted) |
131 RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange; |
116 RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange; |
132 |
117 |
133 // Phone lock password is hashed in RSPClient and NokiaTSY. See CSCPServer::HashISACode() for details. |
118 // Phone lock password is hashed in RSPClient and NokiaTSY. See CSCPServer::HashISACode() for details. |
134 TBuf8<KSCPMaxHashLength> hashOldPwd; |
119 TBuf8<KSCPMaxHashLength> hashOldPwd; |
135 TBuf8<KSCPMaxHashLength> hashNewPwd; |
120 TBuf8<KSCPMaxHashLength> hashNewPwd; |
136 iATCmdParser.HashSecurityCode(oldPassword, hashOldPwd); |
121 iATCmdParser.HashSecurityCode(oldPassword, hashOldPwd); |
137 iATCmdParser.HashSecurityCode(newPassword, hashNewPwd); |
122 iATCmdParser.HashSecurityCode(newPassword, hashNewPwd); |
138 |
123 |
139 ChangeSecurityCode(RMobilePhone::ESecurityCodePhonePassword, hashOldPwd, hashNewPwd); |
124 ChangeSecurityCode(RMobilePhone::ESecurityCodePhonePassword, hashOldPwd, hashNewPwd); |
140 } |
125 } |
141 else if(passwordType.Compare(KATCPWDSC) == 0) // SIM pin |
126 else if(passwordType.CompareF(KATCPWDSC) == 0) // SIM pin |
142 { |
127 { |
143 // "SC" SIM (lock SIM/UICC card) (SIM/UICC asks password in MT power-up and when this lock command |
128 // "SC" SIM (lock SIM/UICC card) (SIM/UICC asks password in MT power-up and when this lock command |
144 // issued) |
129 // issued) |
145 |
130 |
146 // todo: if it is required to return +CME code according to SIM Lock status, |
131 // todo: if it is required to return +CME code according to SIM Lock status, |
147 // should check SIM Lock is on here and return an error if it is off. |
132 // should check SIM Lock is on here and return an error if it is off. |
148 ChangeSecurityCode(RMobilePhone::ESecurityCodePin1, oldPassword, newPassword); |
133 ChangeSecurityCode(RMobilePhone::ESecurityCodePin1, oldPassword, newPassword); |
149 } |
134 } |
150 else if(passwordType.Compare(KATCPWDP2) == 0) // SIM pin2 |
135 else if(passwordType.CompareF(KATCPWDP2) == 0) // SIM pin2 |
151 { |
136 { |
152 ChangeSecurityCode(RMobilePhone::ESecurityCodePin2, oldPassword, newPassword); |
137 ChangeSecurityCode(RMobilePhone::ESecurityCodePin2, oldPassword, newPassword); |
153 } |
138 } |
154 else if(passwordType.Compare(KATCPWDAB) == 0) // All Barring services |
139 else if(passwordType.CompareF(KATCPWDAB) == 0) // All Barring services |
155 { |
140 { |
156 // "AB" All Barring services (refer 3GPP TS 22.030 [19]) (applicable only for <mode>=0) |
141 // "AB" All Barring services (refer 3GPP TS 22.030 [19]) (applicable only for <mode>=0) |
157 RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange; |
142 RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange; |
158 passwordChange.iOldPassword.Copy(oldPassword); |
143 passwordChange.iOldPassword.Copy(oldPassword); |
159 passwordChange.iNewPassword.Copy(newPassword); |
144 passwordChange.iNewPassword.Copy(newPassword); |
201 } |
184 } |
202 |
185 |
203 |
186 |
204 void CCPWDCommandHandler::ChangeSecurityCode(RMobilePhone::TMobilePhoneSecurityCode aType, TDesC8& aOldPassword, TDesC8& aNewPassword) |
187 void CCPWDCommandHandler::ChangeSecurityCode(RMobilePhone::TMobilePhoneSecurityCode aType, TDesC8& aOldPassword, TDesC8& aNewPassword) |
205 { |
188 { |
|
189 TRACE_FUNC_ENTRY |
206 RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange; |
190 RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange; |
207 passwordChange.iOldPassword.Copy(aOldPassword); |
191 passwordChange.iOldPassword.Copy(aOldPassword); |
208 passwordChange.iNewPassword.Copy(aNewPassword); |
192 passwordChange.iNewPassword.Copy(aNewPassword); |
209 iPhone.ChangeSecurityCode(iStatus, aType, passwordChange); |
193 iPhone.ChangeSecurityCode(iStatus, aType, passwordChange); |
210 iPendingEvent = EMobilePhoneChangeSecurityCode; |
194 iPendingEvent = EMobilePhoneChangeSecurityCode; |
211 SetActive(); |
195 SetActive(); |
|
196 TRACE_FUNC_EXIT |
212 } |
197 } |