|
1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "snsrdisplaycontrolclient.h" |
|
19 #include "snsrdisplaycontrolcommon.h" |
|
20 |
|
21 // =========== CONSTANTS =========== |
|
22 |
|
23 |
|
24 // ======== LOCAL FUNCTIONS ======== |
|
25 |
|
26 // ----------------------------------------------------------------------------- |
|
27 // CreateServerProcess |
|
28 // Static function to create the server process. |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 static TInt CreateServerProcess() |
|
32 { |
|
33 TInt err( KErrNone ); |
|
34 RProcess server; |
|
35 err = server.Create( KSnsrDispCtrlSrvName, KNullDesC, EOwnerThread ); |
|
36 if ( !err ) |
|
37 { |
|
38 TRequestStatus status; |
|
39 server.Rendezvous( status ); |
|
40 if ( status != KRequestPending ) |
|
41 { |
|
42 server.Kill( 0 ); // Abort startup. |
|
43 } |
|
44 else |
|
45 { |
|
46 server.Resume(); // Logon OK - start the server. |
|
47 } |
|
48 User::WaitForRequest( status ); // Wait for start or death. |
|
49 // We can't use the 'exit reason' if the server panicked as this |
|
50 // is the panic 'reason' and may be '0' which cannot be distinguished |
|
51 // from KErrNone. |
|
52 err = ( server.ExitType() == EExitPanic ) ? KErrGeneral |
|
53 : status.Int(); |
|
54 server.Close(); |
|
55 } |
|
56 return err; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // StartServer |
|
61 // Static function to start the server. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 static TInt StartServer() |
|
65 { |
|
66 TInt result; |
|
67 |
|
68 TFindServer findServer( KSnsrDispCtrlSrvName ); |
|
69 TFullName name; |
|
70 |
|
71 result = findServer.Next( name ); |
|
72 if ( result != KErrNone ) |
|
73 { |
|
74 // Server not running |
|
75 result = CreateServerProcess(); |
|
76 } |
|
77 return result; |
|
78 } |
|
79 |
|
80 |
|
81 |
|
82 // ======== MEMBER FUNCTIONS ======== |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C RSnsrDisplayControlClient::RSnsrDisplayControlClient() : |
|
89 RSessionBase(), iError( KErrNotReady ) |
|
90 { |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C TInt RSnsrDisplayControlClient::Open() |
|
98 { |
|
99 iError = StartServer(); |
|
100 |
|
101 if ( !iError ) |
|
102 { |
|
103 iError = CreateSession( KSnsrDispCtrlSrvName, Version() ); |
|
104 } |
|
105 |
|
106 if ( !iError ) |
|
107 { |
|
108 iError = ShareAuto(); |
|
109 } |
|
110 |
|
111 return iError; |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 EXPORT_C void RSnsrDisplayControlClient::Close() |
|
119 { |
|
120 RSessionBase::Close(); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C TVersion RSnsrDisplayControlClient::Version() const |
|
128 { |
|
129 return TVersion( KSnsrDispCtrlSrvVerMajor, |
|
130 KSnsrDispCtrlSrvVerMinor, |
|
131 KSnsrDispCtrlSrvVerBuild ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C void RSnsrDisplayControlClient::SetDisplayFullPower() |
|
139 { |
|
140 if ( !iError ) |
|
141 { |
|
142 TRequestStatus status( KRequestPending ); |
|
143 SendReceive( ESnsrDispCtrlSrvDisplayFullPower, TIpcArgs(), status ); |
|
144 User::WaitForRequest( status ); |
|
145 } |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 EXPORT_C void RSnsrDisplayControlClient::SetDisplayLowPower( TInt aStartRow, TInt aEndRow ) |
|
153 { |
|
154 if ( !iError ) |
|
155 { |
|
156 TRequestStatus status( KRequestPending ); |
|
157 TIpcArgs args( aStartRow, aEndRow ); |
|
158 |
|
159 SendReceive( ESnsrDispCtrlSrvDisplayLowPower, args, status ); |
|
160 |
|
161 User::WaitForRequest( status ); |
|
162 } |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 EXPORT_C void RSnsrDisplayControlClient::SetDisplayOff() |
|
170 { |
|
171 if ( !iError ) |
|
172 { |
|
173 TRequestStatus status( KRequestPending ); |
|
174 SendReceive( ESnsrDispCtrlSrvDisplayOff, TIpcArgs(), status ); |
|
175 User::WaitForRequest( status ); |
|
176 } |
|
177 } |
|
178 |