|
1 /* |
|
2 * Copyright (c) 2004 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: Methods for CNcnCRRepositoryHandler class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "NcnDebug.h" |
|
22 #include "CNcnCRRepositoryHandler.h" |
|
23 #include "MNcnCRRepositoryHandlerCallback.h" |
|
24 |
|
25 // ================= LOCAL CONSTANTS ======================= |
|
26 namespace |
|
27 { |
|
28 } |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // ---------------------------------------------------- |
|
33 // CNcnCRRepositoryHandler::CNcnCRRepositoryHandler |
|
34 // ---------------------------------------------------- |
|
35 // |
|
36 CNcnCRRepositoryHandler::CNcnCRRepositoryHandler( |
|
37 MNcnCRRepositoryHandlerCallback& aCallback, |
|
38 CRepository& aRepository, |
|
39 CCenRepNotifyHandler::TCenRepKeyType aKeyType, |
|
40 TUint32 aId ) : |
|
41 iCallback( aCallback ), |
|
42 iRepository( aRepository ), |
|
43 iKeyType( aKeyType ), |
|
44 iId( aId ) |
|
45 { |
|
46 // empty |
|
47 } |
|
48 |
|
49 // ---------------------------------------------------- |
|
50 // CNcnCRRepositoryHandler::NewL |
|
51 // ---------------------------------------------------- |
|
52 // |
|
53 CNcnCRRepositoryHandler* CNcnCRRepositoryHandler::NewL( |
|
54 MNcnCRRepositoryHandlerCallback& aCallback, |
|
55 CRepository& aRepository, |
|
56 CCenRepNotifyHandler::TCenRepKeyType aKeyType, |
|
57 TUint32 aId ) |
|
58 { |
|
59 CNcnCRRepositoryHandler* self = |
|
60 new (ELeave) CNcnCRRepositoryHandler( |
|
61 aCallback, |
|
62 aRepository, |
|
63 aKeyType, |
|
64 aId ); |
|
65 |
|
66 return self; |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------- |
|
70 // CNcnCRRepositoryHandler::~CNcnCRRepositoryHandler |
|
71 // ---------------------------------------------------- |
|
72 // |
|
73 CNcnCRRepositoryHandler::~CNcnCRRepositoryHandler() |
|
74 { |
|
75 // just stop listening (releases allocated resources) |
|
76 StopListening(); |
|
77 } |
|
78 |
|
79 // ---------------------------------------------------- |
|
80 // CNcnCRRepositoryHandler::HandleNotifyInt |
|
81 // ---------------------------------------------------- |
|
82 // |
|
83 void CNcnCRRepositoryHandler::HandleNotifyInt(TUint32 aId, TInt aNewValue) |
|
84 { |
|
85 // delegate to callback |
|
86 iCallback.HandleRepositoryNotifyInt( iRepository, aId, aNewValue ); |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------- |
|
90 // CNcnCRRepositoryHandler::HandleNotifyReal |
|
91 // ---------------------------------------------------- |
|
92 // |
|
93 void CNcnCRRepositoryHandler::HandleNotifyReal(TUint32 aId, TReal aNewValue) |
|
94 { |
|
95 // delegate to callback |
|
96 iCallback.HandleRepositoryNotifyReal( iRepository, aId, aNewValue ); |
|
97 } |
|
98 |
|
99 // ---------------------------------------------------- |
|
100 // CNcnCRRepositoryHandler::HandleNotifyString |
|
101 // ---------------------------------------------------- |
|
102 // |
|
103 void CNcnCRRepositoryHandler::HandleNotifyString(TUint32 aId, const TDesC16& aNewValue) |
|
104 { |
|
105 // delegate to callback |
|
106 iCallback.HandleRepositoryNotifyString( iRepository, aId, aNewValue ); |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------- |
|
110 // CNcnCRRepositoryHandler::HandleNotifyBinary |
|
111 // ---------------------------------------------------- |
|
112 // |
|
113 void CNcnCRRepositoryHandler::HandleNotifyBinary(TUint32 aId, const TDesC8& aNewValue) |
|
114 { |
|
115 // delegate to callback |
|
116 iCallback.HandleRepositoryNotifyBinary( iRepository, aId, aNewValue ); |
|
117 } |
|
118 |
|
119 // ---------------------------------------------------- |
|
120 // CNcnCRRepositoryHandler::HandleNotifyGeneric |
|
121 // ---------------------------------------------------- |
|
122 // |
|
123 void CNcnCRRepositoryHandler::HandleNotifyGeneric(TUint32 aId) |
|
124 { |
|
125 // delegate to callback |
|
126 iCallback.HandleRepositoryNotifyGeneric( iRepository, aId ); |
|
127 } |
|
128 |
|
129 // ---------------------------------------------------- |
|
130 // CNcnCRRepositoryHandler::HandleNotifyError |
|
131 // ---------------------------------------------------- |
|
132 // |
|
133 void CNcnCRRepositoryHandler::HandleNotifyError(TUint32 aId, |
|
134 TInt aError, |
|
135 CCenRepNotifyHandler* aHandler) |
|
136 { |
|
137 // delegate to callback |
|
138 iCallback.HandleRepositoryNotifyError( iRepository, aId, aError, aHandler ); |
|
139 } |
|
140 |
|
141 // ---------------------------------------------------- |
|
142 // CNcnCRRepositoryHandler::StartListeningL |
|
143 // ---------------------------------------------------- |
|
144 // |
|
145 void CNcnCRRepositoryHandler::StartListeningL() |
|
146 { |
|
147 // if notify handler is not yet instantiated |
|
148 if( !iNotifyHandler ) |
|
149 { |
|
150 // instantiate notify handler |
|
151 iNotifyHandler = |
|
152 CCenRepNotifyHandler::NewL( |
|
153 *this, |
|
154 iRepository, |
|
155 iKeyType, |
|
156 iId ); |
|
157 |
|
158 // and start listening |
|
159 iNotifyHandler->StartListeningL(); |
|
160 } |
|
161 } |
|
162 |
|
163 // ---------------------------------------------------- |
|
164 // CNcnCRRepositoryHandler::StopListening |
|
165 // ---------------------------------------------------- |
|
166 // |
|
167 void CNcnCRRepositoryHandler::StopListening() |
|
168 { |
|
169 // if notify handler is instantiated |
|
170 if( iNotifyHandler ) |
|
171 { |
|
172 // stop listening and delete the instance |
|
173 iNotifyHandler->StopListening(); |
|
174 delete iNotifyHandler; |
|
175 iNotifyHandler = 0; |
|
176 } |
|
177 } |
|
178 |
|
179 |
|
180 // End of File |