|
1 /* |
|
2 * Copyright (c) 2007 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: Handle BT power state related to PSM mode |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef BTPSMPLUGIN_H |
|
20 #define BTPSMPLUGIN_H |
|
21 |
|
22 #include <psmpluginbase.h> |
|
23 #include <btengsettings.h> |
|
24 |
|
25 |
|
26 /** |
|
27 * Plug-in of PowerSaveMode (PSM) |
|
28 * implements PSM plug-in and setting configuration API, |
|
29 * handles BT power state when entering and leaving PSM mode. |
|
30 * |
|
31 * @since S60 v5.1 |
|
32 */ |
|
33 class CBTPsmPlugin : public CPsmPluginBase, |
|
34 public MBTEngSettingsObserver |
|
35 { |
|
36 public: |
|
37 |
|
38 /** |
|
39 * Two-phased constructor. |
|
40 * |
|
41 * @param aInitParams Passed by the caller. |
|
42 */ |
|
43 static CBTPsmPlugin* NewL(TPsmPluginCTorParams& aInitParams); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 */ |
|
48 virtual ~CBTPsmPlugin(); |
|
49 |
|
50 /** |
|
51 * From CPsmPluginBase |
|
52 * |
|
53 * Notifies plugin about the power save mode change. There is only one |
|
54 * active plugin at a time in psmserver, meaning that when this plugin has done |
|
55 * its mode change, next plugin has process time to complete its mode change. |
|
56 * Because of this it is good not to make any heavy process during this mode change. |
|
57 * |
|
58 * @since S60 v5.1 |
|
59 * @param aMode Mode to change to. |
|
60 */ |
|
61 void NotifyModeChange( const TInt aMode ); |
|
62 |
|
63 /** |
|
64 * From MBTEngSettingsObserver |
|
65 * When BT PowerState is changed in PSM mode, write it into PSM data storage. |
|
66 * |
|
67 * @since S60 v5.1 |
|
68 * @param aState EBTPowerOff if the BT hardware has been turned off, |
|
69 * EBTPowerOn if it has been turned off. |
|
70 */ |
|
71 void PowerStateChanged( TBTPowerStateValue aState ); |
|
72 |
|
73 /** |
|
74 * From MBTEngSettingsObserver |
|
75 * Power Saving Mode change does not affect Bluetooth visibility. |
|
76 * |
|
77 * @since S60 v5.1 |
|
78 * @param aState EBTDiscModeHidden if the BT hardware is in hidden mode, |
|
79 * EBTDiscModeGeneral if it is in visible mode. |
|
80 */ |
|
81 void VisibilityModeChanged( TBTVisibilityMode /*aState*/ ); |
|
82 |
|
83 private: |
|
84 |
|
85 /** |
|
86 * Default C++ constructor |
|
87 * |
|
88 * @param aInitParams Passed by the caller. |
|
89 */ |
|
90 CBTPsmPlugin(TPsmPluginCTorParams& aInitParams); |
|
91 |
|
92 /** |
|
93 * Symbian 2nd-phase constructor |
|
94 * |
|
95 * @since S60 v5.1 |
|
96 */ |
|
97 void ConstructL(); |
|
98 |
|
99 /** |
|
100 * Leave function called by NotifyModeChange(). |
|
101 * |
|
102 * @since S60 v5.1 |
|
103 */ |
|
104 void NotifyModeChangeL(); |
|
105 |
|
106 /** |
|
107 * Handle whether and how to update the current BT Power state |
|
108 * |
|
109 * @since S60 v5.1 |
|
110 */ |
|
111 void HandlePowerStateL(); |
|
112 |
|
113 /** |
|
114 * Get setting from PSM configuration file |
|
115 * |
|
116 * @since S60 v5.1 |
|
117 * @return TBTPowerStateValue The power state stored in PSM configuration storage. |
|
118 */ |
|
119 TBTPowerStateValue GetSettingsFromPsmStorageL(); |
|
120 |
|
121 /** |
|
122 * Save configuration into PSM storage. Backup the setting before entering PSM |
|
123 * or update the setting when the user changes BT PowerState in PSM mode |
|
124 * |
|
125 * @param aState The current BT power state. |
|
126 */ |
|
127 void SavePsmConfigurationL(TBTPowerStateValue aState); |
|
128 |
|
129 private: // data |
|
130 |
|
131 /** |
|
132 * BTEng Settings class |
|
133 * Owned |
|
134 */ |
|
135 CBTEngSettings* iBtEngSettings; |
|
136 |
|
137 /** |
|
138 * TPsmsrvMode type defination in psmtypes.h |
|
139 */ |
|
140 TInt iMode; |
|
141 |
|
142 /** |
|
143 * Flag if allow the change of power state to be written into PSM storage. |
|
144 * EFalse is the default value, when EBTPowerOn before PSM is activated. |
|
145 * ETrue when EBTPowerOff or active connections before PSM is activated, |
|
146 * or when PowerON becomes OFF after PSM is activated. |
|
147 */ |
|
148 TBool iAllowToConfig; |
|
149 }; |
|
150 |
|
151 #endif // BTPSMPLUGIN_H |