21 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
21 import com.nokia.mj.impl.rt.ui.RuntimeUi; |
22 import com.nokia.mj.impl.utils.Logger; |
22 import com.nokia.mj.impl.utils.Logger; |
23 import com.nokia.mj.impl.utils.exception.ExceptionBase; |
23 import com.nokia.mj.impl.utils.exception.ExceptionBase; |
24 import com.nokia.mj.impl.rt.support.Jvm; |
24 import com.nokia.mj.impl.rt.support.Jvm; |
25 |
25 |
|
26 import com.nokia.mj.impl.utils.Id; |
|
27 import com.nokia.mj.impl.utils.ResourceLoader; |
|
28 |
26 /** |
29 /** |
27 * Runtime UI QT implementation. |
30 * Runtime UI QT implementation. |
28 * |
31 * |
29 */ |
32 */ |
30 public class RuntimeUiQt extends RuntimeUi |
33 public class RuntimeUiQt extends RuntimeUi |
31 { |
34 { |
|
35 private static final Id ALLOW_BUTTON = new Id(null, "prompt_allow"); |
|
36 private static final Id DENY_BUTTON = new Id(null, "prompt_deny"); |
|
37 private static final Id DETAILS_BUTTON = new Id(null, "error_details"); |
|
38 private static final Id OK_BUTTON = new Id(null, "prompt_ok"); |
|
39 private static final String QT_LOC_FILE = "javaapplicationsecuritymessages"; |
|
40 private static final String QT_PREFIX = "txt_java_secur_button_"; |
|
41 |
|
42 private static ResourceLoader iRes = null; |
32 |
43 |
33 static |
44 static |
34 { |
45 { |
35 Jvm.loadSystemLibrary("javaruntimeui"); |
46 Jvm.loadSystemLibrary("javaruntimeui"); |
36 } |
47 } |
54 * @return true if the user has answered, false if the user has |
65 * @return true if the user has answered, false if the user has |
55 * canceled the confirmation |
66 * canceled the confirmation |
56 */ |
67 */ |
57 public boolean confirm(String aAppName, ConfirmData aConfirmData) |
68 public boolean confirm(String aAppName, ConfirmData aConfirmData) |
58 { |
69 { |
59 if (aConfirmData != null) |
70 |
60 { |
71 if (aConfirmData == null) |
61 return _confirm(aAppName, aConfirmData, isIdentified()); |
|
62 } |
|
63 else |
|
64 { |
72 { |
65 Logger.LOG(Logger.EJavaRuntime, |
73 Logger.LOG(Logger.EJavaRuntime, |
66 Logger.EError, "RuntimeUi: ConfirmData null"); |
74 Logger.EError, "RuntimeUi: ConfirmData null"); |
|
75 return false; |
67 } |
76 } |
68 return true; |
77 |
|
78 // If no localized button text provided load default ones. |
|
79 if (aConfirmData.getAnswerOptions() == null) |
|
80 { |
|
81 if (iRes == null) |
|
82 { |
|
83 iRes = ResourceLoader.getInstance(null, null, QT_LOC_FILE, QT_PREFIX); |
|
84 } |
|
85 |
|
86 String allowButton = iRes.format(ALLOW_BUTTON, null); |
|
87 String denyButton = iRes.format(DENY_BUTTON, null); |
|
88 |
|
89 aConfirmData = new ConfirmData(aConfirmData.getQuestion(), |
|
90 new String[] {allowButton, denyButton}, |
|
91 aConfirmData.getAnswerSuggestion()); |
|
92 } |
|
93 |
|
94 return _confirm(aAppName, aConfirmData, isIdentified()); |
69 } |
95 } |
70 |
96 |
71 /** |
97 /** |
72 * Notifies the user that an error has occurred. |
98 * Notifies the user that an error has occurred. |
73 * This method must return quickly. |
99 * This method must return quickly. |
78 */ |
104 */ |
79 public void error(String aAppName, ExceptionBase aException) |
105 public void error(String aAppName, ExceptionBase aException) |
80 { |
106 { |
81 if (aException != null) |
107 if (aException != null) |
82 { |
108 { |
83 _error(aAppName, aException.getShortMessage(), aException.getDetailedMessage()); |
109 if (iRes == null) |
84 } |
110 { |
85 else |
111 iRes = ResourceLoader.getInstance(null, null, QT_LOC_FILE, QT_PREFIX); |
86 { |
112 } |
87 Logger.LOG(Logger.EJavaRuntime, |
113 |
88 Logger.EError, "RuntimeUi: Error null"); |
114 String detailsButton = iRes.format(DETAILS_BUTTON, null); |
|
115 String okButton = iRes.format(OK_BUTTON, null); |
|
116 |
|
117 _error(aAppName, |
|
118 aException.getShortMessage(), |
|
119 aException.getDetailedMessage(), |
|
120 detailsButton, |
|
121 okButton); |
89 } |
122 } |
90 } |
123 } |
91 |
124 |
92 private native boolean _confirm(String aAppName, ConfirmData aConfirmData, boolean aIdentifiedApp); |
125 private native boolean _confirm(String aAppName, ConfirmData aConfirmData, boolean aIdentifiedApp); |
93 private native void _error(String aAppName, String aShortMessage, String aDetailedMessage); |
126 private native void _error(String aAppName, String aShortMessage, String aDetailedMessage, String aDetailsButton, String aOkButton); |
94 } |
127 } |