/*!
* \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.
/*!
* \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()
{
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); }
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);
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,
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);
}
for (i = 0; !err && i < count; i++) {
CFDictionaryRef dictionary = NULL;
- kim_options options = KIM_OPTIONS_DEFAULT;
CFStringRef cfstring = NULL;
dictionary = (CFDictionaryRef) CFArrayGetValueAtIndex (value, i);
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);