72
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Java side Core UI accessor.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.mj.impl.coreuiqt;
|
|
18 |
|
|
19 |
import com.nokia.mj.impl.utils.Uid;
|
|
20 |
import com.nokia.mj.impl.rt.support.Jvm;
|
|
21 |
import com.nokia.mj.impl.rt.support.ApplicationUtils;
|
|
22 |
import com.nokia.mj.impl.rt.support.ApplicationInfo;
|
|
23 |
import com.nokia.mj.impl.coreui.CoreUi;
|
|
24 |
|
80
|
25 |
import org.eclipse.swt.internal.extension.Toolkit;
|
|
26 |
|
72
|
27 |
|
|
28 |
/**
|
|
29 |
* A gate to CoreUi Qt implementation.
|
|
30 |
*/
|
|
31 |
public class CoreUiImpl extends CoreUi
|
|
32 |
{
|
|
33 |
|
|
34 |
public CoreUiImpl()
|
|
35 |
{
|
|
36 |
// Load the native.
|
|
37 |
Jvm.loadSystemLibrary("javacoreui");
|
|
38 |
}
|
|
39 |
|
|
40 |
/**
|
|
41 |
* Connects to the already created CoreUi.
|
|
42 |
* @return permission to start the application. There is a small time
|
|
43 |
* window where user is able to cancel the application
|
|
44 |
* start. In this case the CoreUi stores the request and
|
|
45 |
* informs the caller of this method that the application
|
|
46 |
* should not be started.
|
|
47 |
*/
|
|
48 |
protected boolean connectToUiImpl()
|
|
49 |
{
|
|
50 |
return true;
|
|
51 |
}
|
|
52 |
|
|
53 |
/**
|
|
54 |
* For creating the UI from Java side. This is meant for the pre-warmed
|
|
55 |
* VM use case. Calling this method will lead creation of the CoreUI.
|
|
56 |
* @param uid The UID of the application.
|
|
57 |
* @param backGroundStart Should the UI be put into background.
|
|
58 |
*/
|
|
59 |
protected void createUiImpl(Uid uid, boolean backGroundStart)
|
|
60 |
{
|
|
61 |
// CoreUiStartScreen.showStartScreen(backGroundStart);
|
|
62 |
}
|
|
63 |
|
|
64 |
/**
|
|
65 |
* For asking the runtime to do the shutdown of the application.
|
|
66 |
*/
|
|
67 |
protected void shutdownRequestImpl()
|
|
68 |
{
|
|
69 |
ApplicationUtils.getInstance().notifyExitCmd();
|
|
70 |
}
|
|
71 |
|
|
72 |
/**
|
|
73 |
* For asking the runtime to bring the application to foreground.
|
|
74 |
*/
|
|
75 |
protected void foregroundRequestImpl()
|
|
76 |
{
|
|
77 |
}
|
|
78 |
|
|
79 |
/**
|
|
80 |
* For asking if the UI is in foreground.
|
|
81 |
*/
|
|
82 |
protected boolean isUiInForegroundImpl()
|
|
83 |
{
|
|
84 |
return true;
|
|
85 |
}
|
|
86 |
|
|
87 |
/**
|
|
88 |
* For asking if the UI to remove the icon from the task manager.
|
|
89 |
*/
|
|
90 |
protected void hideApplicationImpl(boolean hide)
|
|
91 |
{
|
|
92 |
// Native logic is reversed between Symbian^3 and Symbian^4.
|
|
93 |
// platform specific part.
|
|
94 |
_hideApplication(!hide);
|
|
95 |
}
|
|
96 |
|
80
|
97 |
/**
|
|
98 |
* Executes given Runnable synchronously in UI thread.
|
|
99 |
* <br>
|
|
100 |
* This method should only be used in cases where it
|
|
101 |
* is absolutely needed. Before using this method,
|
|
102 |
* consider carefully if the use case really requires
|
|
103 |
* code to be executed in UI thread.
|
|
104 |
* <br>
|
|
105 |
* This method is only supported in Qt based runtimes.
|
|
106 |
* <br>
|
|
107 |
* @param runnable Runnable to be executed
|
|
108 |
* @throws RuntimeException if execution in UI thread
|
|
109 |
* is not supported
|
|
110 |
*/
|
|
111 |
protected void runInSyncUiThreadImpl(Runnable runnable)
|
|
112 |
{
|
|
113 |
Toolkit.getInternalDisplay().syncExec(runnable);
|
|
114 |
}
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Executes given Runnable asynchronously in UI thread.
|
|
118 |
* <br>
|
|
119 |
* This method should only be used in cases where it
|
|
120 |
* is absolutely needed. Before using this method,
|
|
121 |
* consider carefully if the use case really requires
|
|
122 |
* code to be executed in UI thread.
|
|
123 |
* <br>
|
|
124 |
* This method is only supported in Qt based runtimes.
|
|
125 |
* <br>
|
|
126 |
* @param runnable Runnable to be executed
|
|
127 |
* @throws RuntimeException if execution in UI thread
|
|
128 |
* is not supported
|
|
129 |
*/
|
|
130 |
protected void runInAsyncUiThreadImpl(Runnable runnable)
|
|
131 |
{
|
|
132 |
Toolkit.getInternalDisplay().asyncExec(runnable);
|
|
133 |
}
|
|
134 |
|
72
|
135 |
private native void _hideApplication(boolean hide);
|
|
136 |
}
|