static int ffm_setup_device(const NProplist *props, int *dev_fd) { const char *device_file = n_proplist_get_string(props, FFM_DEVFILE_KEY); if (device_file == NULL) { N_DEBUG (LOG_CAT "No %s provided, using automatic detection", FFM_DEVFILE_KEY); *dev_fd = ffmemless_evdev_file_search(); } else { N_DEBUG (LOG_CAT "%s found with value \"%s\"", FFM_DEVFILE_KEY, device_file); *dev_fd = ffmemless_evdev_file_open(device_file); /* do a fall back to automatic search, in case open fails */ if (*dev_fd == -1) { N_DEBUG (LOG_CAT "%s is not a valid event device", device_file); N_DEBUG (LOG_CAT "Falling back to automatic detection"); *dev_fd = ffmemless_evdev_file_search(); } } if (*dev_fd == -1) { N_DEBUG (LOG_CAT "Failed to open ff-memless event device"); return -1; } else { N_DEBUG (LOG_CAT "Successfully opened ff-memless event device"); return 0; } }
/* Fetches string value from props with full key combined from prefix and key */ static const char *ffm_get_str_value(const NProplist *props, const char *prefix, const char *key) { char full_key[FFM_MAX_PARAM_LEN]; sprintf(full_key, "%s%s", prefix, key); return n_proplist_get_string(props, full_key); }
static int mce_sink_play (NSinkInterface *iface, NRequest *request) { const NProplist *props = n_request_get_properties (request); (void) iface; const gchar *pattern = NULL; MceData *data = (MceData*) n_request_get_data (request, MCE_KEY); g_assert (data != NULL); if (n_proplist_get_bool (props, "mce.backlight_on")) backlight_on (); pattern = n_proplist_get_string (props, "mce.led_pattern"); if (pattern != NULL) { data->pattern = g_strdup (pattern); if (toggle_pattern (pattern, TRUE)) { active_events = g_list_append(active_events, data); } else { g_free (data->pattern); data->pattern = NULL; } } return TRUE; }
static void transform_properties_cb (NHook *hook, void *data, void *userdata) { (void) hook; (void) data; (void) userdata; NCore *core = (NCore*) userdata; NContext *context = n_core_get_context (core); NProplist *new_props = NULL; NProplist *props = NULL; GList *iter = NULL; const char *match_str = NULL; ProfileEntry *entry = NULL; NValue *value = NULL; gchar *context_key = NULL; NCoreHookTransformPropertiesData *transform = (NCoreHookTransformPropertiesData*) data; N_DEBUG (LOG_CAT "transforming profile values for request '%s'", n_request_get_name (transform->request)); new_props = n_proplist_new (); props = (NProplist*) n_request_get_properties (transform->request); for (iter = g_list_first (request_keys); iter; iter = g_list_next (iter)) { match_str = n_proplist_get_string (props, (gchar*) iter->data); if (!match_str) continue; entry = g_hash_table_lookup (profile_entries, match_str); if (!entry) continue; /* if this a fallback request, we don't care if there is existing target. otherwise check if the target exists. */ if (!n_request_is_fallback (transform->request) && n_proplist_has_key (props, entry->target)) continue; context_key = construct_context_key (entry->profile, entry->key); value = (NValue*) n_context_get_value (context, context_key); if (value) { N_DEBUG (LOG_CAT "+ transforming profile key '%s' to target '%s'", entry->key, entry->target); n_proplist_set (new_props, entry->target, n_value_copy (value)); } g_free (context_key); } n_proplist_merge (props, new_props); n_proplist_free (new_props); N_DEBUG (LOG_CAT "new properties:") n_proplist_dump (props); }
static int canberra_sink_prepare (NSinkInterface *iface, NRequest *request) { N_DEBUG (LOG_CAT "sink prepare"); CanberraData *data = g_slice_new0 (CanberraData); NProplist *props = props = (NProplist*) n_request_get_properties (request); data->request = request; data->iface = iface; data->filename = n_proplist_get_string (props, SOUND_FILENAME_KEY); data->sound_enabled = TRUE; data->complete_cb_id = 0; n_request_store_data (request, CANBERRA_KEY, data); n_sink_interface_synchronize (iface, request); if (n_proplist_has_key (props, SOUND_VOLUME_KEY)) data->sound_enabled = n_proplist_get_int (props, SOUND_VOLUME_KEY) > 0; return TRUE; }
static const char *get_type(NRequest *request) { return n_proplist_get_string(n_request_get_properties(request), "tonegen.type"); }