86
|
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 for server side session object of
|
|
15 |
* Screensaver Display Control Server
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
#include <power_save_display_mode.h>
|
|
20 |
#include <hal.h>
|
90
|
21 |
#include <coreapplicationuisdomainpskeys.h>
|
|
22 |
#include <e32property.h>
|
86
|
23 |
|
|
24 |
#include "snsrdisplaycontrolsession.h"
|
|
25 |
#include "snsrdisplaycontrolcommon.h"
|
|
26 |
|
|
27 |
|
|
28 |
// ======== LOCAL FUNCTIONS ========
|
|
29 |
|
|
30 |
|
|
31 |
// ======== MEMBER FUNCTIONS ========
|
|
32 |
|
|
33 |
|
|
34 |
// ---------------------------------------------------------------------------
|
|
35 |
// CSnsrDisplayControlSession
|
|
36 |
// ---------------------------------------------------------------------------
|
|
37 |
//
|
|
38 |
CSnsrDisplayControlSession::CSnsrDisplayControlSession() :
|
|
39 |
CSession2()
|
|
40 |
{
|
|
41 |
}
|
|
42 |
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// ConstructL
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
void CSnsrDisplayControlSession::ConstructL()
|
|
49 |
{
|
|
50 |
iPowerSave = CPowerSaveDisplayMode::NewL();
|
|
51 |
|
|
52 |
// Create pixel buffer that can hold the full screen picture of our
|
|
53 |
// display device.
|
|
54 |
TInt x = 0;
|
|
55 |
TInt y = 0;
|
|
56 |
HAL::Get(HALData::EDisplayXPixels, x);
|
|
57 |
HAL::Get(HALData::EDisplayYPixels, y);
|
|
58 |
iPowerSavePixelBuffer = HBufC::NewL(x*y);
|
|
59 |
iPowerSavePixelBuffer->Des().FillZ();
|
|
60 |
}
|
|
61 |
|
|
62 |
|
|
63 |
// ---------------------------------------------------------------------------
|
|
64 |
// NewL
|
|
65 |
// ---------------------------------------------------------------------------
|
|
66 |
//
|
|
67 |
EXPORT_C CSnsrDisplayControlSession* CSnsrDisplayControlSession::NewL()
|
|
68 |
{
|
|
69 |
CSnsrDisplayControlSession* self = new (ELeave) CSnsrDisplayControlSession();
|
|
70 |
CleanupStack::PushL( self );
|
|
71 |
self->ConstructL();
|
|
72 |
CleanupStack::Pop( self );
|
|
73 |
return self;
|
|
74 |
}
|
|
75 |
|
|
76 |
|
|
77 |
// ---------------------------------------------------------------------------
|
|
78 |
// ~CSnsrDisplayControlSession
|
|
79 |
// ---------------------------------------------------------------------------
|
|
80 |
//
|
|
81 |
CSnsrDisplayControlSession::~CSnsrDisplayControlSession()
|
|
82 |
{
|
|
83 |
delete iPowerSave;
|
|
84 |
delete iPowerSavePixelBuffer;
|
|
85 |
}
|
|
86 |
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
// ServiceL
|
|
89 |
// ---------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void CSnsrDisplayControlSession::ServiceL( const RMessage2& aMessage )
|
|
92 |
{
|
|
93 |
TInt func = aMessage.Function();
|
|
94 |
|
|
95 |
TInt err( KErrNone );
|
|
96 |
|
|
97 |
switch ( func )
|
|
98 |
{
|
|
99 |
case ESnsrDispCtrlSrvDisplayOff:
|
|
100 |
{
|
90
|
101 |
// Disable touch
|
|
102 |
HAL::Set( HALData::EPenState, 0 );
|
|
103 |
|
|
104 |
// Lights off
|
|
105 |
err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsSSForcedLightsOn, 0);
|
86
|
106 |
break;
|
|
107 |
}
|
|
108 |
case ESnsrDispCtrlSrvDisplayLowPower:
|
|
109 |
{
|
90
|
110 |
// Disable touch
|
|
111 |
HAL::Set( HALData::EPenState, 0 );
|
|
112 |
|
|
113 |
// Set display mode
|
86
|
114 |
TInt startRow = aMessage.Int0();
|
|
115 |
TInt endRow = aMessage.Int1();
|
|
116 |
// TODO: for now, we pass a zero-filled pixel buffer to power save API.
|
|
117 |
// This works fine with our reference hardware but some types of displays
|
|
118 |
// might require passing the actual screen contents in this buffer.
|
|
119 |
TUint16* ptr = const_cast<TUint16*>( iPowerSavePixelBuffer->Ptr() );
|
|
120 |
err = iPowerSave->Set(startRow, endRow, ptr);
|
|
121 |
break;
|
|
122 |
}
|
|
123 |
case ESnsrDispCtrlSrvDisplayFullPower:
|
|
124 |
{
|
90
|
125 |
// Enable touch
|
|
126 |
HAL::Set( HALData::EPenState, 1 );
|
|
127 |
|
|
128 |
// Set display mode
|
86
|
129 |
err = iPowerSave->Exit();
|
90
|
130 |
|
|
131 |
// Lights on
|
|
132 |
err = RProperty::Set(KPSUidCoreApplicationUIs, KLightsSSForcedLightsOn, 30) || err;
|
86
|
133 |
break;
|
|
134 |
}
|
|
135 |
default:
|
|
136 |
{
|
|
137 |
err = KErrNotSupported;
|
|
138 |
}
|
|
139 |
}
|
|
140 |
|
|
141 |
aMessage.Complete(err);
|
|
142 |
}
|
|
143 |
|