|
1 /* |
|
2 * Copyright (c) 2005-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: CSysApCenRepController implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "SysApCenRepController.h" |
|
21 #include "SysApAppUi.h" |
|
22 #include "SysAp.hrh" |
|
23 #include "CoreApplicationUIsPrivateCRKeys.h" |
|
24 #include "accessoriescrkeys.h" |
|
25 |
|
26 |
|
27 // ========================== MEMBER FUNCTIONS ================================ |
|
28 |
|
29 // ---------------------------------------------------------------------------- |
|
30 // CSysApCenRepController* CSysApCenRepController::NewL() |
|
31 // ---------------------------------------------------------------------------- |
|
32 |
|
33 CSysApCenRepController* CSysApCenRepController::NewL() |
|
34 { |
|
35 TRACES( RDebug::Print( _L("CSysApCenRepController::NewL" ) ) ); |
|
36 CSysApCenRepController* self = new ( ELeave ) CSysApCenRepController(); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(); //self |
|
40 return self; |
|
41 } |
|
42 |
|
43 // ---------------------------------------------------------------------------- |
|
44 // CSysApCenRepController::CSysApCenRepController() |
|
45 // ---------------------------------------------------------------------------- |
|
46 |
|
47 CSysApCenRepController::CSysApCenRepController() |
|
48 { |
|
49 } |
|
50 |
|
51 // ---------------------------------------------------------------------------- |
|
52 // CSysApCenRepController::~CSysApCenRepController() |
|
53 // ---------------------------------------------------------------------------- |
|
54 |
|
55 CSysApCenRepController::~CSysApCenRepController() |
|
56 { |
|
57 TRACES( RDebug::Print( _L("~CSysApCenRepController") ) ); |
|
58 delete iSysApRepository; |
|
59 delete iProfileSettingsRepository; |
|
60 } |
|
61 |
|
62 // ---------------------------------------------------------------------------- |
|
63 // CSysApCenRepController::ConstructL() |
|
64 // ---------------------------------------------------------------------------- |
|
65 |
|
66 void CSysApCenRepController::ConstructL() |
|
67 { |
|
68 TRACES( RDebug::Print( _L("CSysApCenRepController::ConstructL start" ) ) ); |
|
69 TRAPD( sysapErr, iSysApRepository = CRepository::NewL( KCRUidCoreApplicationUIsSysAp ) ); // 0x101F8765 |
|
70 TRACES( RDebug::Print( _L("CSysApCenRepController::ConstructL sysapErr=%d" ), sysapErr ) ); |
|
71 User::LeaveIfError( sysapErr ); |
|
72 TRAPD( profileErr, iProfileSettingsRepository = CRepository::NewL( KCRUidProfileSettings ) ); // 0x101F877D |
|
73 TRACES( RDebug::Print( _L("CSysApCenRepController::ConstructL profileErr=%d" ), profileErr ) ); |
|
74 User::LeaveIfError( profileErr ); |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CSysApCenRepController::GetInt() |
|
79 // ---------------------------------------------------------------------------- |
|
80 |
|
81 TInt CSysApCenRepController::GetInt( const TUid aRepository, const TUint32 aKey, TBool* aErrorReturn ) |
|
82 { |
|
83 TInt returnValue( 0 ); |
|
84 TInt err( KErrNone ); |
|
85 TBool errorReturn = EFalse; |
|
86 |
|
87 if ( aRepository == KCRUidCoreApplicationUIsSysAp ) |
|
88 { |
|
89 err = iSysApRepository->Get( aKey, returnValue ); |
|
90 if ( err ) |
|
91 { |
|
92 TRACES( RDebug::Print( _L("CSysApCenRepController::GetInt: err=%d (key)" ), err ) ); |
|
93 returnValue = err; |
|
94 errorReturn = ETrue; |
|
95 } |
|
96 } |
|
97 else |
|
98 { |
|
99 CRepository* repository = NULL; |
|
100 TRAP( err, repository = CRepository::NewL( aRepository ) ); |
|
101 if ( err ) |
|
102 { |
|
103 TRACES( RDebug::Print( _L("CSysApCenRepController::GetInt: err=%d (repository)" ), err ) ); |
|
104 returnValue = err; |
|
105 errorReturn = ETrue; |
|
106 } |
|
107 else |
|
108 { |
|
109 err = repository->Get( aKey, returnValue ); |
|
110 if ( err ) |
|
111 { |
|
112 TRACES( RDebug::Print( _L("CSysApCenRepController::GetInt: err=%d (key)" ), err ) ); |
|
113 returnValue = err; |
|
114 errorReturn = ETrue; |
|
115 } |
|
116 } |
|
117 delete repository; |
|
118 } |
|
119 |
|
120 if ( aErrorReturn != NULL ) // caller of this function wants to make distinction between real and error value |
|
121 { |
|
122 *aErrorReturn = errorReturn; |
|
123 } |
|
124 |
|
125 return returnValue; |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // CSysApCenRepController::SetInt() |
|
130 // ---------------------------------------------------------------------------- |
|
131 |
|
132 void CSysApCenRepController::SetInt( const TUid aRepository, const TUint32 aKey, const TInt aNewValue ) |
|
133 { |
|
134 TInt err( KErrNone ); |
|
135 if ( aRepository == KCRUidCoreApplicationUIsSysAp ) |
|
136 { |
|
137 err = iSysApRepository->Set( aKey, aNewValue ); |
|
138 } |
|
139 else |
|
140 { |
|
141 CRepository* repository = NULL; |
|
142 TRAP( err, repository= CRepository::NewL( aRepository ) ); |
|
143 if ( !err ) |
|
144 { |
|
145 err = repository->Set( aKey, aNewValue ); |
|
146 } |
|
147 delete repository; |
|
148 } |
|
149 if ( err ) |
|
150 { |
|
151 TRACES( RDebug::Print( _L("CSysApCenRepController::SetInt: err=%d" ), err ) ); |
|
152 } |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CSysApCenRepController::ProfileIdForSelectedAccessory |
|
157 // ---------------------------------------------------------------------------- |
|
158 |
|
159 TInt CSysApCenRepController::ProfileIdForSelectedAccessory( TSysApAccessoryType aAccessoryType ) |
|
160 { |
|
161 TInt err( 0 ); |
|
162 TInt accessoryProfileId( 0 ); |
|
163 switch( aAccessoryType ) |
|
164 { |
|
165 case ESysApHeadset: |
|
166 err = iProfileSettingsRepository->Get( KSettingsHeadsetDefaultProfile ,accessoryProfileId ); |
|
167 break; |
|
168 case ESysApLoopset: |
|
169 err = iProfileSettingsRepository->Get( KSettingsLoopsetDefaultProfile ,accessoryProfileId ); |
|
170 break; |
|
171 case ESysApTty: |
|
172 err = iProfileSettingsRepository->Get( KSettingsTTYDefaultProfile ,accessoryProfileId ); |
|
173 break; |
|
174 case ESysApWirelessCarkit: |
|
175 err = iProfileSettingsRepository->Get( KSettingsWirelessCarkitDefaultProfile ,accessoryProfileId ); |
|
176 break; |
|
177 case ESysApCarkit: |
|
178 err = iProfileSettingsRepository->Get( KSettingsCarKitDefaultProfile ,accessoryProfileId ); |
|
179 break; |
|
180 case ESysApMusicStand: |
|
181 err = iProfileSettingsRepository->Get( KSettingsMusicStandDefaultProfile ,accessoryProfileId ); |
|
182 break; |
|
183 case ESysApTvOut: |
|
184 err = iProfileSettingsRepository->Get( KSettingsTvOutDefaultProfile ,accessoryProfileId ); |
|
185 break; |
|
186 case ESysApHeadphones: |
|
187 err = iProfileSettingsRepository->Get( KSettingsHeadphonesDefaultProfile ,accessoryProfileId ); |
|
188 break; |
|
189 default: |
|
190 break; |
|
191 } |
|
192 |
|
193 if( err ) |
|
194 { |
|
195 TRACES( RDebug::Print( _L("CSysApCenRepController::ProfileIdForSelectedAccessory: err=%d" ), err ) ); |
|
196 return 0; // General profile |
|
197 } |
|
198 else |
|
199 { |
|
200 return accessoryProfileId; |
|
201 } |
|
202 } |
|
203 |
|
204 // End of File |
|
205 |