49
|
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 |
|
50
|
18 |
#include <e32base.h>
|
|
19 |
#include <centralrepository.h>
|
|
20 |
|
49
|
21 |
#include "coreinterface.h"
|
|
22 |
#include "eventconsumerinterface.h"
|
|
23 |
|
|
24 |
#include "logger.h"
|
|
25 |
#include "cenreplistener.h"
|
|
26 |
#include "settingschangeeventsprovidermessages.h"
|
|
27 |
|
|
28 |
namespace java
|
|
29 |
{
|
|
30 |
namespace captain
|
|
31 |
{
|
|
32 |
|
50
|
33 |
// General listener used as a base value indicating that whole repository is being
|
|
34 |
// listened instead of individual key.
|
|
35 |
CenRepListener::CenRepListener() : mKeyType(CenRepListener::GENERAL_LISTENER)
|
|
36 |
{
|
|
37 |
}
|
49
|
38 |
|
50
|
39 |
CenRepListener::~CenRepListener()
|
|
40 |
{
|
|
41 |
close();
|
|
42 |
}
|
49
|
43 |
|
50
|
44 |
void CenRepListener::close()
|
|
45 |
{
|
|
46 |
if (mNotifyHandler)
|
49
|
47 |
{
|
50
|
48 |
mNotifyHandler->StopListening();
|
|
49 |
delete mNotifyHandler;
|
|
50 |
mNotifyHandler = 0;
|
49
|
51 |
}
|
50
|
52 |
if (mCenRepSession)
|
49
|
53 |
{
|
50
|
54 |
delete mCenRepSession;
|
|
55 |
mCenRepSession = 0;
|
49
|
56 |
}
|
50
|
57 |
}
|
49
|
58 |
|
50
|
59 |
CenRepListener* CenRepListener::NewL(CoreInterface* aCore, TUid aRepoId, TUint32 aKeyId,
|
|
60 |
CCenRepNotifyHandler::TCenRepKeyType aKeyType)
|
|
61 |
{
|
|
62 |
CenRepListener* crListener = new(ELeave) CenRepListener();
|
|
63 |
CleanupStack::PushL(crListener);
|
|
64 |
crListener->ConstructL(aCore, aRepoId, aKeyId, aKeyType);
|
|
65 |
CleanupStack::Pop(crListener);
|
|
66 |
return (crListener);
|
|
67 |
}
|
49
|
68 |
|
50
|
69 |
void CenRepListener::ConstructL(CoreInterface* aCore, TUid aRepoId, TUint32 aKeyId,
|
|
70 |
CCenRepNotifyHandler::TCenRepKeyType aKeyType)
|
|
71 |
{
|
|
72 |
mCore = aCore;
|
|
73 |
mRepoId = aRepoId;
|
|
74 |
mKeyType = aKeyType;
|
|
75 |
mCenRepSession = CRepository::NewL(mRepoId);
|
|
76 |
mNotifyHandler = CCenRepNotifyHandler::NewL(*this, *mCenRepSession,
|
|
77 |
aKeyType, aKeyId);
|
|
78 |
mNotifyHandler->StartListeningL();
|
|
79 |
}
|
49
|
80 |
|
50
|
81 |
void CenRepListener::HandleNotifyString(TUint32 aKeyId, const TDesC16& /*aNewValue*/)
|
|
82 |
{
|
|
83 |
if (KCRUidJavaRuntime == mRepoId && KJavaRuntimeMIDPClasspath == aKeyId)
|
49
|
84 |
{
|
50
|
85 |
ILOG(EJavaCaptain, "CenRepListener::HandleNotifyString: change notified "
|
|
86 |
"in key KJavaRuntimeMIDPClasspath");
|
|
87 |
dispatchEvent(SETTINGS_CHANGE_EVENT_PROVIDER,
|
|
88 |
MIDP_CLASS_PATH_CHANGE);
|
49
|
89 |
}
|
50
|
90 |
else
|
49
|
91 |
{
|
50
|
92 |
WLOG1(EJavaCaptain, "Change in Unrecognised cenrep string key noticed! "
|
49
|
93 |
"CR Key= %0x", aKeyId);
|
|
94 |
}
|
50
|
95 |
}
|
49
|
96 |
|
50
|
97 |
void CenRepListener::HandleNotifyError(TUint32 aKeyId, TInt aError, CCenRepNotifyHandler* /* aHandler */)
|
|
98 |
{
|
|
99 |
ELOG2(EJavaCaptain, "Error (code: %d) occured when listening changes on "
|
|
100 |
"Cenrep key (Key ID: %0x). Listening stopped!", aError, aKeyId);
|
|
101 |
close();
|
|
102 |
}
|
49
|
103 |
|
50
|
104 |
void CenRepListener::dispatchEvent(const std::string& aEvent,
|
|
105 |
const SettingsChangeEventType_t& aType) const
|
|
106 |
{
|
|
107 |
ILOG2(EJavaCaptain, "CenRepListener::dispatchEvent: dispatching event=%s "
|
|
108 |
"type=%d", aEvent.c_str(), aType);
|
|
109 |
CommsMessage eventMsg;
|
|
110 |
setSettingsChangeEventMessageParams(eventMsg, aType);
|
|
111 |
mCore->getEventDispatcher()->event(aEvent, eventMsg);
|
|
112 |
}
|
49
|
113 |
|
|
114 |
} // namespace captain
|
|
115 |
} // namespace java
|
|
116 |
|