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