void updateEncryption() { Boolean validKey; CFStringRef password; unsigned char md5[16]; char hash[32]; doEncrypt = (CFPreferencesGetAppBooleanValue(ENCRYPT_PREF_KEY,PREF_DOMAIN,&validKey))?kCFBooleanTrue:kCFBooleanFalse; if (!validKey) { doEncrypt = kCFBooleanTrue; CFPreferencesSetAppValue(ENCRYPT_PREF_KEY,doEncrypt,PREF_DOMAIN); } if (!(password = (CFStringRef)CFPreferencesCopyAppValue(PASSWORD_PREF_KEY,PREF_DOMAIN))) { password = CFSTR(DEFAULT_PASSWORD); MD5((const unsigned char*)CFStringGetCStringPtr(password,CFStringGetFastestEncoding(password)),CFStringGetLength(password),md5); for (int i=0; i<sizeof(md5); i++) sprintf(hash+2*i,"%02x",md5[i]); password = CFStringCreateWithCString(kCFAllocatorDefault,hash,kCFStringEncodingASCII); CFPreferencesSetAppValue(PASSWORD_PREF_KEY,password,PREF_DOMAIN); } makeEncryptKey(password); }
// FIXME: It is confusing that this function both sets connection count and determines maximum request count at network layer. This can and should be done separately. unsigned initializeMaximumHTTPConnectionCountPerHost() { static const unsigned preferredConnectionCount = 6; static const unsigned unlimitedRequestCount = 10000; _CFNetworkHTTPConnectionCacheSetLimit(kHTTPLoadWidth, preferredConnectionCount); unsigned maximumHTTPConnectionCountPerHost = _CFNetworkHTTPConnectionCacheGetLimit(kHTTPLoadWidth); Boolean keyExistsAndHasValidFormat = false; Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitEnableHTTPPipelining"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) ResourceRequest::setHTTPPipeliningEnabled(prefValue); // Use WebCore scheduler when we can't use request priorities with CFNetwork. if (!ResourceRequest::resourcePrioritiesEnabled()) return maximumHTTPConnectionCountPerHost; _CFNetworkHTTPConnectionCacheSetLimit(kHTTPPriorityNumLevels, toPlatformRequestPriority(ResourceLoadPriority::Highest)); #if !PLATFORM(WIN) // FIXME: <rdar://problem/9375609> Implement minimum fast lane priority setting on Windows _CFNetworkHTTPConnectionCacheSetLimit(kHTTPMinimumFastLanePriority, toPlatformRequestPriority(ResourceLoadPriority::Medium)); #endif return unlimitedRequestCount; }
void updateKeymap() { CFReadStreamRef readStream; if (!fileExists(CFSTR(KEYMAP_PATH))) { stamp_file(CFSTR("Error: Keymap file is missing")); keymap = NULL; return; } readStream = CFReadStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,CFSTR(KEYMAP_PATH),kCFURLPOSIXPathStyle,false)); if (!readStream||!(CFReadStreamOpen(readStream))) { stamp_file(CFSTR("Error: Can't open keymap file")); keymap = NULL; return; } keymap = (CFDictionaryRef)CFPropertyListCreateFromStream(kCFAllocatorDefault,readStream,0,kCFPropertyListImmutable,NULL,NULL); CFReadStreamClose(readStream); if (!keymap) { stamp_file(CFSTR("Error: Can't read keymap file")); return; } Boolean validKey; showMods = (CFPreferencesGetAppBooleanValue(CFSTR("Mods"),PREF_DOMAIN,&validKey))?kCFBooleanTrue:kCFBooleanFalse; if (!validKey) { showMods = kCFBooleanTrue; CFPreferencesSetAppValue(CFSTR("Mods"),showMods,PREF_DOMAIN); } }
unsigned initializeMaximumHTTPConnectionCountPerHost() { static const unsigned preferredConnectionCount = 6; // Always set the connection count per host, even when pipelining. unsigned maximumHTTPConnectionCountPerHost = wkInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount); static const unsigned unlimitedConnectionCount = 10000; Boolean keyExistsAndHasValidFormat = false; Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitEnableHTTPPipelining"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) ResourceRequest::setHTTPPipeliningEnabled(prefValue); if (ResourceRequest::httpPipeliningEnabled()) { wkSetHTTPPipeliningMaximumPriority(toHTTPPipeliningPriority(ResourceLoadPriorityHighest)); #if !PLATFORM(WIN) // FIXME: <rdar://problem/9375609> Implement minimum fast lane priority setting on Windows wkSetHTTPPipeliningMinimumFastLanePriority(toHTTPPipeliningPriority(ResourceLoadPriorityMedium)); #endif // When pipelining do not rate-limit requests sent from WebCore since CFNetwork handles that. return unlimitedConnectionCount; } return maximumHTTPConnectionCountPerHost; }
int subsurface_get_conf_bool(char *name) { Boolean boolpref, exists; boolpref = CFPreferencesGetAppBooleanValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES, &exists); if (!exists) return -1; return boolpref; }
static int read_boolean_pref (CFStringRef name, int default_) { int value; Boolean ok; value = CFPreferencesGetAppBooleanValue (name, CFSTR ("com.apple.x11"), &ok); return ok ? value : default_; }
void JSConsoleClient::initializeLogToSystemConsole() { #if !LOG_DISABLED sLogToSystemConsole = true; #elif USE(CF) Boolean keyExistsAndHasValidFormat = false; Boolean preference = CFPreferencesGetAppBooleanValue(CFSTR("JavaScriptCoreOutputConsoleMessagesToSystemConsole"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) sLogToSystemConsole = preference; #endif }
bool Moose::iPodScrobblingEnabled() { Boolean key_exists; bool b = CFPreferencesGetAppBooleanValue( CFSTR( "iPodScrobblingEnabled"), CFSTR( MOOSE_PREFS_PLIST ), &key_exists ); if (!key_exists) return true; return b; }
static int /* O - 1 if set, 0 otherwise */ cups_apple_get_boolean( CFStringRef key, /* I - Key (name) */ int *value) /* O - Boolean value */ { Boolean bval, /* Preference value */ bval_set; /* Value is set? */ bval = CFPreferencesGetAppBooleanValue(key, kCUPSPrintingPrefs, &bval_set); if (bval_set) *value = (int)bval; return ((int)bval_set); }
void JSGlobalObjectConsoleClient::initializeLogToSystemConsole() { // If setLogToSystemConsole() was called, no need to query the default value. if (sSetLogToSystemConsole) return; #if !LOG_DISABLED sLogToSystemConsole = true; #elif USE(CF) Boolean keyExistsAndHasValidFormat = false; Boolean preference = CFPreferencesGetAppBooleanValue(CFSTR("JavaScriptCoreOutputConsoleMessagesToSystemConsole"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) sLogToSystemConsole = preference; #endif sSetLogToSystemConsole = true; }
nsresult CProfileManager::GetShowDialogOnStart(PRBool* showIt) { *showIt = PR_TRUE; CFStringRef showDialogKey = CFSTR(kPrefShowProfilesAtStartup); Boolean keyExistsAndIsValid, value; value = CFPreferencesGetAppBooleanValue(showDialogKey, kCFPreferencesCurrentApplication, &keyExistsAndIsValid); if (!keyExistsAndIsValid) return NS_ERROR_FAILURE; *showIt = value; return NS_OK; }
unsigned initializeMaximumHTTPConnectionCountPerHost() { static const unsigned preferredConnectionCount = 6; static const unsigned unlimitedConnectionCount = 10000; wkInitializeMaximumHTTPConnectionCountPerHost(preferredConnectionCount); Boolean keyExistsAndHasValidFormat = false; Boolean prefValue = CFPreferencesGetAppBooleanValue(CFSTR("WebKitEnableHTTPPipelining"), kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); if (keyExistsAndHasValidFormat) ResourceRequest::setHTTPPipeliningEnabled(prefValue); wkSetHTTPRequestMaximumPriority(toPlatformRequestPriority(ResourceLoadPriorityHighest)); #if !PLATFORM(WIN) // FIXME: <rdar://problem/9375609> Implement minimum fast lane priority setting on Windows wkSetHTTPRequestMinimumFastLanePriority(toPlatformRequestPriority(ResourceLoadPriorityMedium)); #endif return unlimitedConnectionCount; }
const void *subsurface_get_conf(char *name, pref_type_t type) { Boolean boolpref; CFPropertyListRef strpref; switch (type) { case PREF_BOOL: boolpref = CFPreferencesGetAppBooleanValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES, FALSE); if (boolpref) return (void *) 1; else return NULL; case PREF_STRING: strpref = CFPreferencesCopyAppValue(CFSTR_VAR(name), SUBSURFACE_PREFERENCES); if (!strpref) return NULL; return strdup(CFStringGetCStringPtr(strpref, kCFStringEncodingMacRoman)); } /* we shouldn't get here, but having this line makes the compiler happy */ return NULL; }
static inline bool readBooleanPreference(CFStringRef key) { Boolean keyExistsAndHasValidFormat; Boolean result = CFPreferencesGetAppBooleanValue(key, kCFPreferencesCurrentApplication, &keyExistsAndHasValidFormat); return keyExistsAndHasValidFormat ? result : false; }
void DaemonTimerCallback( CFRunLoopTimerRef timer, void *info ) { /*********Wait if not logging**********/ Boolean validKey; CFPreferencesAppSynchronize(PREF_DOMAIN); CFBooleanRef isLogging = (CFPreferencesGetAppBooleanValue(CFSTR("Logging"),PREF_DOMAIN,&validKey))?kCFBooleanTrue:kCFBooleanFalse; if (!validKey) { isLogging = kCFBooleanTrue; CFPreferencesSetAppValue(CFSTR("Logging"),isLogging,PREF_DOMAIN); } if (!CFBooleanGetValue(isLogging)) return; /********* Check the buffer **********/ int buffsize=0; int keys=0; getBufferSizeAndKeys(&buffsize,&keys); #ifdef DEBUG syslog(LOG_ERR,"Buffsize %d, Keys %d.",buffsize,keys); #endif if (!keys) // no keyboards logged return; if (buffsize < MAX_BUFF_SIZE/10) return; /********* Get the buffer **********/ CFStringRef the_buffer = getBuffer(); /********* Check defaults/file **********/ CFStringRef curPathName = (CFStringRef)CFPreferencesCopyAppValue(PATHNAME_PREF_KEY,PREF_DOMAIN); if (!curPathName) // path has been deleted { pathName = CFSTR(DEFAULT_PATHNAME); CFPreferencesSetAppValue(PATHNAME_PREF_KEY,pathName,PREF_DOMAIN); logStream = CFWriteStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,pathName,kCFURLPOSIXPathStyle,false)); if (!logStream) { syslog(LOG_ERR,"Error: Couldn't open file stream while running."); return; } } else if (CFStringCompare(curPathName,pathName,0)!=kCFCompareEqualTo) // path has changed { pathName = curPathName; logStream = CFWriteStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,pathName,kCFURLPOSIXPathStyle,false)); if (!logStream) { syslog(LOG_ERR,"Error: Couldn't open file stream while running."); return; } CFDataDeleteBytes(encrypt_buffer,CFRangeMake(0,CFDataGetLength(encrypt_buffer))); } if (!fileExists(pathName)) // when file is deleted, we resync the encryption & keymap preferences { CFPreferencesAppSynchronize(PREF_DOMAIN); updateEncryption(); updateKeymap(); logStream = CFWriteStreamCreateWithFile(kCFAllocatorDefault,CFURLCreateWithFileSystemPath(kCFAllocatorDefault,pathName,kCFURLPOSIXPathStyle,false)); if (!logStream) { syslog(LOG_ERR,"Error: Couldn't open file stream while running."); return; } stamp_file(CFSTR("LogKext Daemon created new logfile")); } if (outOfSpace(pathName)) { stamp_file(CFSTR("Not enough disk space remaining!")); return; } /********* Finally, write the buffer **********/ write_buffer(the_buffer); CFRelease(the_buffer); return; }
void PreferencesDialog::initDataBase() { m_dataBase = new TrackerSettingsDatabase(); m_dataBase->store(KEY_USEMIDI, 0); m_dataBase->store(KEY_SAVEPREFS, 0); m_dataBase->store(KEY_MIDIDEVICE, ""); m_dataBase->store(KEY_RECORDVELOCITY, 0); m_dataBase->store(KEY_VELOCITYAMPLIFY, 100); m_dataBase->store(KEY_INSERTEMULATION, 0); m_dataBase->store(KEY_SIXTEENBITCOLOR, 0); // try to retrieve the values from the PLIST Boolean success = FALSE; CFStringRef key = CFSTR(KEY_USEMIDI); Boolean b = CFPreferencesGetAppBooleanValue(key, applicationID, &success); if (success) m_dataBase->store(KEY_USEMIDI, b); // Return boolean success = FALSE; key = CFSTR(KEY_SAVEPREFS); b = CFPreferencesGetAppBooleanValue(key, applicationID, &success); if (success) m_dataBase->store(KEY_SAVEPREFS, b); // Return string, little bit more complicated key = CFSTR(KEY_MIDIDEVICE); CFPropertyListRef plistRef = CFPreferencesCopyAppValue(key, applicationID); if (plistRef) { if (CFGetTypeID(plistRef) == CFStringGetTypeID()) { CFStringRef stringRef = static_cast<CFStringRef>(plistRef); char buffer[512]; CFStringGetCString(stringRef, buffer, 512, kCFStringEncodingASCII); m_dataBase->store(KEY_MIDIDEVICE, buffer); } } // More boolean values following success = FALSE; key = CFSTR(KEY_RECORDVELOCITY); b = CFPreferencesGetAppBooleanValue(key, applicationID, &success); if (success) m_dataBase->store(KEY_RECORDVELOCITY, b); // Integer value success = FALSE; key = CFSTR(KEY_VELOCITYAMPLIFY); int i = CFPreferencesGetAppIntegerValue(key, applicationID, &success); if (success) m_dataBase->store(KEY_VELOCITYAMPLIFY, i); // Integer value success = FALSE; key = CFSTR(KEY_INSERTEMULATION); i = CFPreferencesGetAppIntegerValue(key, applicationID, &success); if (success) m_dataBase->store(KEY_INSERTEMULATION, i); // More boolean values following success = FALSE; key = CFSTR(KEY_SIXTEENBITCOLOR); b = CFPreferencesGetAppBooleanValue(key, applicationID, &success); if (success) m_dataBase->store(KEY_SIXTEENBITCOLOR, b); }