|
1 /* |
|
2 * Copyright (c) 2007-2008 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: OOM plugin for skin server. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <ecom/ecom.h> |
|
19 #include <ecom/implementationproxy.h> |
|
20 #include <oommonitorplugin.h> |
|
21 #include <AknsSrvClient.h> |
|
22 #include <w32std.h> |
|
23 |
|
24 class CAknSkinsOomMonitorPlugin : public COomMonitorPlugin |
|
25 { |
|
26 public: |
|
27 CAknSkinsOomMonitorPlugin(); |
|
28 ~CAknSkinsOomMonitorPlugin(); |
|
29 void ConstructL(); |
|
30 |
|
31 public: |
|
32 void FreeRam(); |
|
33 void MemoryGood(); |
|
34 |
|
35 private: |
|
36 RAknsSrvSession iSkinSrvSession; |
|
37 }; |
|
38 |
|
39 // ----------------------------------------------------------------------------- |
|
40 // C++ constructor. |
|
41 // ----------------------------------------------------------------------------- |
|
42 // |
|
43 CAknSkinsOomMonitorPlugin::CAknSkinsOomMonitorPlugin() |
|
44 { |
|
45 } |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // Destructor. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CAknSkinsOomMonitorPlugin::~CAknSkinsOomMonitorPlugin() |
|
52 { |
|
53 iSkinSrvSession.Close(); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // Symbian two-phased constructor (2nd phase). |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 void CAknSkinsOomMonitorPlugin::ConstructL() |
|
61 { |
|
62 COomMonitorPlugin::ConstructL(); |
|
63 User::LeaveIfError( iSkinSrvSession.Connect() ); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // Gets display type. |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 TAknsSrcScreenMode GetDisplayTypeL(RWsSession& aSession) |
|
71 { |
|
72 CWsScreenDevice* sc = new (ELeave) CWsScreenDevice(aSession); |
|
73 CleanupStack::PushL(sc); |
|
74 sc->Construct(); |
|
75 TSize screensize(0,0); |
|
76 screensize = sc->SizeInPixels(); |
|
77 CleanupStack::PopAndDestroy();// screendevice |
|
78 if (screensize.iWidth > screensize.iHeight) |
|
79 { |
|
80 return EAknsSrvScrModeLandscape; |
|
81 } |
|
82 else if (screensize.iWidth < screensize.iHeight) |
|
83 { |
|
84 return EAknsSrvScrModePortrait; |
|
85 } |
|
86 else // square |
|
87 { |
|
88 return EAknsSrvScrModeSquare; |
|
89 } |
|
90 } |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // Tries to free RAM. |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CAknSkinsOomMonitorPlugin::FreeRam() |
|
97 { |
|
98 TInt err(KErrNone); |
|
99 TAknsSrcScreenMode mode = EAknsSrvScrModeSquare; |
|
100 TRAP(err, mode = GetDisplayTypeL(WsSession())); |
|
101 if (mode != EAknsSrvScrModeSquare) |
|
102 { |
|
103 #if defined(_DEBUG) |
|
104 RDebug::Print(_L("CAknSkinsOomMonitorPlugin: Starting to free memory, mode %d"), mode); |
|
105 #endif |
|
106 iSkinSrvSession.FreeUnnecessaryLayoutBitmaps(mode); |
|
107 } |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CAknSkinsOomMonitorPlugin::MemoryGood |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 void CAknSkinsOomMonitorPlugin::MemoryGood() |
|
115 { |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // Creates plugin. |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 TAny* CreatePlugin() |
|
123 { |
|
124 CAknSkinsOomMonitorPlugin* plugin = new(ELeave) CAknSkinsOomMonitorPlugin; |
|
125 CleanupStack::PushL(plugin); |
|
126 plugin->ConstructL(); |
|
127 CleanupStack::Pop(plugin); |
|
128 return plugin; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // Implementation table for plugin. |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 const TImplementationProxy ImplementationTable[] = |
|
136 { |
|
137 {{0x10207140}, ::CreatePlugin} |
|
138 }; |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // ImplementationGroupProxy |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
145 { |
|
146 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy) ; |
|
147 return ImplementationTable; |
|
148 } |
|
149 |
|
150 // End of file |
|
151 |