1 /* finddefault.c -- find_default_device() implementation
2 Roger Dannenberg, June 2008
9 #include "pminternal.h"
10 #include "pmmacosxcm.h"
11 #include "readbinaryplist.h"
13 /* Parse preference files, find default device, search devices --
14 This parses the preference file(s) once for input and once for
15 output, which is inefficient but much simpler to manage. Note
16 that using the readbinaryplist.c module, you cannot keep two
17 plist files (user and system) open at once (due to a simple
18 memory management scheme).
20 PmDeviceID find_default_device(char *path, int input, PmDeviceID id)
21 /* path -- the name of the preference we are searching for
22 input -- true iff this is an input device
23 id -- current default device id
24 returns matching device id if found, otherwise id
27 static char *pref_file = "com.apple.java.util.prefs.plist";
28 char *pref_str = NULL;
29 // read device preferences
30 value_ptr prefs = bplist_read_user_pref(pref_file);
32 value_ptr pref_val = value_dict_lookup_using_path(prefs, path);
34 pref_str = value_get_asciistring(pref_val);
38 bplist_free_data(); /* look elsewhere */
39 prefs = bplist_read_system_pref(pref_file);
41 value_ptr pref_val = value_dict_lookup_using_path(prefs, path);
43 pref_str = value_get_asciistring(pref_val);
47 if (pref_str) { /* search devices for match */
48 int i = pm_find_default_device(pref_str, input);
49 if (i != pmNoDevice) {