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