|
1 /* |
|
2 * Copyright (c) 2006 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: Implementation of CseScheduler client's Server* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <ipvideo/RCseSchedulerClient.h> // Header for this class |
|
21 #include "CseDebug.h" // Debug macros |
|
22 #include <ipvideo/CseSchedulerClientServerCommon.h> // Common defines for client and server |
|
23 #include <e32math.h> |
|
24 #include <f32file.h> |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 // None |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 // None |
|
31 |
|
32 // CONSTANTS |
|
33 const TUint KSchedulingDefaultMessageSlots( 4 ); |
|
34 const TUint KSchedulingNumberOfServerStartupAttempts( 2 ); |
|
35 |
|
36 // MACROS |
|
37 // None |
|
38 |
|
39 // LOCAL CONSTANTS AND MACROS |
|
40 // None |
|
41 |
|
42 // MODULE DATA STRUCTURES |
|
43 // None |
|
44 |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 // LOCAL FUNCTION PROTOTYPES |
|
47 static TInt StartServer(); |
|
48 static TInt CreateServerProcess(); |
|
49 |
|
50 // FORWARD DECLARATIONS |
|
51 // None |
|
52 |
|
53 // ============================= LOCAL FUNCTIONS =============================== |
|
54 // ----------------------------------------------------------------------------- |
|
55 // StartServer |
|
56 // Returns: Error code |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 static TInt StartServer() |
|
60 { |
|
61 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::StartServer"); |
|
62 TFindServer findServer( KCseSchedulerServerName ); |
|
63 TFullName name; |
|
64 |
|
65 // Server already running? |
|
66 if ( !findServer.Next( name ) ) |
|
67 { |
|
68 return KErrNone; |
|
69 } |
|
70 |
|
71 TInt result( CreateServerProcess() ); |
|
72 |
|
73 CSELOGSTRING2_HIGH_LEVEL("<<<RCseSchedulerClient::StartServer: %d", result); |
|
74 return result; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CreateServerProcess |
|
79 // |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 static TInt CreateServerProcess() |
|
83 { |
|
84 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::CreateServerProcess"); |
|
85 RProcess server; |
|
86 TInt result( server.Create( KCseSchedulerServerFileName , _L( "" ) ) ); |
|
87 |
|
88 if ( result ) |
|
89 { |
|
90 return result; |
|
91 } |
|
92 |
|
93 // Makes the server eligible for execution. |
|
94 TRequestStatus reqStatus; |
|
95 server.Rendezvous(reqStatus); |
|
96 |
|
97 server.Resume(); |
|
98 |
|
99 User::WaitForRequest(reqStatus); |
|
100 |
|
101 if( reqStatus.Int() != KErrNone ) |
|
102 { |
|
103 server.Close(); |
|
104 } |
|
105 |
|
106 CSELOGSTRING2_HIGH_LEVEL("<<<RCseSchedulerClient::CreateServerProcess: %d", reqStatus.Int()); |
|
107 return reqStatus.Int(); |
|
108 } |
|
109 |
|
110 // ============================ MEMBER FUNCTIONS =============================== |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // RCseSchedulerClient::RCseSchedulerClient |
|
114 // |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 RCseSchedulerClient::RCseSchedulerClient() : RSessionBase() |
|
118 { |
|
119 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::RCseSchedulerClient"); |
|
120 // None |
|
121 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerClient::RCseSchedulerClient"); |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // RCseSchedulerClient::~RCseSchedulerClient |
|
126 // |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 RCseSchedulerClient::~RCseSchedulerClient() |
|
130 { |
|
131 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::~RCseSchedulerClient"); |
|
132 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerClient::~RCseSchedulerClient"); |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // RCseSchedulerClient::Connect |
|
137 // |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 TInt RCseSchedulerClient::Connect() |
|
141 { |
|
142 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::Connect"); |
|
143 TInt ret( KErrNotFound ); |
|
144 TInt retry( KSchedulingNumberOfServerStartupAttempts ); |
|
145 do |
|
146 { |
|
147 // Start |
|
148 ret = StartServer(); |
|
149 if ( ret!=KErrNone && ret!=KErrAlreadyExists ) |
|
150 { |
|
151 return ret; |
|
152 } |
|
153 |
|
154 // Subsession |
|
155 ret = CreateSession( KCseSchedulerServerName, Version(), KSchedulingDefaultMessageSlots ); |
|
156 if ( ret != KErrNotFound && ret != KErrServerTerminated ) |
|
157 { |
|
158 return ret; |
|
159 } |
|
160 |
|
161 retry--; |
|
162 } |
|
163 while( retry >= 0 ); |
|
164 |
|
165 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerClient::Connect"); |
|
166 return ret; |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // RCseSchedulerClient::Close |
|
171 // |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void RCseSchedulerClient::Close() |
|
175 { |
|
176 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::Close"); |
|
177 |
|
178 TIpcArgs args( TIpcArgs::ENothing ); |
|
179 SendReceive( ECseServCloseSession, args ); |
|
180 |
|
181 RHandleBase::Close(); |
|
182 |
|
183 CSELOGSTRING_HIGH_LEVEL("<<<RCseSchedulerClient::Connect"); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // RCseSchedulerClient::Version |
|
188 // |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 TVersion RCseSchedulerClient::Version( void ) const |
|
192 { |
|
193 CSELOGSTRING_HIGH_LEVEL(">>>RCseSchedulerClient::Version"); |
|
194 |
|
195 return( TVersion( KCseServMajorVersionNumber, |
|
196 KCseServMinorVersionNumber, |
|
197 KCseServBuildVersionNumber ) ); |
|
198 } |
|
199 |
|
200 // End of File |