diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2025-04-16 12:15:00 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2025-04-16 12:15:00 (GMT) |
commit | bb323895ac2d8655d5f6c85d16eefea364017298 (patch) | |
tree | 76a02a748277ce66a8bde32d7b58e55c3ec0b701 /plugins/pychrysalide | |
parent | d1665deb8929feeb3df4d8e1913063b8431a6d41 (diff) |
Handle optional settings for secure storage properly.
Diffstat (limited to 'plugins/pychrysalide')
-rw-r--r-- | plugins/pychrysalide/convert.c | 31 | ||||
-rw-r--r-- | plugins/pychrysalide/convert.h | 3 | ||||
-rw-r--r-- | plugins/pychrysalide/glibext/secstorage.c | 9 |
3 files changed, 39 insertions, 4 deletions
diff --git a/plugins/pychrysalide/convert.c b/plugins/pychrysalide/convert.c index c67c8ba..08866cb 100644 --- a/plugins/pychrysalide/convert.c +++ b/plugins/pychrysalide/convert.c @@ -87,3 +87,34 @@ int convert_to_gsettings(PyObject *arg, void *dst) return result; } + + +/****************************************************************************** +* * +* Paramètres : arg = argument quelconque à tenter de convertir. * +* dst = destination des valeurs récupérées en cas de succès. * +* * +* Description : Tente de convertir en instance GSettings ou NULL. * +* * +* Retour : Bilan de l'opération, voire indications supplémentaires. * +* * +* Remarques : - * +* * +******************************************************************************/ + +int convert_to_gsettings_or_none(PyObject *arg, void *dst) +{ + int result; /* Bilan à retourner */ + + if (arg == Py_None) + { + *((GSettings **)dst) = NULL; + result = 1; + } + + else + result = convert_to_gsettings(arg, dst); + + return result; + +} diff --git a/plugins/pychrysalide/convert.h b/plugins/pychrysalide/convert.h index 7bdf7da..86d7528 100644 --- a/plugins/pychrysalide/convert.h +++ b/plugins/pychrysalide/convert.h @@ -33,6 +33,9 @@ /* Tente de convertir en instance GSettings. */ int convert_to_gsettings(PyObject *, void *); +/* Tente de convertir en instance GSettings ou NULL. */ +int convert_to_gsettings_or_none(PyObject *, void *); + #endif /* _PLUGINS_PYCHRYSALIDE_CONVERT_H */ diff --git a/plugins/pychrysalide/glibext/secstorage.c b/plugins/pychrysalide/glibext/secstorage.c index b5adb7c..5935d29 100644 --- a/plugins/pychrysalide/glibext/secstorage.c +++ b/plugins/pychrysalide/glibext/secstorage.c @@ -106,14 +106,15 @@ static int py_secret_storage_init(PyObject *self, PyObject *args, PyObject *kwds "\n" \ "Instances can be created using the following constructor:\n" \ "\n" \ - " SecretStorage(settings)" \ + " SecretStorage(settings=None)" \ "\n" \ - "The *settings* arguement must point to a GSettings intance;" \ - " the main configuration settings are used by default." \ + "The *settings* arguement may point to a GSettings instance." \ + " This optional argument is mainly used for testing purpose;" \ + " the main configuration settings are used by default." settings = NULL; - ret = PyArg_ParseTuple(args, "|O&", convert_to_gsettings, &settings); + ret = PyArg_ParseTuple(args, "|O&", convert_to_gsettings_or_none, &settings); if (!ret) return -1; /* Initialisation d'un objet GLib */ |