From a963958bb2579862a367b6523a3f46d53109f8c8 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Thu, 9 Oct 2008 17:51:03 +0000 Subject: [PATCH] preferences should handle KIM_OPTIONS_DEFAULT ticket: new git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20854 dc483132-0cff-0310-8789-dd5450dbe970 --- src/include/kim/kim_options.h | 3 ++- src/include/kim/kim_preferences.h | 3 ++- src/kim/lib/kim_preferences.c | 2 +- src/kim/lib/kim_selection_hints.c | 6 +----- src/kim/lib/mac/kim_os_preferences.c | 6 +++--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/include/kim/kim_options.h b/src/include/kim/kim_options.h index 2c82b3ef5..d36aa0c02 100644 --- a/src/include/kim/kim_options.h +++ b/src/include/kim/kim_options.h @@ -185,7 +185,8 @@ kim_error kim_options_create (kim_options *out_options); /*! * \param out_options on exit, a new options object which is a copy of \a in_options. - * Must be freed with kim_options_free(). + * Must be freed with kim_options_free(). If passed KIM_OPTIONS_DEFAULT + * will set \a out_options to KIM_OPTIONS_DEFAULT. * \param in_options a options object. * \return On success, #KIM_NO_ERROR. On failure, an error code representing the failure. * \brief Copy options. diff --git a/src/include/kim/kim_preferences.h b/src/include/kim/kim_preferences.h index bce010cdd..d7970ba04 100644 --- a/src/include/kim/kim_preferences.h +++ b/src/include/kim/kim_preferences.h @@ -177,7 +177,8 @@ kim_error kim_preferences_set_options (kim_preferences io_preferences, /*! * \param in_preferences a preferences object. * \param out_options on exit, the options specified in \a in_preferences. - * Must be freed with kim_options_free(). + * May be KIM_OPTIONS_DEFAULT. + * If not, must be freed with kim_options_free(). * \return On success, #KIM_NO_ERROR. On failure, an error code representing the failure. * \brief Get the user's preferred options. * \sa kim_preferences_set_options() diff --git a/src/kim/lib/kim_preferences.c b/src/kim/lib/kim_preferences.c index 48dd75c63..d63a6141d 100644 --- a/src/kim/lib/kim_preferences.c +++ b/src/kim/lib/kim_preferences.c @@ -230,7 +230,7 @@ kim_error kim_favorites_add_identity (kim_favorites io_favorites, { kim_error err = KIM_NO_ERROR; kim_identity identity = NULL; - kim_options options = NULL; + kim_options options = KIM_OPTIONS_DEFAULT; kim_count insert_at = 0; if (!err && !io_favorites) { err = check_error (KIM_NULL_PARAMETER_ERR); } diff --git a/src/kim/lib/kim_selection_hints.c b/src/kim/lib/kim_selection_hints.c index 580191ded..797f70bd5 100644 --- a/src/kim/lib/kim_selection_hints.c +++ b/src/kim/lib/kim_selection_hints.c @@ -372,11 +372,7 @@ kim_error kim_selection_hints_get_options (kim_selection_hints in_selection_hin if (!err && !out_options ) { err = check_error (KIM_NULL_PARAMETER_ERR); } if (!err) { - if (in_selection_hints->options) { - err = kim_options_copy (out_options, in_selection_hints->options); - } else { - *out_options = KIM_OPTIONS_DEFAULT; - } + err = kim_options_copy (out_options, in_selection_hints->options); } return check_error (err); diff --git a/src/kim/lib/mac/kim_os_preferences.c b/src/kim/lib/mac/kim_os_preferences.c index 152132c04..0b48a7fbb 100644 --- a/src/kim/lib/mac/kim_os_preferences.c +++ b/src/kim/lib/mac/kim_os_preferences.c @@ -888,7 +888,7 @@ kim_error kim_os_preferences_set_options_for_key (kim_preference_key in_key, kim_error err = KIM_NO_ERROR; CFMutableDictionaryRef dictionary = NULL; - if (!err && !in_options) { err = check_error (KIM_NULL_PARAMETER_ERR); } + /* in_options may be KIM_OPTIONS_DEFAULT, in which case we empty the dict */ if (!err) { dictionary = CFDictionaryCreateMutable (kCFAllocatorDefault, 0, @@ -897,7 +897,7 @@ kim_error kim_os_preferences_set_options_for_key (kim_preference_key in_key, if (!dictionary) { err = check_error (KIM_OUT_OF_MEMORY_ERR); } } - if (!err) { + if (!err && in_options) { err = kim_os_preferences_options_to_dictionary (in_options, dictionary); } @@ -937,7 +937,6 @@ kim_error kim_os_preferences_get_favorites_for_key (kim_preference_key in_key, for (i = 0; !err && i < count; i++) { CFDictionaryRef dictionary = NULL; - kim_options options = KIM_OPTIONS_DEFAULT; CFStringRef cfstring = NULL; dictionary = (CFDictionaryRef) CFArrayGetValueAtIndex (value, i); @@ -955,6 +954,7 @@ kim_error kim_os_preferences_get_favorites_for_key (kim_preference_key in_key, if (!err && cfstring) { kim_string string = NULL; kim_identity identity = NULL; + kim_options options = KIM_OPTIONS_DEFAULT; err = kim_os_string_create_from_cfstring (&string, cfstring); -- 2.26.2