|
1 /* |
|
2 * Copyright (c) 2006 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: |
|
15 * BT HID settings manager |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include <e32property.h> |
|
23 #include <e32debug.h> |
|
24 #include <centralrepository.h> |
|
25 #include "btengprivatecrkeys.h" |
|
26 #include "bthidsettings.h" |
|
27 #include "debug.h" |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CBtHidSettings::CBtHidSettings |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 EXPORT_C CBtHidSettings::CBtHidSettings() |
|
38 {} |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CBtHidSettings::ConstructL |
|
42 // Symbian 2nd phase constructor can leave. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C void CBtHidSettings::ConstructL() |
|
46 {} |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // CBtHidSettings::NewL |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CBtHidSettings* CBtHidSettings::NewL() |
|
54 { |
|
55 CBtHidSettings* self = CBtHidSettings::NewLC(); |
|
56 CleanupStack::Pop(); |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CBtHidSettings::NewLC |
|
64 // Two-phased constructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 EXPORT_C CBtHidSettings* CBtHidSettings::NewLC() |
|
68 { |
|
69 CBtHidSettings* self = new( ELeave ) CBtHidSettings; |
|
70 |
|
71 CleanupStack::PushL( self ); |
|
72 self->ConstructL(); |
|
73 |
|
74 return self; |
|
75 } |
|
76 |
|
77 |
|
78 // Destructor |
|
79 EXPORT_C CBtHidSettings::~CBtHidSettings() |
|
80 {} |
|
81 |
|
82 // ---------------------------------------------------- |
|
83 // CBtHidSettings::LoadLayoutSetting() |
|
84 // ---------------------------------------------------- |
|
85 // |
|
86 EXPORT_C THidKeyboardLayoutId CBtHidSettings::LoadLayoutSetting() |
|
87 { |
|
88 TInt layout; |
|
89 |
|
90 TInt err = GetValue( KBtHidKeyboardLayout, layout ); |
|
91 if( KErrNone != err) |
|
92 { |
|
93 TRACE_INFO( (_L("[HID]\tGetValue() error (%d)\n"), err)); |
|
94 layout = 0; |
|
95 } |
|
96 |
|
97 // Convert the Int to the enum. |
|
98 THidKeyboardLayoutId layoutID = |
|
99 static_cast<THidKeyboardLayoutId>(layout); |
|
100 |
|
101 TRACE_INFO( (_L("[HID]\tCBtHidSettings::LoadLayoutSetting()(%d)\n"), |
|
102 layoutID)); |
|
103 return layoutID; |
|
104 } |
|
105 |
|
106 // ---------------------------------------------------- |
|
107 // CBtHidSettings::SaveLayoutSettingL |
|
108 // ---------------------------------------------------- |
|
109 // |
|
110 EXPORT_C void CBtHidSettings::SaveLayoutSettingL(THidKeyboardLayoutId aNewValue) const |
|
111 { |
|
112 User::LeaveIfError( SetValue( KBtHidKeyboardLayout, aNewValue ) ); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CBtHidSettings::SetValue |
|
117 // Sets integer value to CenRep |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TInt CBtHidSettings::SetValue( const TUint32 aKey, const TInt aValue ) const |
|
121 { |
|
122 TRACE_INFO(_L("[BTHID]\t CBtHidSettings::SetValue")); |
|
123 CRepository* cenrep = NULL; |
|
124 TRAPD(status, cenrep = CRepository::NewL(KCRUidBTEngPrivateSettings)); |
|
125 if( status == KErrNone) |
|
126 { |
|
127 status = cenrep->Set( aKey, aValue ); |
|
128 delete cenrep; |
|
129 } |
|
130 if( status != KErrNone) |
|
131 { |
|
132 TRACE_INFO(_L("Cenrep fail")); |
|
133 } |
|
134 return status; |
|
135 } |
|
136 |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CBtHidSettings::GetValue |
|
140 // Gets integer value from CenRep |
|
141 // ----------------------------------------------------------------------------- |
|
142 // |
|
143 TInt CBtHidSettings::GetValue( const TUint32 aKey, TInt& aValue ) |
|
144 { |
|
145 TRACE_INFO(_L("[BTHID]\t CBtHidSettings::GetValue")); |
|
146 CRepository* cenrep = NULL; |
|
147 TRAPD( status , cenrep = CRepository::NewL(KCRUidBTEngPrivateSettings)); |
|
148 if( status == KErrNone) |
|
149 { |
|
150 status = cenrep->Get( aKey, aValue ); |
|
151 delete cenrep; |
|
152 } |
|
153 if( status != KErrNone) |
|
154 { |
|
155 TRACE_INFO(_L("Cenrep fail")); |
|
156 } |
|
157 |
|
158 TRACE_FUNC_EXIT |
|
159 return status; |
|
160 } |
|
161 |
|
162 // End of File |
|
163 |
|
164 |
|
165 |