|
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: Implementation of Screensaver Display Control Server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "snsrdisplaycontrolserver.h" |
|
20 #include "snsrdisplaycontrolsession.h" |
|
21 #include "snsrdisplaycontrolcommon.h" |
|
22 |
|
23 // =========== CONSTANTS =========== |
|
24 |
|
25 |
|
26 // ======== LOCAL FUNCTIONS ======== |
|
27 |
|
28 // ---------------------------------------------------------------------------- |
|
29 // Initialize and run the server |
|
30 // ---------------------------------------------------------------------------- |
|
31 // |
|
32 static void RunTheServerL() |
|
33 { |
|
34 // First create and install the active scheduler |
|
35 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler; |
|
36 CleanupStack::PushL( scheduler ); |
|
37 CActiveScheduler::Install( scheduler ); |
|
38 |
|
39 TInt err = User::RenameThread( KSnsrDispCtrlSrvName ); |
|
40 User::LeaveIfError( err ); |
|
41 |
|
42 // Create the server |
|
43 CSnsrDisplayControlServer* server = CSnsrDisplayControlServer::NewLC(); |
|
44 server->StartL( KSnsrDispCtrlSrvName ); |
|
45 |
|
46 // Signal the client the startup is complete |
|
47 RProcess::Rendezvous(KErrNone); |
|
48 |
|
49 // Enter the wait loop |
|
50 CActiveScheduler::Start(); |
|
51 |
|
52 // Exited cleanup scheduler and server |
|
53 CleanupStack::PopAndDestroy( server ); |
|
54 CleanupStack::PopAndDestroy( scheduler ); |
|
55 } |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // Main entry-point for the server thread/process |
|
59 // ---------------------------------------------------------------------------- |
|
60 // |
|
61 static TInt RunTheServer() |
|
62 { |
|
63 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
64 TInt r = KErrNoMemory; |
|
65 if (cleanup) |
|
66 { |
|
67 TRAP( r, RunTheServerL() ); |
|
68 delete cleanup; |
|
69 } |
|
70 |
|
71 return (r); |
|
72 } |
|
73 |
|
74 |
|
75 // ======== MEMBER FUNCTIONS ======== |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // Constructor |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CSnsrDisplayControlServer::CSnsrDisplayControlServer() : |
|
82 CServer2( EPriorityStandard, CServer2::TServerType( EIpcSession_Sharable ) ) |
|
83 { |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // Second phase constructor |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void CSnsrDisplayControlServer::ConstructL() |
|
91 { |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Factory method |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 CSnsrDisplayControlServer* CSnsrDisplayControlServer::NewLC() |
|
99 { |
|
100 CSnsrDisplayControlServer* self = new (ELeave) CSnsrDisplayControlServer(); |
|
101 CleanupStack::PushL( self ); |
|
102 self->ConstructL(); |
|
103 return self; |
|
104 } |
|
105 |
|
106 // --------------------------------------------------------------------------- |
|
107 // Destructor |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 CSnsrDisplayControlServer::~CSnsrDisplayControlServer() |
|
111 { |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // Create server side session object |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 CSession2* CSnsrDisplayControlServer::NewSessionL( const TVersion& aVersion, |
|
119 const RMessage2& aMessage ) const |
|
120 { |
|
121 TVersion version( KSnsrDispCtrlSrvVerMajor, |
|
122 KSnsrDispCtrlSrvVerMinor, |
|
123 KSnsrDispCtrlSrvVerBuild ); |
|
124 if ( !User::QueryVersionSupported( version, aVersion ) ) |
|
125 { |
|
126 User::Leave( KErrNotSupported ); |
|
127 } |
|
128 |
|
129 // Allow connections only from HbDeviceDialogAppServer. Essentially, we are a |
|
130 // capability proxy which grants access to API normally needing WriteDeviceData |
|
131 // capability to a process which doesn't have it. Use access control |
|
132 // of our own to prevent maluse. This module is not part of SDK or even platform API |
|
133 // and only supposed to be used internally by Screensaver, so preventing access |
|
134 // from other processes should not be a problem. |
|
135 static _LIT_SECURITY_POLICY_S0(hbDeviceDialogSidPolicy, 0x20022FC5); |
|
136 TBool passed = hbDeviceDialogSidPolicy().CheckPolicy(aMessage); |
|
137 if ( !passed ) |
|
138 { |
|
139 User::Leave( KErrPermissionDenied ); |
|
140 } |
|
141 |
|
142 CSession2* session; |
|
143 session = CSnsrDisplayControlSession::NewL(); |
|
144 session->SetServer( this ); |
|
145 return session; |
|
146 } |
|
147 |
|
148 |
|
149 // ======== GLOBAL FUNCTIONS ======== |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // Process entry point |
|
153 // ---------------------------------------------------------------------------- |
|
154 TInt E32Main() |
|
155 { |
|
156 return RunTheServer(); |
|
157 } |
|
158 |