88 }
89
90 char *setupMacOSXLocale(int cat) {
91 char * ret = getMacOSXLocale(cat);
92
93 if (cat == LC_MESSAGES && ret != NULL) {
94 void *jrsFwk = getJRSFramework();
95 if (jrsFwk != NULL) {
96 void (*JRSSetDefaultLocalization)(char *) = dlsym(jrsFwk, "JRSSetDefaultLocalization");
97 if (JRSSetDefaultLocalization) JRSSetDefaultLocalization(ret);
98 }
99 }
100
101 if (ret == NULL) {
102 return getPosixLocale(cat);
103 } else {
104 return ret;
105 }
106 }
107
108 /* There are several toolkit options on Mac OS X, so we should try to
109 * pick the "best" one, given what we know about the environment Java
110 * is running under
111 */
112
113 static PreferredToolkit getPreferredToolkitFromEnv() {
114 char *envVar = getenv("AWT_TOOLKIT");
115 if (envVar == NULL) return unset;
116
117 if (strcasecmp(envVar, "CToolkit") == 0) return CToolkit;
118 if (strcasecmp(envVar, "XToolkit") == 0) return XToolkit;
119 if (strcasecmp(envVar, "HToolkit") == 0) return HToolkit;
120 return unset;
121 }
122
123 static bool isInAquaSession() {
124 // Is the WindowServer available?
125 SecuritySessionId session_id;
126 SessionAttributeBits session_info;
127 OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
128 if (status != noErr) return false;
129 if (!(session_info & sessionHasGraphicAccess)) return false;
130 return true;
131 }
132
133 PreferredToolkit getPreferredToolkit() {
134 static PreferredToolkit pref = unset;
135 if (pref != unset) return pref;
136
137 PreferredToolkit prefFromEnv = getPreferredToolkitFromEnv();
138 if (prefFromEnv != unset) return pref = prefFromEnv;
139
140 if (isInAquaSession()) return pref = CToolkit;
141 return pref = HToolkit;
142 }
143
144 void setOSNameAndVersion(java_props_t *sprops) {
145 /* Don't rely on JRSCopyOSName because there's no guarantee the value will
146 * remain the same, or even if the JRS functions will continue to be part of
147 * Mac OS X. So hardcode os_name, and fill in os_version if we can.
148 */
149 sprops->os_name = strdup("Mac OS X");
150
151 void *jrsFwk = getJRSFramework();
152 if (jrsFwk != NULL) {
153 char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
154 if (copyOSVersion != NULL) {
155 sprops->os_version = copyOSVersion();
156 return;
157 }
158 }
159 sprops->os_version = strdup("Unknown");
160 }
161
|
88 }
89
90 char *setupMacOSXLocale(int cat) {
91 char * ret = getMacOSXLocale(cat);
92
93 if (cat == LC_MESSAGES && ret != NULL) {
94 void *jrsFwk = getJRSFramework();
95 if (jrsFwk != NULL) {
96 void (*JRSSetDefaultLocalization)(char *) = dlsym(jrsFwk, "JRSSetDefaultLocalization");
97 if (JRSSetDefaultLocalization) JRSSetDefaultLocalization(ret);
98 }
99 }
100
101 if (ret == NULL) {
102 return getPosixLocale(cat);
103 } else {
104 return ret;
105 }
106 }
107
108 int isInAquaSession() {
109 // Is the WindowServer available?
110 SecuritySessionId session_id;
111 SessionAttributeBits session_info;
112 OSStatus status = SessionGetInfo(callerSecuritySession, &session_id, &session_info);
113 if (status == noErr) {
114 if (session_info & sessionHasGraphicAccess) {
115 return 1;
116 }
117 }
118 return 0;
119 }
120
121 void setOSNameAndVersion(java_props_t *sprops) {
122 /* Don't rely on JRSCopyOSName because there's no guarantee the value will
123 * remain the same, or even if the JRS functions will continue to be part of
124 * Mac OS X. So hardcode os_name, and fill in os_version if we can.
125 */
126 sprops->os_name = strdup("Mac OS X");
127
128 void *jrsFwk = getJRSFramework();
129 if (jrsFwk != NULL) {
130 char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion");
131 if (copyOSVersion != NULL) {
132 sprops->os_version = copyOSVersion();
133 return;
134 }
135 }
136 sprops->os_version = strdup("Unknown");
137 }
138
|