13 * |
13 * |
14 * Description: |
14 * Description: |
15 * |
15 * |
16 */ |
16 */ |
17 |
17 |
|
18 // System includes |
|
19 #include <centralrepository.h> |
|
20 |
18 // User includes |
21 // User includes |
|
22 #include "cradiosettingsimp.h" |
19 #include "radiointernalcrkeys.h" |
23 #include "radiointernalcrkeys.h" |
20 #include "cradioapplicationsettings.h" |
24 #include "cradioapplicationsettings.h" |
21 #include "cradiorepositorymanager.h" |
|
22 #include "cradioenginelogger.h" |
25 #include "cradioenginelogger.h" |
23 |
26 |
|
27 // This has to be the last include. |
|
28 #ifdef STUB_CONSTELLATION |
|
29 # include <RadioStubManager.h> |
|
30 #endif //STUB_CONSTELLATION |
24 |
31 |
25 // ======== MEMBER FUNCTIONS ======== |
32 // ======== MEMBER FUNCTIONS ======== |
26 |
33 |
27 // --------------------------------------------------------------------------- |
34 // --------------------------------------------------------------------------- |
28 // |
35 // |
29 // --------------------------------------------------------------------------- |
36 // --------------------------------------------------------------------------- |
30 // |
37 // |
31 CRadioApplicationSettings* CRadioApplicationSettings::NewL( CRadioRepositoryManager& aRepositoryManager, |
38 CRadioApplicationSettings* CRadioApplicationSettings::NewL() |
32 CCoeEnv& aCoeEnv ) |
|
33 { |
39 { |
34 CRadioApplicationSettings* self = new ( ELeave ) CRadioApplicationSettings( aRepositoryManager, aCoeEnv ); |
40 LEVEL3( LOG_METHOD_AUTO ); |
|
41 CRadioApplicationSettings* self = new ( ELeave ) CRadioApplicationSettings(); |
35 CleanupStack::PushL( self ); |
42 CleanupStack::PushL( self ); |
36 self->ConstructL(); |
43 self->ConstructL(); |
37 CleanupStack::Pop( self ); |
44 CleanupStack::Pop( self ); |
38 return self; |
45 return self; |
39 } |
46 } |
42 // |
49 // |
43 // --------------------------------------------------------------------------- |
50 // --------------------------------------------------------------------------- |
44 // |
51 // |
45 void CRadioApplicationSettings::ConstructL() |
52 void CRadioApplicationSettings::ConstructL() |
46 { |
53 { |
47 iRepositoryManager.AddEntityL( KRadioCRUid, KRadioCRActiveFocusLocation, CRadioRepositoryManager::ERadioEntityInt ); |
54 LEVEL2( LOG_METHOD_AUTO ); |
48 iRepositoryManager.AddEntityL( KRadioCRUid, KRadioCRAudioPlayHistory, CRadioRepositoryManager::ERadioEntityInt ); |
55 iRepository = CRepository::NewL( KRadioCRUid ); |
49 iRepositoryManager.AddEntityL( KRadioCRUid, KRadioCRUiFlags, CRadioRepositoryManager::ERadioEntityInt ); |
56 LOG_FORMAT( "iRepository = %i", iRepository ); |
50 } |
57 } |
51 |
58 |
52 // --------------------------------------------------------------------------- |
59 // --------------------------------------------------------------------------- |
53 // |
60 // |
54 // --------------------------------------------------------------------------- |
61 // --------------------------------------------------------------------------- |
55 // |
62 // |
56 CRadioApplicationSettings::CRadioApplicationSettings( CRadioRepositoryManager& aRepositoryManager, |
63 CRadioApplicationSettings::CRadioApplicationSettings() |
57 CCoeEnv& aCoeEnv ) |
|
58 : CRadioSettingsBase( aRepositoryManager, aCoeEnv ) |
|
59 { |
64 { |
|
65 LEVEL3( LOG_METHOD_AUTO ); |
60 } |
66 } |
61 |
67 |
62 // --------------------------------------------------------------------------- |
68 // --------------------------------------------------------------------------- |
63 // |
69 // |
64 // --------------------------------------------------------------------------- |
70 // --------------------------------------------------------------------------- |
65 // |
71 // |
66 CRadioApplicationSettings::~CRadioApplicationSettings() |
72 CRadioApplicationSettings::~CRadioApplicationSettings() |
67 { |
73 { |
|
74 LEVEL3( LOG_METHOD_AUTO ); |
|
75 delete iRepository; |
68 } |
76 } |
69 |
77 |
70 // --------------------------------------------------------------------------- |
78 // --------------------------------------------------------------------------- |
71 // From class MRadioApplicationSettings. |
79 // From class MRadioApplicationSettings. |
72 // |
80 // |
73 // --------------------------------------------------------------------------- |
81 // --------------------------------------------------------------------------- |
74 // |
82 // |
75 TInt CRadioApplicationSettings::SetActiveFocusLocation( TInt aIndex ) |
83 TBool CRadioApplicationSettings::IsFirstTimeStart() |
76 { |
84 { |
77 return iRepositoryManager.SetEntityValue( KRadioCRUid, KRadioCRActiveFocusLocation, aIndex ); |
85 LEVEL3( LOG_METHOD_AUTO ); |
|
86 TInt startCount = 0; |
|
87 iRepository->Get( KRadioCRLaunchCount, startCount ); |
|
88 |
|
89 return startCount == 0; |
78 } |
90 } |
79 |
91 |
80 // --------------------------------------------------------------------------- |
92 // --------------------------------------------------------------------------- |
81 // From class MRadioApplicationSettings. |
93 // From class MRadioApplicationSettings. |
82 // |
94 // |
83 // --------------------------------------------------------------------------- |
95 // --------------------------------------------------------------------------- |
84 // |
96 // |
85 TInt CRadioApplicationSettings::ActiveFocusLocation() const |
97 void CRadioApplicationSettings::SetFirstTimeStartPerformed( TBool aFirstTimeStartPerformed ) |
86 { |
98 { |
87 return iRepositoryManager.EntityValueInt( KRadioCRUid, KRadioCRActiveFocusLocation ); |
99 LEVEL3( LOG_METHOD_AUTO ); |
|
100 iRepository->Set( KRadioCRLaunchCount, aFirstTimeStartPerformed ? 1 : 0 ); |
88 } |
101 } |
89 |
102 |
90 // --------------------------------------------------------------------------- |
|
91 // From class MRadioApplicationSettings. |
|
92 // |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 void CRadioApplicationSettings::SetAudioPlayHistoryL( TRadioCRAudioPlayHistory aHistory ) |
|
96 { |
|
97 if ( AudioPlayHistory() != ERadioCRAudioPlayed ) |
|
98 { |
|
99 User::LeaveIfError( iRepositoryManager.SetEntityValue( KRadioCRUid, KRadioCRAudioPlayHistory, aHistory ) ); |
|
100 } |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // From class MRadioApplicationSettings. |
|
105 // |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 MRadioApplicationSettings::TRadioCRAudioPlayHistory CRadioApplicationSettings::AudioPlayHistory() const |
|
109 { |
|
110 return static_cast<TRadioCRAudioPlayHistory>( |
|
111 iRepositoryManager.EntityValueInt( KRadioCRUid, KRadioCRAudioPlayHistory ) ); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // From class MRadioApplicationSettings. |
|
116 // |
|
117 // --------------------------------------------------------------------------- |
|
118 // |
|
119 TInt CRadioApplicationSettings::UpdateStartCount() |
|
120 { |
|
121 TInt startCount = 0; |
|
122 TRAP_IGNORE |
|
123 ( |
|
124 CRadioRepositoryManager::GetRepositoryValueL( KRadioCRUid, KRadioCRLaunchCount, startCount ); |
|
125 CRadioRepositoryManager::SetRepositoryValueL( KRadioCRUid, KRadioCRLaunchCount, startCount + 1 ); |
|
126 ); |
|
127 return startCount; |
|
128 } |
|
129 |
103 |
130 // --------------------------------------------------------------------------- |
104 // --------------------------------------------------------------------------- |
131 // From class MRadioApplicationSettings. |
105 // From class MRadioApplicationSettings. |
132 // |
106 // |
133 // --------------------------------------------------------------------------- |
107 // --------------------------------------------------------------------------- |
134 // |
108 // |
135 TInt CRadioApplicationSettings::SetUiFlags( TUint aUiFlags ) |
109 TInt CRadioApplicationSettings::SetUiFlags( TUint aUiFlags ) |
136 { |
110 { |
137 return iRepositoryManager.SetEntityValue( KRadioCRUid, KRadioCRUiFlags, static_cast<TInt>( aUiFlags ) ); |
111 LEVEL3( LOG_METHOD_AUTO ); |
|
112 return iRepository->Set( KRadioCRUiFlags, static_cast<TInt>( aUiFlags ) ); |
138 } |
113 } |
139 |
114 |
140 // --------------------------------------------------------------------------- |
115 // --------------------------------------------------------------------------- |
141 // From class MRadioApplicationSettings. |
116 // From class MRadioApplicationSettings. |
142 // |
117 // |
143 // --------------------------------------------------------------------------- |
118 // --------------------------------------------------------------------------- |
144 // |
119 // |
145 TUint CRadioApplicationSettings::UiFlags() const |
120 TUint CRadioApplicationSettings::UiFlags() const |
146 { |
121 { |
147 return static_cast<TUint>( iRepositoryManager.EntityValueInt( KRadioCRUid, KRadioCRUiFlags ) ); |
122 LEVEL3( LOG_METHOD_AUTO ); |
|
123 TInt uiFlags( 0 ); |
|
124 iRepository->Get( KRadioCRUiFlags, uiFlags ); |
|
125 return static_cast<TUint>( uiFlags ); |
148 } |
126 } |