78
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Implementation class of GlobalIndicators API.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
package com.nokia.mj.impl.nokiauiapi;
|
|
19 |
|
|
20 |
import com.nokia.mid.ui.GlobalIndicators;
|
|
21 |
import com.nokia.mid.ui.GlobalIndicatorsException;
|
|
22 |
import com.nokia.mj.impl.utils.OsErrorMessage;
|
|
23 |
import com.nokia.mj.impl.rt.support.ApplicationInfo;
|
|
24 |
|
|
25 |
|
|
26 |
public class GlobalIndicatorsImpl
|
|
27 |
{
|
|
28 |
|
|
29 |
// Static instance, can be got with getInstace method
|
|
30 |
private static GlobalIndicatorsImpl sGlobalIndicator;
|
|
31 |
// Static block of the class.
|
|
32 |
|
|
33 |
static
|
|
34 |
{
|
|
35 |
// com.nokia.mj.impl.rt.support.Jvm.loadSystemLibrary("javaglobalindicators");
|
|
36 |
|
|
37 |
// This is called when class is loaded for the first time
|
|
38 |
sGlobalIndicator = new GlobalIndicatorsImpl();
|
|
39 |
}
|
|
40 |
|
|
41 |
/**
|
|
42 |
* This private constructor can be called only from static block.
|
|
43 |
*/
|
|
44 |
private GlobalIndicatorsImpl()
|
|
45 |
{
|
|
46 |
}
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Return GlobalIndicatorsImpl instance
|
|
50 |
*/
|
|
51 |
public static GlobalIndicatorsImpl getInstance()
|
|
52 |
{
|
|
53 |
return sGlobalIndicator;
|
|
54 |
}
|
|
55 |
|
|
56 |
/**
|
|
57 |
* See class GlobalIndicators for comments
|
|
58 |
*/
|
|
59 |
public int setGlobalIndicator(int aIndicator, int aValue)
|
|
60 |
throws GlobalIndicatorsException
|
|
61 |
{
|
|
62 |
int ret;
|
|
63 |
String protectionDomain = ApplicationInfo.getInstance().getProtectionDomain();
|
|
64 |
if (protectionDomain == null)
|
|
65 |
{
|
|
66 |
throw new GlobalIndicatorsException(
|
|
67 |
"Failed to set global indicator for unidentified domain");
|
|
68 |
}
|
|
69 |
else
|
|
70 |
{
|
|
71 |
// For mail and chat indicators only show and hide are supported
|
|
72 |
if (((aIndicator == GlobalIndicators.MAIL_INDICATOR) ||
|
|
73 |
(aIndicator == GlobalIndicators.CHAT_INDICATOR)) &&
|
|
74 |
((aValue != GlobalIndicators.INDICATOR_SHOW) &&
|
|
75 |
(aValue != GlobalIndicators.INDICATOR_HIDE)))
|
|
76 |
{
|
|
77 |
throw new GlobalIndicatorsException(
|
|
78 |
"Value is not supported for global indicator");
|
|
79 |
}
|
|
80 |
|
|
81 |
//int ret = _setGlobalIndicator( aIndicator, aValue );
|
|
82 |
ret = 0;//_setGlobalIndicator(aIndicator, aValue);
|
|
83 |
if (ret < OsErrorMessage.SUCCESS)
|
|
84 |
{
|
|
85 |
throw new GlobalIndicatorsException(
|
|
86 |
"Failed to set global indicator", ret);
|
|
87 |
}
|
|
88 |
}
|
|
89 |
return ret;
|
|
90 |
}
|
|
91 |
|
|
92 |
/**
|
|
93 |
* See class GlobalIndicators for comments
|
|
94 |
*/
|
|
95 |
public int getGlobalIndicator(int aIndicator)
|
|
96 |
throws GlobalIndicatorsException
|
|
97 |
{
|
|
98 |
int ret = 0;//_getGlobalIndicator(aIndicator);
|
|
99 |
if (ret < OsErrorMessage.SUCCESS)
|
|
100 |
{
|
|
101 |
throw new GlobalIndicatorsException(
|
|
102 |
"Failed to get global indicator value", ret);
|
|
103 |
}
|
|
104 |
return ret;
|
|
105 |
}
|
|
106 |
|
|
107 |
}
|