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; |
26 import com.nokia.mj.impl.utils.ResourceLoader; |
28 |
27 |
29 /** |
28 /** |
30 * Runtime UI QT implementation. |
29 * Runtime UI QT implementation. |
31 * |
30 * |
32 */ |
31 */ |
33 public class RuntimeUiQt extends RuntimeUi |
32 public class RuntimeUiQt extends RuntimeUi |
34 { |
33 { |
35 private static final Id ALLOW_BUTTON = new Id(null, "prompt_allow"); |
34 private static final String ALLOW_BUTTON = "prompt_allow"; |
36 private static final Id DENY_BUTTON = new Id(null, "prompt_deny"); |
35 private static final String DENY_BUTTON = "prompt_deny"; |
37 private static final Id DETAILS_BUTTON = new Id(null, "error_details"); |
36 private static final String DETAILS_BUTTON = "error_details"; |
38 private static final Id OK_BUTTON = new Id(null, "prompt_ok"); |
37 private static final String OK_BUTTON = "prompt_ok"; |
39 private static final String QT_LOC_FILE = "javaapplicationsecuritymessages"; |
38 private static final String QT_LOC_FILE = "javaapplicationsecuritymessages"; |
40 private static final String QT_PREFIX = "txt_java_secur_button_"; |
39 private static final String QT_PREFIX = "txt_java_secur_button_"; |
41 |
40 |
42 private static ResourceLoader iRes = null; |
41 private static ResourceLoader iRes = null; |
43 |
42 |
65 * @return true if the user has answered, false if the user has |
64 * @return true if the user has answered, false if the user has |
66 * canceled the confirmation |
65 * canceled the confirmation |
67 */ |
66 */ |
68 public boolean confirm(String aAppName, ConfirmData aConfirmData) |
67 public boolean confirm(String aAppName, ConfirmData aConfirmData) |
69 { |
68 { |
70 |
|
71 if (aConfirmData == null) |
69 if (aConfirmData == null) |
72 { |
70 { |
73 Logger.LOG(Logger.EJavaRuntime, |
71 Logger.LOG(Logger.EJavaRuntime, |
74 Logger.EError, "RuntimeUi: ConfirmData null"); |
72 Logger.EError, "RuntimeUi: ConfirmData null"); |
75 return false; |
73 return false; |
78 // If no localized button text provided load default ones. |
76 // If no localized button text provided load default ones. |
79 if (aConfirmData.getAnswerOptions() == null) |
77 if (aConfirmData.getAnswerOptions() == null) |
80 { |
78 { |
81 if (iRes == null) |
79 if (iRes == null) |
82 { |
80 { |
83 iRes = ResourceLoader.getInstance(null, null, QT_LOC_FILE, QT_PREFIX); |
81 iRes = ResourceLoader.getInstance(QT_LOC_FILE, QT_PREFIX); |
84 } |
82 } |
85 |
83 |
86 String allowButton = iRes.format(ALLOW_BUTTON, null); |
84 String[] answerOptions = {iRes.format(ALLOW_BUTTON).toString(), |
87 String denyButton = iRes.format(DENY_BUTTON, null); |
85 iRes.format(DENY_BUTTON).toString()}; |
88 |
86 aConfirmData.setAnswerOptions(answerOptions); |
89 aConfirmData = new ConfirmData(aConfirmData.getQuestion(), |
|
90 new String[] {allowButton, denyButton}, |
|
91 aConfirmData.getAnswerSuggestion()); |
|
92 } |
87 } |
93 |
|
94 return _confirm(aAppName, aConfirmData, isIdentified()); |
88 return _confirm(aAppName, aConfirmData, isIdentified()); |
95 } |
89 } |
96 |
90 |
97 /** |
91 /** |
98 * Notifies the user that an error has occurred. |
92 * Notifies the user that an error has occurred. |
109 if (iRes == null) |
103 if (iRes == null) |
110 { |
104 { |
111 iRes = ResourceLoader.getInstance(null, null, QT_LOC_FILE, QT_PREFIX); |
105 iRes = ResourceLoader.getInstance(null, null, QT_LOC_FILE, QT_PREFIX); |
112 } |
106 } |
113 |
107 |
114 String detailsButton = iRes.format(DETAILS_BUTTON, null); |
|
115 String okButton = iRes.format(OK_BUTTON, null); |
|
116 |
|
117 _error(aAppName, |
108 _error(aAppName, |
118 aException.getShortMessage(), |
109 aException.getShortMessage(), |
119 aException.getDetailedMessage(), |
110 aException.getDetailedMessage(), |
120 detailsButton, |
111 iRes.format(DETAILS_BUTTON).toString(), |
121 okButton); |
112 iRes.format(OK_BUTTON).toString()); |
122 } |
113 } |
123 } |
114 } |
124 |
115 |
125 private native boolean _confirm(String aAppName, ConfirmData aConfirmData, boolean aIdentifiedApp); |
116 private native boolean _confirm(String aAppName, ConfirmData aConfirmData, boolean aIdentifiedApp); |
126 private native void _error(String aAppName, String aShortMessage, String aDetailedMessage, String aDetailsButton, String aOkButton); |
117 private native void _error(String aAppName, String aShortMessage, String aDetailedMessage, String aDetailsButton, String aOkButton); |