|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (developer.feedback@nokia.com) |
|
6 ** |
|
7 ** This file is part of the HbServers module of the UI Extensions for Mobile. |
|
8 ** |
|
9 ** GNU Lesser General Public License Usage |
|
10 ** This file may be used under the terms of the GNU Lesser General Public |
|
11 ** License version 2.1 as published by the Free Software Foundation and |
|
12 ** appearing in the file LICENSE.LGPL included in the packaging of this file. |
|
13 ** Please review the following information to ensure the GNU Lesser General |
|
14 ** Public License version 2.1 requirements will be met: |
|
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
16 ** |
|
17 ** In addition, as a special exception, Nokia gives you certain additional |
|
18 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
20 ** |
|
21 ** If you have questions regarding the use of this file, please contact |
|
22 ** Nokia at developer.feedback@nokia.com. |
|
23 ** |
|
24 ****************************************************************************/ |
|
25 |
|
26 #include "hbthemeclientoogm_p.h" |
|
27 |
|
28 const TUint KDefaultMessageSlots=4; |
|
29 |
|
30 |
|
31 /*! |
|
32 * Constructor |
|
33 */ |
|
34 HbThemeClientOogm::HbThemeClientOogm(): connected(false) |
|
35 { |
|
36 } |
|
37 |
|
38 |
|
39 /*! |
|
40 * Connects to the server using 4 message slots. |
|
41 * returns true if connection succeeds. |
|
42 */ |
|
43 bool HbThemeClientOogm::ConnectToServer() |
|
44 { |
|
45 |
|
46 TInt error = CreateSession(KThemeServerName, Version(), KDefaultMessageSlots); |
|
47 |
|
48 if (KErrNone != error) { |
|
49 RDebug::Print(_L("ThemeServerPlugin : Server Connection request failed")); |
|
50 return false; |
|
51 } |
|
52 connected = true; |
|
53 return connected; |
|
54 } |
|
55 |
|
56 |
|
57 /*! |
|
58 * Returns the earliest version number of the server that we can talk to. |
|
59 */ |
|
60 TVersion HbThemeClientOogm::Version(void) const |
|
61 { |
|
62 return(TVersion(KThemeServerMajorVersionNumber, KThemeServerMinorVersionNumber, KThemeServerBuildVersionNumber)); |
|
63 } |
|
64 |
|
65 |
|
66 /*! |
|
67 * Closing the server and tidying up. |
|
68 */ |
|
69 void HbThemeClientOogm::Close() |
|
70 { |
|
71 RSessionBase::Close(); |
|
72 } |
|
73 |
|
74 /*! |
|
75 * Sends FreeRam request to HbThemeserver with the bytes to be freed. |
|
76 * see goomconfig.xml as what is the threshold that triggers a call to this API. |
|
77 */ |
|
78 |
|
79 void HbThemeClientOogm::FreeRam(int bytes) |
|
80 { |
|
81 if (!connected) { |
|
82 ConnectToServer(); |
|
83 } |
|
84 |
|
85 if (connected) { |
|
86 TPckg<TInt> bytesToFree(bytes); |
|
87 TIpcArgs args(&bytesToFree, 0); |
|
88 |
|
89 TInt err = SendReceive(EFreeRam, args); |
|
90 if (KErrNone != err) { |
|
91 RDebug::Print(_L("ThemeServerPlugin: Free RAM notification sent to ThemeServer")); |
|
92 } |
|
93 } |
|
94 } |
|
95 |
|
96 /*! |
|
97 * Sends MemoryGood request to HbThemeserver. |
|
98 * see goomconfig.xml as what is the threshold that triggers a call to this API. |
|
99 */ |
|
100 |
|
101 void HbThemeClientOogm::GoodMemory() |
|
102 { |
|
103 if (!connected) { |
|
104 ConnectToServer(); |
|
105 } |
|
106 |
|
107 if (connected) { |
|
108 TInt err = SendReceive(EMemoryGood); |
|
109 if (KErrNone != err) { |
|
110 RDebug::Print(_L("ThemeServerPlugin: Good Memory notification sent to ThemeServer")); |
|
111 } |
|
112 } |
|
113 } |
|
114 |