preferences should handle KIM_OPTIONS_DEFAULT
authorAlexandra Ellwood <lxs@mit.edu>
Thu, 9 Oct 2008 17:51:03 +0000 (17:51 +0000)
committerAlexandra Ellwood <lxs@mit.edu>
Thu, 9 Oct 2008 17:51:03 +0000 (17:51 +0000)
ticket: new

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@20854 dc483132-0cff-0310-8789-dd5450dbe970

src/include/kim/kim_options.h
src/include/kim/kim_preferences.h
src/kim/lib/kim_preferences.c
src/kim/lib/kim_selection_hints.c
src/kim/lib/mac/kim_os_preferences.c

index 2c82b3ef5d4226f5e6c092146c7f3ad14a756421..d36aa0c0211024d7ffb3f718c2e2a3e29362bb3d 100644 (file)
@@ -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.
index bce010cdd1024ba64c27a255228b5f982f504c50..d7970ba049ea7ddb76e8636883f00baed3f498b2 100644 (file)
@@ -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()
index 48dd75c632488661591b383c6a554938549c9881..d63a6141d5fddf625401ed6278c77ddceb9e4e38 100644 (file)
@@ -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); }
index 580191ded04f3493294a8037725580f6b304c0c5..797f70bd5b74c999c3ef15269d9de39629b69d08 100644 (file)
@@ -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);
index 152132c04952519f37cc7692ece51fe6b8e44bd0..0b48a7fbb16926c78b754e4bba603b81e719b806 100644 (file)
@@ -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);