|
1 /* |
|
2 * Copyright (c) 2007 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: Client source file |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "IntegrityCheckClient.h" |
|
21 #include "IntegrityCheckDefs.h" |
|
22 #include "IntegrityCheckDebug.h" |
|
23 |
|
24 // MACROS |
|
25 |
|
26 // LOCAL CONSTANTS AND MACROS |
|
27 |
|
28 // MODULE DATA STRUCTURES |
|
29 |
|
30 // LOCAL FUNCTION PROTOTYPES |
|
31 |
|
32 // FORWARD DECLARATIONS |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // StartServer() |
|
36 // |
|
37 // --------------------------------------------------------------------------- |
|
38 // |
|
39 static TInt StartServer() |
|
40 { |
|
41 BTIC_TRACE_PRINT("[BTIC Client] StartServer"); |
|
42 |
|
43 const TUidType serverUid( |
|
44 KNullUid, |
|
45 KNullUid, |
|
46 KBTICServerUid3 ); |
|
47 |
|
48 RProcess server; |
|
49 |
|
50 TInt err = server.Create( KBTICServer, KNullDesC ); |
|
51 BTIC_TRACE_PRINT_NUM("StartServer: Create error = %d", err ); |
|
52 |
|
53 if ( err != KErrNone ) |
|
54 { |
|
55 return err; |
|
56 } |
|
57 |
|
58 TRequestStatus status; |
|
59 |
|
60 server.Rendezvous( status ); |
|
61 |
|
62 if ( status != KRequestPending ) |
|
63 { |
|
64 server.Kill( 0 ); |
|
65 } |
|
66 else |
|
67 { |
|
68 server.Resume(); |
|
69 } |
|
70 |
|
71 // Wait to server to start. |
|
72 User::WaitForRequest( status ); |
|
73 |
|
74 err = ( server.ExitType() == EExitPanic ) ? KErrGeneral : status.Int(); |
|
75 |
|
76 server.Close(); |
|
77 |
|
78 return err; |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // RIntegrityCheckClient::Connect() |
|
84 // |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C TInt RIntegrityCheckClient::Connect() |
|
88 { |
|
89 BTIC_TRACE_PRINT("[BTIC Client] Connect"); |
|
90 TInt retry( 2 ); |
|
91 |
|
92 for (;;) |
|
93 { |
|
94 |
|
95 TInt status = |
|
96 CreateSession( KBTICServer, TVersion( 0, 0, 0 ), 1 ); |
|
97 BTIC_TRACE_PRINT_NUM("Connect: CreateSession status = %d", status ); |
|
98 |
|
99 if ( ( status != KErrNotFound ) && ( status != KErrServerTerminated ) ) |
|
100 { |
|
101 return status; |
|
102 } |
|
103 |
|
104 if ( --retry == 0 ) |
|
105 { |
|
106 return status; |
|
107 } |
|
108 |
|
109 BTIC_TRACE_PRINT("Connect: StartServer"); |
|
110 status = StartServer(); |
|
111 BTIC_TRACE_PRINT_NUM("Connect: StartServer status = %d", status ); |
|
112 |
|
113 if ( ( status != KErrNone ) && ( status != KErrAlreadyExists ) ) |
|
114 { |
|
115 return status; |
|
116 } |
|
117 } |
|
118 } |
|
119 |
|
120 |
|
121 // --------------------------------------------------------------------------- |
|
122 // RIntegrityCheckClient::Close() |
|
123 // |
|
124 // --------------------------------------------------------------------------- |
|
125 // |
|
126 EXPORT_C void RIntegrityCheckClient::Close() |
|
127 { |
|
128 BTIC_TRACE_PRINT("[BTIC Client] Close"); |
|
129 RSessionBase::Close(); |
|
130 } |
|
131 |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // RIntegrityCheckClient::GetSWBootReason() |
|
135 // |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C TInt RIntegrityCheckClient::GetSWBootReason( TInt& aBootReason ) |
|
139 { |
|
140 BTIC_TRACE_PRINT("[BTIC Client] GetSWBootReason"); |
|
141 TPckg<TInt> pckgBootReason( aBootReason ); |
|
142 return SendReceive( EBTICBootReasonSW, TIpcArgs( &pckgBootReason ) ); |
|
143 } |
|
144 |