|
1 /* |
|
2 * Copyright (c) 2010 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 * |
|
16 */ |
|
17 |
|
18 #include "settingslistenerimpl.h" |
|
19 #include "cenreplistener.h" |
|
20 #include "logger.h" |
|
21 |
|
22 namespace java |
|
23 { |
|
24 namespace captain |
|
25 { |
|
26 |
|
27 SettingsListenerImpl::SettingsListenerImpl(CoreInterface* aCore) : |
|
28 mCore(aCore) |
|
29 { |
|
30 } |
|
31 |
|
32 SettingsListenerImpl::~SettingsListenerImpl() |
|
33 { |
|
34 cleanUp(); |
|
35 } |
|
36 |
|
37 void SettingsListenerImpl::startListening() |
|
38 { |
|
39 // All "listeners" must be created&started here. |
|
40 |
|
41 // Currently there is just this one CenRep key to be listened |
|
42 TInt error = KErrNone; |
|
43 CenRepListener* crMidpClassPathChangeListener = |
|
44 createCenRepKeyListener(KCRUidJavaRuntime, KJavaRuntimeMIDPClasspath, |
|
45 CCenRepNotifyHandler::EStringKey, error); |
|
46 if (crMidpClassPathChangeListener) |
|
47 { |
|
48 mCenRepListeners.push_back(crMidpClassPathChangeListener); |
|
49 } |
|
50 else |
|
51 { |
|
52 ELOG4(EJavaCaptain, "Error (code: %d) occured when starting " |
|
53 "CenRepListener (repo=%0x, key=%0x, keytype=%d)", |
|
54 error, KCRUidJavaRuntime.iUid, KJavaRuntimeMIDPClasspath, |
|
55 CCenRepNotifyHandler::EStringKey); |
|
56 } |
|
57 } |
|
58 |
|
59 void SettingsListenerImpl::stopListening() |
|
60 { |
|
61 cleanUp(); |
|
62 } |
|
63 |
|
64 CenRepListener* SettingsListenerImpl::createCenRepKeyListener(TUid aRepoId, TUint32 aKeyId, |
|
65 CCenRepNotifyHandler::TCenRepKeyType aKeyType, TInt& aErrorCode) |
|
66 { |
|
67 CenRepListener* listener = NULL; |
|
68 TRAP(aErrorCode, listener = CenRepListener::NewL(mCore, aRepoId, aKeyId, aKeyType)); |
|
69 return listener; // Possible error propagated as a function parameter |
|
70 } |
|
71 |
|
72 // Clean up owned resources |
|
73 void SettingsListenerImpl::cleanUp() |
|
74 { |
|
75 for (crListeners_t::iterator listenersIter = mCenRepListeners.begin(); |
|
76 listenersIter != mCenRepListeners.end(); ++listenersIter) |
|
77 { |
|
78 delete *listenersIter; |
|
79 *listenersIter = 0; |
|
80 } |
|
81 mCenRepListeners.clear(); |
|
82 } |
|
83 |
|
84 } // namespace captain |
|
85 } // namespace java |
|
86 |