56
|
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: The JNI code for Java Installer class FileWriter.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#include "com_nokia_mj_impl_installer_utils_PropertyProvider.h"
|
|
19 |
#include "logger.h"
|
|
20 |
#include "propertylistener.h"
|
|
21 |
|
|
22 |
// NAMESPACE DECLARATION
|
|
23 |
using namespace java::installer;
|
|
24 |
using namespace java::util;
|
|
25 |
|
|
26 |
/*
|
|
27 |
* Class: com_nokia_mj_impl_installer_utils_PropertyProvider
|
|
28 |
* Method: _subscribe
|
|
29 |
* Signature: (II)I
|
|
30 |
*/
|
|
31 |
JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_utils_PropertyProvider__1subscribe
|
|
32 |
(JNIEnv */*aEnv*/, jclass, jint aCategory, jint aKey)
|
|
33 |
{
|
|
34 |
TUid uid = TUid::Uid(aCategory);
|
|
35 |
TUint key = (TUint)aKey;
|
|
36 |
// Construct PropertyListener.
|
|
37 |
CPropertyListener* propertyListener = 0;
|
|
38 |
TRAPD(err, propertyListener = CPropertyListener::NewL(uid, key));
|
|
39 |
if (KErrNone != err)
|
|
40 |
{
|
|
41 |
ELOG3(EJavaInstaller,
|
|
42 |
"PropertyProvider__1subscribe: creating property listener "
|
|
43 |
"failed, uid: 0x%x, key: 0x%x, err=%d", uid.iUid, key, err);
|
|
44 |
return err;
|
|
45 |
}
|
|
46 |
|
|
47 |
// Return handle to session. Utilize the fact that in Symbian
|
|
48 |
// all pointer addresses are MOD 4 so the last 2 bits are 0
|
|
49 |
// and can be shifted out. This way the returned handle is
|
|
50 |
// always positive whereas Symbian error codes are always negative.
|
|
51 |
return reinterpret_cast<TUint>(propertyListener)>>2;
|
|
52 |
}
|
|
53 |
|
|
54 |
/*
|
|
55 |
* Class: com_nokia_mj_impl_installer_utils_PropertyProvider
|
|
56 |
* Method: _processEvents
|
|
57 |
* Signature: (ILcom/nokia/mj/impl/installer/utils/PropertyProvider;)I
|
|
58 |
*/
|
|
59 |
JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_utils_PropertyProvider__1processEvents
|
|
60 |
(JNIEnv *aEnv, jclass, jint aHandle, jobject aProvider)
|
|
61 |
{
|
|
62 |
CPropertyListener* propertyListener =
|
|
63 |
reinterpret_cast<CPropertyListener*>(aHandle<<2);
|
|
64 |
// Start propertyListener for event sending.
|
|
65 |
TRAPD(err, propertyListener->ProcessEventsL(aEnv, aProvider));
|
|
66 |
if (KErrNone != err)
|
|
67 |
{
|
|
68 |
ELOG1(EJavaInstaller,
|
|
69 |
"PropertyProvider__1processEvents: initializing "
|
|
70 |
"propertyListener failed, err=%d", err);
|
|
71 |
}
|
|
72 |
return err;
|
|
73 |
}
|
|
74 |
|
|
75 |
/*
|
|
76 |
* Class: com_nokia_mj_impl_installer_utils_PropertyProvider
|
|
77 |
* Method: _unsubscribe
|
|
78 |
* Signature: (I)I
|
|
79 |
*/
|
|
80 |
JNIEXPORT jint JNICALL Java_com_nokia_mj_impl_installer_utils_PropertyProvider__1unsubscribe
|
|
81 |
(JNIEnv *, jclass, jint aHandle)
|
|
82 |
{
|
|
83 |
CPropertyListener* propertyListener =
|
|
84 |
reinterpret_cast<CPropertyListener*>(aHandle<<2);
|
|
85 |
|
|
86 |
// Delete PropertyListener.
|
|
87 |
delete propertyListener;
|
|
88 |
propertyListener = 0;
|
|
89 |
|
|
90 |
return KErrNone;
|
|
91 |
}
|