|
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: LandmarksUi Content File - |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // System Include |
|
26 #include <centralrepository.h> |
|
27 #include <locnotprefplugindomaincrkeys.h> |
|
28 #include <lmkerrors.h> |
|
29 |
|
30 // INCLUDE FILES |
|
31 #include "clmkcentralrepository.h" |
|
32 |
|
33 // CONSTANTS |
|
34 const TUint32 KNullKey = 0; |
|
35 #if defined(_DEBUG) |
|
36 /// Unnamed namespace for local definitions |
|
37 namespace { |
|
38 |
|
39 _LIT( KPanicMsg, "CLmkCentralRepository"); |
|
40 |
|
41 void Panic( TPanicCode aReason ) |
|
42 { |
|
43 User::Panic( KPanicMsg, aReason ); |
|
44 } |
|
45 } // namespace |
|
46 #endif |
|
47 |
|
48 |
|
49 // ============================ MEMBER FUNCTIONS ============================== |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CLmkCentralRepository::CLmkCentralRepository() |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CLmkCentralRepository::CLmkCentralRepository( TUint32 aKey , |
|
56 MLmkCentralRepositoryObserver* aObserver) |
|
57 :CActive( EPriorityStandard ), |
|
58 iKey( aKey ), |
|
59 iObserver( aObserver ) |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CLmkCentralRepository::~CLmkCentralRepository() |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CLmkCentralRepository::~CLmkCentralRepository() |
|
68 { |
|
69 Cancel(); |
|
70 delete iRepository; |
|
71 iRepository = NULL; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // CLmkCentralRepository::NewL() |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CLmkCentralRepository* CLmkCentralRepository::NewL() |
|
79 { |
|
80 CLmkCentralRepository* self = |
|
81 CLmkCentralRepository::NewLC(); |
|
82 CleanupStack::Pop(self); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CLmkCentralRepository::NewLC() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 CLmkCentralRepository* CLmkCentralRepository::NewLC() |
|
91 { |
|
92 CLmkCentralRepository* self = |
|
93 new(ELeave) CLmkCentralRepository( KNullKey,NULL ); |
|
94 CleanupStack::PushL(self); |
|
95 self->ConstructL(); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // CLmkCentralRepository::NewL() |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 CLmkCentralRepository* CLmkCentralRepository::NewL( TUint32 aKey , |
|
104 MLmkCentralRepositoryObserver* aObserver) |
|
105 { |
|
106 CLmkCentralRepository* self = |
|
107 CLmkCentralRepository::NewLC( aKey, aObserver); |
|
108 CleanupStack::Pop(self); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CLmkCentralRepository::NewLC() |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CLmkCentralRepository* CLmkCentralRepository::NewLC( TUint32 aKey , |
|
117 MLmkCentralRepositoryObserver* aObserver) |
|
118 { |
|
119 CLmkCentralRepository* self = |
|
120 new(ELeave) CLmkCentralRepository( aKey,aObserver ); |
|
121 CleanupStack::PushL(self); |
|
122 self->Construct2L(); |
|
123 return self; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CLmkCentralRepository::Construct2L() |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 void CLmkCentralRepository::Construct2L() |
|
131 { |
|
132 ConstructL(); |
|
133 StartNotification(); |
|
134 } |
|
135 // --------------------------------------------------------------------------- |
|
136 // CLmkCentralRepository::ConstructL() |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CLmkCentralRepository::ConstructL() |
|
140 { |
|
141 CActiveScheduler::Add( this ); |
|
142 //creates central repository |
|
143 iRepository = CRepository::NewL(TUid::Uid( KCRUidLocNotationPref )); |
|
144 } |
|
145 |
|
146 // -------------------------------------------------------------------------- |
|
147 // CLmkCentralRepository::RunL() |
|
148 // --------------------------------------------------------------------------- |
|
149 // |
|
150 void CLmkCentralRepository::RunL() |
|
151 { |
|
152 // Issue Notification |
|
153 iObserver->HandleCentralRepositoryChangeL(); |
|
154 |
|
155 // Schedule for listening to change events again |
|
156 StartNotification(); |
|
157 } |
|
158 |
|
159 // -------------------------------------------------------------------------- |
|
160 // CLmkCentralRepository::DoCancel() |
|
161 // --------------------------------------------------------------------------- |
|
162 // |
|
163 void CLmkCentralRepository::DoCancel() |
|
164 { |
|
165 if( iKey != KNullKey) |
|
166 { |
|
167 // Cancel the outstanding CR notification request |
|
168 iRepository->NotifyCancel( iKey ); |
|
169 } |
|
170 } |
|
171 |
|
172 // -------------------------------------------------------------------------- |
|
173 // CLmkCentralRepository::StartNotification() |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 TInt CLmkCentralRepository::StartNotification() |
|
177 { |
|
178 __ASSERT_DEBUG( iObserver, Panic( KLmkPanicNullMember ) ); |
|
179 __ASSERT_DEBUG( iKey != KNullKey, Panic( KLmkPanicKeyNotSet ) ); |
|
180 TInt err = KErrNone; |
|
181 if( !IsActive()) |
|
182 { |
|
183 iStatus = KRequestPending; |
|
184 // Request for notification |
|
185 err = iRepository->NotifyRequest( iKey, iStatus); |
|
186 if( KErrNone == err ) |
|
187 { |
|
188 SetActive(); |
|
189 } |
|
190 } |
|
191 return err; |
|
192 } |
|
193 |
|
194 // -------------------------------------------------------------------------- |
|
195 // CLmkCentralRepository::GetKeyValue() |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 TInt CLmkCentralRepository::GetKeyValue(TUint32 aKey, TInt& aValue) |
|
199 { |
|
200 return iRepository->Get( aKey,aValue ); |
|
201 } |
|
202 // End of File |
|
203 |