128 if (!(session_info & sessionHasGraphicAccess)) return false; 129 return true; 130 } 131 132 static bool isXDisplayDefined() { 133 return getenv("DISPLAY") != NULL; 134 } 135 136 PreferredToolkit getPreferredToolkit() { 137 static PreferredToolkit pref = unset; 138 if (pref != unset) return pref; 139 140 PreferredToolkit prefFromEnv = getPreferredToolkitFromEnv(); 141 if (prefFromEnv != unset) return pref = prefFromEnv; 142 143 if (isInAquaSession()) return pref = CToolkit; 144 if (isXDisplayDefined()) return pref = XToolkit; 145 return pref = HToolkit; 146 } 147 148 void setUnknownOSAndVersion(java_props_t *sprops) { 149 sprops->os_name = strdup("Unknown"); 150 sprops->os_version = strdup("Unknown"); 151 } 152 153 void setOSNameAndVersion(java_props_t *sprops) { 154 void *jrsFwk = getJRSFramework(); 155 if (jrsFwk == NULL) { 156 setUnknownOSAndVersion(sprops); 157 return; 158 } 159 160 char *(*copyOSName)() = dlsym(jrsFwk, "JRSCopyOSName"); 161 char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion"); 162 if (copyOSName == NULL || copyOSVersion == NULL) { 163 setUnknownOSAndVersion(sprops); 164 return; 165 } 166 167 sprops->os_name = copyOSName(); 168 sprops->os_version = copyOSVersion(); 169 } 170 171 172 static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) { 173 /* See if the proxy is enabled. */ 174 CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey); 175 if (cf_enabled == NULL) { 176 return false; 177 } 178 179 int isEnabled = false; 180 if (!CFNumberGetValue(cf_enabled, kCFNumberIntType, &isEnabled)) { 181 return isEnabled; 182 } 183 184 if (!isEnabled) return false; 185 *outProxyHost = CFDictionaryGetValue(inDict, inHostKey); 186 187 // If cf_host is null, that means the checkbox is set, 188 // but no host was entered. We'll treat that as NOT ENABLED. | 128 if (!(session_info & sessionHasGraphicAccess)) return false; 129 return true; 130 } 131 132 static bool isXDisplayDefined() { 133 return getenv("DISPLAY") != NULL; 134 } 135 136 PreferredToolkit getPreferredToolkit() { 137 static PreferredToolkit pref = unset; 138 if (pref != unset) return pref; 139 140 PreferredToolkit prefFromEnv = getPreferredToolkitFromEnv(); 141 if (prefFromEnv != unset) return pref = prefFromEnv; 142 143 if (isInAquaSession()) return pref = CToolkit; 144 if (isXDisplayDefined()) return pref = XToolkit; 145 return pref = HToolkit; 146 } 147 148 void setOSNameAndVersion(java_props_t *sprops) { 149 /* Don't rely on JRSCopyOSName because there's no guarantee the value will 150 * remain the same, or even if the JRS functions will continue to be part of 151 * Mac OS X. So hardcode os_name, and fill in os_version if we can. 152 */ 153 sprops->os_name = strdup("Mac OS X"); 154 155 void *jrsFwk = getJRSFramework(); 156 if (jrsFwk != NULL) { 157 char *(*copyOSVersion)() = dlsym(jrsFwk, "JRSCopyOSVersion"); 158 if (copyOSVersion != NULL) { 159 sprops->os_version = copyOSVersion(); 160 return; 161 } 162 } 163 sprops->os_version = strdup("Unknown"); 164 } 165 166 167 static Boolean getProxyInfoForProtocol(CFDictionaryRef inDict, CFStringRef inEnabledKey, CFStringRef inHostKey, CFStringRef inPortKey, CFStringRef *outProxyHost, int *ioProxyPort) { 168 /* See if the proxy is enabled. */ 169 CFNumberRef cf_enabled = CFDictionaryGetValue(inDict, inEnabledKey); 170 if (cf_enabled == NULL) { 171 return false; 172 } 173 174 int isEnabled = false; 175 if (!CFNumberGetValue(cf_enabled, kCFNumberIntType, &isEnabled)) { 176 return isEnabled; 177 } 178 179 if (!isEnabled) return false; 180 *outProxyHost = CFDictionaryGetValue(inDict, inHostKey); 181 182 // If cf_host is null, that means the checkbox is set, 183 // but no host was entered. We'll treat that as NOT ENABLED. |