|
1 /* |
|
2 * Copyright (c) 2009 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: LAWMO Client implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32svr.h> |
|
19 #include <featmgr.h> |
|
20 #include "dcmoclientserver.h" |
|
21 #include "lawmoclient.h" |
|
22 #include "lawmodebug.h" |
|
23 // Standard server startup code |
|
24 // |
|
25 static TInt StartServer() |
|
26 { |
|
27 RLDEBUG("from lawmoclient ->starting dcmo server..."); |
|
28 |
|
29 // EPOC and EKA 2 is easy, we just create a new server process. Simultaneous |
|
30 // launching of two such processes should be detected when the second one |
|
31 // attempts to create the server object, failing with KErrAlreadyExists. |
|
32 RProcess server; |
|
33 TInt r=server.Create(KDCMOServerName,KNullDesC); |
|
34 |
|
35 if (r!=KErrNone) |
|
36 { |
|
37 RLDEBUG_2("lawmoclient -> server start failed %d",r); |
|
38 return r; |
|
39 } |
|
40 TRequestStatus stat; |
|
41 server.Rendezvous(stat); |
|
42 if (stat!=KRequestPending) |
|
43 server.Kill(0); // abort startup |
|
44 else |
|
45 server.Resume(); // logon OK - start the server |
|
46 RLDEBUG("lawmoclient -> dcmoserver Started"); |
|
47 User::WaitForRequest(stat); // wait for start or death |
|
48 // we can't use the 'exit reason' if the server panicked as this |
|
49 // is the panic 'reason' and may be '0' which cannot be distinguished |
|
50 // from KErrNone |
|
51 r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
|
52 server.Close(); |
|
53 return r; |
|
54 } |
|
55 |
|
56 |
|
57 // This is the standard retry pattern for server connection |
|
58 EXPORT_C TInt RLawmoClient::Connect() |
|
59 { |
|
60 RLDEBUG("RLawmoClient: connect..."); |
|
61 TInt retry=2; |
|
62 for (;;) |
|
63 { |
|
64 TInt r=CreateSession(KDCMOServerName,TVersion(0,0,0),1); |
|
65 if (r!=KErrNotFound && r!=KErrServerTerminated) |
|
66 return r; |
|
67 if (--retry==0) |
|
68 return r; |
|
69 RLDEBUG("RLawmoClient: to start server..."); |
|
70 r=StartServer(); |
|
71 if (r!=KErrNone && r!=KErrAlreadyExists) |
|
72 return r; |
|
73 } |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // RLawmoClient::Close() |
|
78 // --------------------------------------------------------------------------- |
|
79 EXPORT_C void RLawmoClient::Close() |
|
80 { |
|
81 RLDEBUG(" RLawmoClient::Close"); |
|
82 RSessionBase::Close(); //basecall |
|
83 RLDEBUG(" RLawmoClient::close done"); |
|
84 } |
|
85 |
|
86 // ---------------------------------------------------------------------------------------- |
|
87 // RLawmoClient::DeviceWipeL |
|
88 // ---------------------------------------------------------------------------------------- |
|
89 EXPORT_C TLawMoStatus RLawmoClient::DeviceWipe() |
|
90 { |
|
91 RLDEBUG("RLawmoClient::DeviceWipe Begin"); |
|
92 TLawMoStatus status(ELawMoAccepted); |
|
93 TPckg<TLawMoStatus> statusValue(status); |
|
94 TInt err = SendReceive(EWipe,TIpcArgs(&statusValue)); |
|
95 //TInt err = SendReceive(EWipe); |
|
96 if(err != KErrNone) |
|
97 status = ELawMoWipeNotPerformed; |
|
98 RLDEBUG("RLawmoClient::DeviceWipe End"); |
|
99 return status; |
|
100 } |
|
101 |
|
102 // ---------------------------------------------------------------------------------------- |
|
103 // RLawmoClient::DeviceWipeAll |
|
104 // ---------------------------------------------------------------------------------------- |
|
105 EXPORT_C TLawMoStatus RLawmoClient::DeviceWipeAll( ) |
|
106 { |
|
107 RLDEBUG("RLawmoClient::DeviceWipeAll Begin"); |
|
108 TLawMoStatus status(ELawMoSuccess); |
|
109 TPckg<TLawMoStatus> statusValue(status); |
|
110 TInt err = SendReceive( EWipeAll,TIpcArgs(&statusValue) ); |
|
111 if(err != KErrNone)//if sendreceive itself failed |
|
112 status = ELawMoWipeFailed; |
|
113 RLDEBUG("RLawmoClient::DeviceWipeAll End"); |
|
114 return status; |
|
115 } |
|
116 |
|
117 // ---------------------------------------------------------------------------------------- |
|
118 // RLawmoClient::SetPasscodeMaxAttempts |
|
119 // ---------------------------------------------------------------------------------------- |
|
120 EXPORT_C TInt RLawmoClient::GetListItemName( TDes& aItemName, TDes& aNodeValue ) |
|
121 { |
|
122 RLDEBUG("RLawmoClient::GetListItemName Begin"); |
|
123 |
|
124 TIpcArgs args1; |
|
125 TLawMoStatus status(ELawMoOk); |
|
126 |
|
127 args1.Set( 0, &aItemName ); |
|
128 args1.Set( 1, &aNodeValue ); |
|
129 args1.Set( 2, status); |
|
130 TInt err = SendReceive( EListItemName_Get, args1 ); |
|
131 if(err != KErrNone) |
|
132 status = ELawMoInvalid; |
|
133 RLDEBUG("RLawmoClient::GetListItemName End"); |
|
134 return status; |
|
135 } |
|
136 |
|
137 EXPORT_C TInt RLawmoClient::GetToBeWipedValue( TDes& aItemName, TBool& aWipeVal ) |
|
138 { |
|
139 RLDEBUG("RLawmoClient::GetToBeWipedValue Begin"); |
|
140 |
|
141 TIpcArgs args1; |
|
142 TBuf<255> wipeValue; |
|
143 TLex lex; |
|
144 |
|
145 TLawMoStatus status(ELawMoOk); |
|
146 |
|
147 args1.Set( 0, &aItemName ); |
|
148 args1.Set( 1, &wipeValue ); |
|
149 args1.Set( 2, status); |
|
150 |
|
151 TInt err = SendReceive( EToBeWiped_Get, args1 ); |
|
152 |
|
153 if( err == KErrNone ) |
|
154 { |
|
155 lex.Assign( wipeValue ); |
|
156 err = lex.Val( aWipeVal ); |
|
157 } |
|
158 if(err != KErrNone) |
|
159 status = ELawMoInvalid; |
|
160 |
|
161 RLDEBUG("RLawmoClient::GetToBeWipedValue End"); |
|
162 return status; |
|
163 } |
|
164 |
|
165 EXPORT_C TInt RLawmoClient::SetToBeWipedValue( TDes& aItemName, TInt aWipeVal ) |
|
166 { |
|
167 RLDEBUG("RLawmoClient::SetToBeWipedValue Begin"); |
|
168 TIpcArgs args1; |
|
169 TLawMoStatus status(ELawMoOk); |
|
170 |
|
171 args1.Set( 0, &aItemName ); |
|
172 args1.Set( 1, aWipeVal ); |
|
173 args1.Set( 2, status); |
|
174 |
|
175 TInt err = SendReceive( EToBeWiped_Set, args1 ); |
|
176 |
|
177 if(err != KErrNone) |
|
178 status = ELawMoInvalid; |
|
179 |
|
180 RLDEBUG("RLawmoClient::SetToBeWipedValue End"); |
|
181 return status; |
|
182 } |
|
183 // ---------------------------------------------------------------------------------------- |
|
184 // RLawmoClient::SetPasscodeMaxAttempts |
|
185 // ---------------------------------------------------------------------------------------- |
|
186 /*EXPORT_C TInt RLawmoClient::GetLawMoState( TDes& aState ) |
|
187 { |
|
188 RLDEBUG("RLawmoClient::GetLawMoState Begin"); |
|
189 |
|
190 TLawMoStatus status(ELawMoSuccess); |
|
191 TIpcArgs args1; |
|
192 args1.Set( 0, &aState ); |
|
193 args1.Set( 1, status); |
|
194 TInt err = SendReceive( EState, args1 ); |
|
195 |
|
196 if(err != KErrNone) |
|
197 status = ELawMoFail; |
|
198 |
|
199 RLDEBUG("RLawmoClient::GetLawMoState End"); |
|
200 return status; |
|
201 }*/ |