1 /* |
|
2 * Copyright (c) 2006-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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32uid.h> |
|
20 #include "tintegrityservicesclientserver.h" |
|
21 #include "tintegrityservicescommon.h" |
|
22 |
|
23 // |
|
24 // Starts the IntegrityServices Server in a new process |
|
25 // |
|
26 static TInt StartIntegrityServicesServer() |
|
27 { |
|
28 const TUidType serverUid(KExecutableImageUid, KNullUid, KIntegrityServicesServerUid3); |
|
29 RProcess server; |
|
30 TInt err = server.Create(KIntegrityServicesServerImage, KNullDesC); |
|
31 |
|
32 if (err != KErrNone) |
|
33 { |
|
34 return err; |
|
35 } |
|
36 |
|
37 TRequestStatus stat; |
|
38 server.Rendezvous(stat); |
|
39 |
|
40 if (stat != KRequestPending) |
|
41 { |
|
42 server.Kill(0); // abort startup |
|
43 } |
|
44 else |
|
45 { |
|
46 server.Resume(); // logon OK, start the server |
|
47 } |
|
48 |
|
49 User::WaitForRequest(stat); // wait for start or death |
|
50 // We can't use the 'exit reason' if the server panicked as this is the |
|
51 // panic 'reason' and may be 0 which cannot be distinguished from KErrNone. |
|
52 err = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int(); |
|
53 server.Close(); |
|
54 return err; |
|
55 } |
|
56 |
|
57 EXPORT_C TInt RIntegrityServicesServerSession::Connect() |
|
58 { |
|
59 TInt retry = 2; |
|
60 for(;;) |
|
61 { |
|
62 TInt err = CreateSession(KIntegrityServicesServerName, TVersion(0,0,0), 1); |
|
63 if (err != KErrNotFound && err != KErrServerTerminated) |
|
64 { |
|
65 return err; |
|
66 } |
|
67 |
|
68 if (--retry == 0) |
|
69 { |
|
70 return err; |
|
71 } |
|
72 |
|
73 err = StartIntegrityServicesServer(); |
|
74 if (err != KErrNone && err != KErrAlreadyExists) |
|
75 { |
|
76 return err; |
|
77 } |
|
78 } |
|
79 } |
|
80 |
|
81 EXPORT_C void RIntegrityServicesServerSession::AddL(const TDesC& aFileName) |
|
82 { |
|
83 User::LeaveIfError(SendReceive(EAdd, TIpcArgs(&aFileName))); |
|
84 } |
|
85 |
|
86 EXPORT_C void RIntegrityServicesServerSession::RemoveL(const TDesC& aFileName) |
|
87 { |
|
88 User::LeaveIfError(SendReceive(ERemove, TIpcArgs(&aFileName))); |
|
89 } |
|
90 |
|
91 EXPORT_C void RIntegrityServicesServerSession::TemporaryL(const TDesC& aFileName) |
|
92 { |
|
93 User::LeaveIfError(SendReceive(ETemporary, TIpcArgs(&aFileName))); |
|
94 } |
|
95 |
|
96 EXPORT_C void RIntegrityServicesServerSession::CommitL() |
|
97 { |
|
98 User::LeaveIfError(SendReceive(ECommit)); |
|
99 } |
|
100 |
|
101 EXPORT_C void RIntegrityServicesServerSession::RollBackL(TBool aAllTransactions) |
|
102 { |
|
103 TPckg<TBool> all(aAllTransactions); |
|
104 User::LeaveIfError(SendReceive(ERollBack, TIpcArgs(&all))); |
|
105 } |
|
106 |
|
107 EXPORT_C void RIntegrityServicesServerSession::SetSimulatedFailureL(TPtrC aFailType, TPtrC aFailPosition, TPtrC aFileName) |
|
108 { |
|
109 User::LeaveIfError(SendReceive(ESetSimulatedFailure, TIpcArgs(&aFailType, &aFailPosition, &aFileName))); |
|
110 } |
|
111 |
|
112 EXPORT_C void RIntegrityServicesServerSession::CreateNewTestFileL(const TDesC& aFileName) |
|
113 { |
|
114 User::LeaveIfError(SendReceive(ECreateNewTestFile, TIpcArgs(&aFileName))); |
|
115 } |
|
116 |
|
117 EXPORT_C void RIntegrityServicesServerSession::CreateTempTestFileL(const TDesC& aFileName) |
|
118 { |
|
119 User::LeaveIfError(SendReceive(ECreateTempTestFile, TIpcArgs(&aFileName))); |
|
120 } |
|