Exemple #1
0
static void
profile_changed_cb (const char *profile,
                    void *userdata)
{
    (void) profile;
    (void) userdata;

    NCore    *core    = (NCore*) userdata;
    NContext *context = n_core_get_context (core);
    NValue   *value   = NULL;

    /* store the current profile to the context */

    value = n_value_new ();
    n_value_set_string (value, profile);
    n_context_set_value (context, CURRENT_PROFILE_KEY, value);
    N_DEBUG (LOG_CAT "current profile changed to '%s'", profile);
}
Exemple #2
0
static void
query_current_profile (NCore *core)
{
    NContext   *context = n_core_get_context (core);
    NValue     *value   = NULL;
    char       *profile = NULL;

    profile = profile_get_profile ();

    /* store the current profile to the context */

    value = n_value_new ();
    n_value_set_string (value, profile);
    n_context_set_value (context, "profile.current_profile", value);
    N_DEBUG (LOG_CAT "current profile set to '%s'", profile);

    free (profile);
}
Exemple #3
0
static void
update_context_value (NContext *context, const char *profile, const char *key,
                      const char *value)
{
    gchar  *context_key = NULL;
    NValue *context_val = NULL;
    gint    level       = 0;
    gchar  *new_val     = NULL;

    context_key = construct_context_key (profile, key);
    context_val = n_value_new ();

    if (g_str_has_suffix (key, TONE_SUFFIX) ||
        g_str_has_suffix (key, PATTERN_SUFFIX)) {
        new_val = get_absolute_tone_path (value);
        new_val = new_val != NULL ? new_val : g_strdup (value);
        n_value_set_string (context_val, new_val);
        g_free (new_val);
    }
    else if (g_str_has_suffix (key, VOLUME_SUFFIX)) {
        n_value_set_int (context_val, profile_parse_int (value));
    }
    else if (g_str_has_suffix (key, SYSTEM_SUFFIX)) {
        level = profile_parse_int (value);
        level = CLAMP_VALUE (level, 0, (gint) num_system_sound_levels-1);
        n_value_set_int (context_val, system_sound_levels[level]);
    }
    else if (g_str_equal (key, KEY_VIBRATION_ENABLED)) {
        n_value_set_bool (context_val, profile_parse_bool (value));
    } else if (g_str_equal (key, KEY_TOUCH_VIBRA_LEVEL)) {
        n_value_set_int (context_val, profile_parse_int (value));
    } else {
        n_value_set_string (context_val, value);
    }

    n_context_set_value (context, context_key, context_val);
    g_free (context_key);
}