void QMacSettingsPrivate::clear() { QCFType<CFArrayRef> cfarray = CFPreferencesCopyKeyList(domains[0].applicationOrSuiteId, domains[0].userName, hostName); CFPreferencesSetMultiple(0, cfarray, domains[0].applicationOrSuiteId, domains[0].userName, hostName); }
// The primary problem we need to resolve for OSX portability is that Apple // only permit you to define static MIME types in the property list for // plugins bundles, because we need to generate these dynamically. // // Luckily, Apple also want to generate MIME types dynamically for QuickTime, // so they provide a (bizarre) API to do so. // // The solution is to set WebPluginMIMETypesFilename to an invalid filename, // and then implement the dynamic symbol BP_CreatePluginMIMETypesPreferences. // When the path is found to be invalid by the loader, our callback will be // invoked and we can generate a new plist. // // Once our callback returns, the loader then attempts to load the missing // filename again, and then parses it for the MIME types. // // In order to keep this file fresh, we should unlink() it on NP_Initialize(). // // This is an example of the data we need: // // <key>WebPluginMIMETypes</key> // <dict> // <key>application/pdf</key> // <dict> // <key>WebPluginExtensions</key> // <array> // <string>pdf</string> // </array> // <key>WebPluginTypeDescription</key> // <string>PDF Image</string> // <key>WebPluginTypeEnabled</key> // <false/> // </dict> // </dict> // // This is the dynamic symbol used by the loader to resolve the missing MIME list. void __export BP_CreatePluginMIMETypesPreferences(void) { CFMutableDictionaryRef cf_root; CFMutableDictionaryRef cf_mimetypes; CFDictionaryRef cf_pluginmimetypes; struct plugin *current; // We need to create a new preferences dictionary, so this will be the root // of the new property list. cf_root = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // A WebPluginMIMETypes Dictionary. cf_mimetypes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); // Every plugin should have a handle should have a CFBundle handle open, // which we can query for it's WebPluginMIMETypes CFDictionary, which we // simply merge with ours. for (current = registry.plugins; current; current = current->next) { // Verify this handle exists, it can be NULL when LoadPlugin fails. if (current->handle) { // This should be a CFDictionary of all the MIME types supported by the plugin. cf_pluginmimetypes = CFBundleGetValueForInfoDictionaryKey(current->handle, CFSTR("WebPluginMIMETypes")); // Check that key exists in the Proerty Info. if (cf_pluginmimetypes) { // Merge this dictionary with ours. CFDictionaryApplyFunction(cf_pluginmimetypes, merge_dictionary_applier, cf_mimetypes); } else { // FIXME: If a plugin does not have a WebPluginMIMETypes key, // it is either invalid, or uses dynamic MIME type // generation. QuickTime is the only major plugin that // does this. // // I can implement it on request, but see no reason to // implement now. l_warning("unable to handle plugin %s, from %s", current->section, current->plugin); } } } // Add the types to my plist root. CFDictionarySetValue(cf_root, CFSTR("WebPluginMIMETypes"), cf_mimetypes); // Create the missing plist file. CFPreferencesSetMultiple(cf_root, NULL, CFSTR("com.google.netscapesecurity"), kCFPreferencesCurrentUser, kCFPreferencesAnyHost); // Save changes to disk. CFPreferencesAppSynchronize(CFSTR("com.google.netscapesecurity")); // Clean up. CFRelease(cf_mimetypes); CFRelease(cf_root); return; }