|
1 // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Test Server - client interface implementation |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32std.h> |
|
19 #include <e32math.h> |
|
20 #include "SmokeTestSecureFSclientserver.h" |
|
21 #include "SmokeTestSecureFSclient.h" |
|
22 |
|
23 static TInt StartServer() |
|
24 // |
|
25 // Start the server process. Simultaneous launching |
|
26 // of two such processes should be detected when the second one attempts to |
|
27 // create the server object, failing with KErrAlreadyExists. |
|
28 // |
|
29 { |
|
30 const TUidType serverUid(KNullUid,KNullUid,KServerUid3); |
|
31 |
|
32 |
|
33 RProcess server; |
|
34 TInt r=server.Create(KTestServerImg, KNullDesC, serverUid); |
|
35 |
|
36 if (r!=KErrNone) |
|
37 return r; |
|
38 TRequestStatus stat; |
|
39 |
|
40 server.Rendezvous(stat); |
|
41 |
|
42 if (stat != KRequestPending) |
|
43 server.Kill(0); // abort startup |
|
44 else |
|
45 server.Resume(); // logon OK - start the server |
|
46 User::WaitForRequest(stat); //wait for start or death |
|
47 // we can't use the 'exit reason' if the server panicked as this |
|
48 // is the panic 'reason' and may be '0' which cannot be distinguished |
|
49 // from KErrNone |
|
50 r=(server.ExitType()==EExitPanic) ? KErrGeneral : stat.Int(); |
|
51 server.Close(); |
|
52 return r; |
|
53 } |
|
54 |
|
55 EXPORT_C TInt RTestSecureFSclient::Connect() |
|
56 {// Connect to the server, attempting to start it if necessary |
|
57 TInt retry=2; |
|
58 for (;;) |
|
59 { |
|
60 TInt r=CreateSession(KTestServerName,TVersion(0,0,0),1); |
|
61 if (r!=KErrNotFound && r!=KErrServerTerminated) |
|
62 return r; |
|
63 if (--retry==0) |
|
64 return r; |
|
65 r=StartServer(); |
|
66 if (r!=KErrNone && r!=KErrAlreadyExists) |
|
67 return r; |
|
68 User::After(1000000); //Let server load up (in EKA2) |
|
69 |
|
70 } |
|
71 } |
|
72 |
|
73 EXPORT_C TInt RTestSecureFSclient::SetHomeTime(const TTime& aTime) |
|
74 { |
|
75 TPckg<TTime> pckg(aTime); |
|
76 return SendReceive(ETestIpcSetHomeTime,TIpcArgs(&pckg)); |
|
77 } |
|
78 |
|
79 EXPORT_C TInt RTestSecureFSclient::DeleteFileL(const TDesC& aFileName) |
|
80 { |
|
81 TIpcArgs args(&aFileName); |
|
82 return SendReceive(ETestIpcDeleteFile,args); |
|
83 } |
|
84 |
|
85 EXPORT_C void RTestSecureFSclient::KillProcessL(const TDesC& aProcessName) |
|
86 { |
|
87 TIpcArgs args(&aProcessName); |
|
88 User::LeaveIfError(SendReceive(ETestIpcKillProcess,args)); |
|
89 } |
|
90 |
|
91 EXPORT_C TInt RTestSecureFSclient::ChangeLocaleName(const TDesC& aLocaleDllName) |
|
92 { |
|
93 TIpcArgs args(&aLocaleDllName); |
|
94 return SendReceive(ETestIpcChangeLocale,args); |
|
95 } |
|
96 |
|
97 EXPORT_C TInt RTestSecureFSclient::CheckForFile(const TDesC& aFileName) |
|
98 { |
|
99 TIpcArgs args(&aFileName); |
|
100 return SendReceive(ETestIpcCheckForFile,args); |
|
101 } |
|
102 |
|
103 EXPORT_C TInt RTestSecureFSclient::CopyFile(const TDesC& Source, const TDesC& Dest) |
|
104 { |
|
105 TIpcArgs args(&Source, &Dest); |
|
106 return SendReceive(ETestIpcCopyFile,args); |
|
107 } |
|
108 |
|
109 EXPORT_C void RTestSecureFSclient::SetUpFbs() |
|
110 { |
|
111 SendReceive(ETestIpcSetUpFbs); |
|
112 } |
|
113 |