diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 2002-05-13 21:21:49 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 2002-05-13 21:21:49 (GMT) |
commit | 23be1ceb512ad8244dfd08b97e6a0dab8404f213 (patch) | |
tree | 45ad70a7aacfcff8beed2136fc44a4eb08db248d /Mac/Modules/cf | |
parent | 4402241450fe679a3cc90e4491aaabee232bb4e2 (diff) | |
download | cpython-23be1ceb512ad8244dfd08b97e6a0dab8404f213.zip cpython-23be1ceb512ad8244dfd08b97e6a0dab8404f213.tar.gz cpython-23be1ceb512ad8244dfd08b97e6a0dab8404f213.tar.bz2 |
Added CFPreferences support. Added these as functions, not methods, which seemed counter-intuitive.
Diffstat (limited to 'Mac/Modules/cf')
-rw-r--r-- | Mac/Modules/cf/_CFmodule.c | 357 | ||||
-rw-r--r-- | Mac/Modules/cf/cfscan.py | 4 | ||||
-rw-r--r-- | Mac/Modules/cf/cfsupport.py | 14 |
3 files changed, 372 insertions, 3 deletions
diff --git a/Mac/Modules/cf/_CFmodule.c b/Mac/Modules/cf/_CFmodule.c index 552511dd..eb3f3f6 100644 --- a/Mac/Modules/cf/_CFmodule.c +++ b/Mac/Modules/cf/_CFmodule.c @@ -28,6 +28,7 @@ #include <CFString.h> #include <CFURL.h> #include <CFPropertyList.h> +#include <CFPreferences.h> #else #include <CoreServices/CoreServices.h> #endif @@ -3320,6 +3321,323 @@ static PyObject *CF_CFDictionaryCreateMutableCopy(PyObject *_self, PyObject *_ar return _res; } +static PyObject *CF_CFPreferencesCopyAppValue(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFTypeRef _rv; + CFStringRef key; + CFStringRef applicationID; +#ifndef CFPreferencesCopyAppValue + PyMac_PRECHECK(CFPreferencesCopyAppValue); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesCopyAppValue(key, + applicationID); + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; +} + +static PyObject *CF_CFPreferencesGetAppBooleanValue(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Boolean _rv; + CFStringRef key; + CFStringRef applicationID; + Boolean keyExistsAndHasValidFormat; +#ifndef CFPreferencesGetAppBooleanValue + PyMac_PRECHECK(CFPreferencesGetAppBooleanValue); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesGetAppBooleanValue(key, + applicationID, + &keyExistsAndHasValidFormat); + _res = Py_BuildValue("ll", + _rv, + keyExistsAndHasValidFormat); + return _res; +} + +static PyObject *CF_CFPreferencesGetAppIntegerValue(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFIndex _rv; + CFStringRef key; + CFStringRef applicationID; + Boolean keyExistsAndHasValidFormat; +#ifndef CFPreferencesGetAppIntegerValue + PyMac_PRECHECK(CFPreferencesGetAppIntegerValue); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesGetAppIntegerValue(key, + applicationID, + &keyExistsAndHasValidFormat); + _res = Py_BuildValue("ll", + _rv, + keyExistsAndHasValidFormat); + return _res; +} + +static PyObject *CF_CFPreferencesSetAppValue(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFStringRef key; + CFTypeRef value; + CFStringRef applicationID; +#ifndef CFPreferencesSetAppValue + PyMac_PRECHECK(CFPreferencesSetAppValue); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + CFStringRefObj_Convert, &key, + CFTypeRefObj_Convert, &value, + CFStringRefObj_Convert, &applicationID)) + return NULL; + CFPreferencesSetAppValue(key, + value, + applicationID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CF_CFPreferencesAddSuitePreferencesToApp(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFStringRef applicationID; + CFStringRef suiteID; +#ifndef CFPreferencesAddSuitePreferencesToApp + PyMac_PRECHECK(CFPreferencesAddSuitePreferencesToApp); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &suiteID)) + return NULL; + CFPreferencesAddSuitePreferencesToApp(applicationID, + suiteID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CF_CFPreferencesRemoveSuitePreferencesFromApp(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFStringRef applicationID; + CFStringRef suiteID; +#ifndef CFPreferencesRemoveSuitePreferencesFromApp + PyMac_PRECHECK(CFPreferencesRemoveSuitePreferencesFromApp); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &suiteID)) + return NULL; + CFPreferencesRemoveSuitePreferencesFromApp(applicationID, + suiteID); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CF_CFPreferencesAppSynchronize(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Boolean _rv; + CFStringRef applicationID; +#ifndef CFPreferencesAppSynchronize + PyMac_PRECHECK(CFPreferencesAppSynchronize); +#endif + if (!PyArg_ParseTuple(_args, "O&", + CFStringRefObj_Convert, &applicationID)) + return NULL; + _rv = CFPreferencesAppSynchronize(applicationID); + _res = Py_BuildValue("l", + _rv); + return _res; +} + +static PyObject *CF_CFPreferencesCopyValue(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFTypeRef _rv; + CFStringRef key; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesCopyValue + PyMac_PRECHECK(CFPreferencesCopyValue); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&", + CFStringRefObj_Convert, &key, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyValue(key, + applicationID, + userName, + hostName); + _res = Py_BuildValue("O&", + CFTypeRefObj_New, _rv); + return _res; +} + +static PyObject *CF_CFPreferencesCopyMultiple(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFDictionaryRef _rv; + CFArrayRef keysToFetch; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesCopyMultiple + PyMac_PRECHECK(CFPreferencesCopyMultiple); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&", + CFArrayRefObj_Convert, &keysToFetch, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyMultiple(keysToFetch, + applicationID, + userName, + hostName); + _res = Py_BuildValue("O&", + CFDictionaryRefObj_New, _rv); + return _res; +} + +static PyObject *CF_CFPreferencesSetValue(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFStringRef key; + CFTypeRef value; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesSetValue + PyMac_PRECHECK(CFPreferencesSetValue); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", + CFStringRefObj_Convert, &key, + CFTypeRefObj_Convert, &value, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + CFPreferencesSetValue(key, + value, + applicationID, + userName, + hostName); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CF_CFPreferencesSetMultiple(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFDictionaryRef keysToSet; + CFArrayRef keysToRemove; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesSetMultiple + PyMac_PRECHECK(CFPreferencesSetMultiple); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&O&O&", + CFDictionaryRefObj_Convert, &keysToSet, + CFArrayRefObj_Convert, &keysToRemove, + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + CFPreferencesSetMultiple(keysToSet, + keysToRemove, + applicationID, + userName, + hostName); + Py_INCREF(Py_None); + _res = Py_None; + return _res; +} + +static PyObject *CF_CFPreferencesSynchronize(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + Boolean _rv; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesSynchronize + PyMac_PRECHECK(CFPreferencesSynchronize); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesSynchronize(applicationID, + userName, + hostName); + _res = Py_BuildValue("l", + _rv); + return _res; +} + +static PyObject *CF_CFPreferencesCopyApplicationList(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFArrayRef _rv; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesCopyApplicationList + PyMac_PRECHECK(CFPreferencesCopyApplicationList); +#endif + if (!PyArg_ParseTuple(_args, "O&O&", + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyApplicationList(userName, + hostName); + _res = Py_BuildValue("O&", + CFArrayRefObj_New, _rv); + return _res; +} + +static PyObject *CF_CFPreferencesCopyKeyList(PyObject *_self, PyObject *_args) +{ + PyObject *_res = NULL; + CFArrayRef _rv; + CFStringRef applicationID; + CFStringRef userName; + CFStringRef hostName; +#ifndef CFPreferencesCopyKeyList + PyMac_PRECHECK(CFPreferencesCopyKeyList); +#endif + if (!PyArg_ParseTuple(_args, "O&O&O&", + CFStringRefObj_Convert, &applicationID, + CFStringRefObj_Convert, &userName, + CFStringRefObj_Convert, &hostName)) + return NULL; + _rv = CFPreferencesCopyKeyList(applicationID, + userName, + hostName); + _res = Py_BuildValue("O&", + CFArrayRefObj_New, _rv); + return _res; +} + static PyObject *CF_CFStringGetTypeID(PyObject *_self, PyObject *_args) { PyObject *_res = NULL; @@ -3884,6 +4202,34 @@ static PyMethodDef CF_methods[] = { "(CFIndex capacity) -> (CFMutableDictionaryRef _rv)"}, {"CFDictionaryCreateMutableCopy", (PyCFunction)CF_CFDictionaryCreateMutableCopy, 1, "(CFIndex capacity, CFDictionaryRef theDict) -> (CFMutableDictionaryRef _rv)"}, + {"CFPreferencesCopyAppValue", (PyCFunction)CF_CFPreferencesCopyAppValue, 1, + "(CFStringRef key, CFStringRef applicationID) -> (CFTypeRef _rv)"}, + {"CFPreferencesGetAppBooleanValue", (PyCFunction)CF_CFPreferencesGetAppBooleanValue, 1, + "(CFStringRef key, CFStringRef applicationID) -> (Boolean _rv, Boolean keyExistsAndHasValidFormat)"}, + {"CFPreferencesGetAppIntegerValue", (PyCFunction)CF_CFPreferencesGetAppIntegerValue, 1, + "(CFStringRef key, CFStringRef applicationID) -> (CFIndex _rv, Boolean keyExistsAndHasValidFormat)"}, + {"CFPreferencesSetAppValue", (PyCFunction)CF_CFPreferencesSetAppValue, 1, + "(CFStringRef key, CFTypeRef value, CFStringRef applicationID) -> None"}, + {"CFPreferencesAddSuitePreferencesToApp", (PyCFunction)CF_CFPreferencesAddSuitePreferencesToApp, 1, + "(CFStringRef applicationID, CFStringRef suiteID) -> None"}, + {"CFPreferencesRemoveSuitePreferencesFromApp", (PyCFunction)CF_CFPreferencesRemoveSuitePreferencesFromApp, 1, + "(CFStringRef applicationID, CFStringRef suiteID) -> None"}, + {"CFPreferencesAppSynchronize", (PyCFunction)CF_CFPreferencesAppSynchronize, 1, + "(CFStringRef applicationID) -> (Boolean _rv)"}, + {"CFPreferencesCopyValue", (PyCFunction)CF_CFPreferencesCopyValue, 1, + "(CFStringRef key, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFTypeRef _rv)"}, + {"CFPreferencesCopyMultiple", (PyCFunction)CF_CFPreferencesCopyMultiple, 1, + "(CFArrayRef keysToFetch, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFDictionaryRef _rv)"}, + {"CFPreferencesSetValue", (PyCFunction)CF_CFPreferencesSetValue, 1, + "(CFStringRef key, CFTypeRef value, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"}, + {"CFPreferencesSetMultiple", (PyCFunction)CF_CFPreferencesSetMultiple, 1, + "(CFDictionaryRef keysToSet, CFArrayRef keysToRemove, CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> None"}, + {"CFPreferencesSynchronize", (PyCFunction)CF_CFPreferencesSynchronize, 1, + "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (Boolean _rv)"}, + {"CFPreferencesCopyApplicationList", (PyCFunction)CF_CFPreferencesCopyApplicationList, 1, + "(CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"}, + {"CFPreferencesCopyKeyList", (PyCFunction)CF_CFPreferencesCopyKeyList, 1, + "(CFStringRef applicationID, CFStringRef userName, CFStringRef hostName) -> (CFArrayRef _rv)"}, {"CFStringGetTypeID", (PyCFunction)CF_CFStringGetTypeID, 1, "() -> (CFTypeID _rv)"}, {"CFStringCreateWithPascalString", (PyCFunction)CF_CFStringCreateWithPascalString, 1, @@ -4017,6 +4363,17 @@ void init_CF(void) Py_INCREF(&CFURLRef_Type); if (PyDict_SetItemString(d, "CFURLRefType", (PyObject *)&CFURLRef_Type) != 0) Py_FatalError("can't initialize CFURLRefType"); + +#define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name)) + _STRINGCONST(kCFPreferencesAnyApplication); + _STRINGCONST(kCFPreferencesCurrentApplication); + _STRINGCONST(kCFPreferencesAnyHost); + _STRINGCONST(kCFPreferencesCurrentHost); + _STRINGCONST(kCFPreferencesAnyUser); + _STRINGCONST(kCFPreferencesCurrentUser); + + + } /* ========================= End module _CF ========================= */ diff --git a/Mac/Modules/cf/cfscan.py b/Mac/Modules/cf/cfscan.py index ebaeed8..85178e4 100644 --- a/Mac/Modules/cf/cfscan.py +++ b/Mac/Modules/cf/cfscan.py @@ -31,7 +31,7 @@ def main(): "CFDictionary.h", ## "CFNumber.h", ## "CFPlugIn.h", -## "CFPreferences.h", + "CFPreferences.h", "CFPropertyList.h", ## "CFSet.h", "CFString.h", @@ -54,7 +54,7 @@ class MyScanner(Scanner_OSX): def destination(self, type, name, arglist): classname = "Function" listname = "functions" - if arglist: + if arglist and name[:13] != 'CFPreferences': t, n, m = arglist[0] if t in OBJECTS and m == "InMode": classname = "Method" diff --git a/Mac/Modules/cf/cfsupport.py b/Mac/Modules/cf/cfsupport.py index 23dbbac..8aed6c2 100644 --- a/Mac/Modules/cf/cfsupport.py +++ b/Mac/Modules/cf/cfsupport.py @@ -50,6 +50,7 @@ includestuff = includestuff + """ #include <CFString.h> #include <CFURL.h> #include <CFPropertyList.h> +#include <CFPreferences.h> #else #include <CoreServices/CoreServices.h> #endif @@ -165,6 +166,17 @@ PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert); PyMac_INIT_TOOLBOX_OBJECT_CONVERT(CFURLRef, CFURLRefObj_Convert); """ +variablestuff=""" +#define _STRINGCONST(name) PyModule_AddObject(m, #name, CFStringRefObj_New(name)) +_STRINGCONST(kCFPreferencesAnyApplication); +_STRINGCONST(kCFPreferencesCurrentApplication); +_STRINGCONST(kCFPreferencesAnyHost); +_STRINGCONST(kCFPreferencesCurrentHost); +_STRINGCONST(kCFPreferencesAnyUser); +_STRINGCONST(kCFPreferencesCurrentUser); + +""" + Boolean = Type("Boolean", "l") CFTypeID = Type("CFTypeID", "l") # XXXX a guess, seems better than OSTypeType. CFHashCode = Type("CFHashCode", "l") @@ -405,7 +417,7 @@ class CFURLRefObjectDefinition(MyGlobalObjectDefinition): # From here on it's basically all boiler plate... # Create the generator groups and link them -module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff) +module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff, variablestuff) CFTypeRef_object = CFTypeRefObjectDefinition('CFTypeRef', 'CFTypeRefObj', 'CFTypeRef') CFArrayRef_object = CFArrayRefObjectDefinition('CFArrayRef', 'CFArrayRefObj', 'CFArrayRef') CFMutableArrayRef_object = CFMutableArrayRefObjectDefinition('CFMutableArrayRef', 'CFMutableArrayRefObj', 'CFMutableArrayRef') |