コード例 #1
0
ProfileControl::ProfileControl(QObject *parent)
    : QObject(parent),
      m_systemSoundLevel(-1),
      m_touchscreenToneLevel(-1),
      m_touchscreenVibrationLevel(-1),
      m_ringerToneEnabled(-1),
      m_messageToneEnabled(-1),
      m_chatToneEnabled(-1),
      m_mailToneEnabled(-1),
      m_internetCallToneEnabled(-1),
      m_calendarToneEnabled(-1),
      m_clockAlarmToneEnabled(-1)
{
    profile_track_add_profile_cb((profile_track_profile_fn_data) currentProfileChangedCallback, this, NULL);

    // track changes in active and inactive profile(s)
    profile_track_add_active_cb((profile_track_value_fn_data) &updateStateCallBackTrampoline, this, NULL);
    profile_track_add_change_cb((profile_track_value_fn_data) &updateStateCallBackTrampoline, this, NULL);

    profile_connection_enable_autoconnect();

    if (s_instanceCounter == 0) {
        profile_tracker_init();
    }
    s_instanceCounter++;

    m_ringerVolume = profile_get_value_as_int(GeneralProfile, VolumeKey);
    m_vibraInGeneral = profile_get_value_as_bool(GeneralProfile, VibraKey);
    m_vibraInSilent = profile_get_value_as_bool(SilentProfile, VibraKey);
}
コード例 #2
0
ファイル: profile.c プロジェクト: arcean/ohm-plugins-misc
static gboolean subscribe_to_service()
{
    /* subscribe to the current profile change notifications */
    profile_track_add_profile_cb(profile_name_change, NULL, NULL);

    /* subscribe to a value change in the current profile notifications */
    profile_track_add_active_cb(profile_value_change, NULL, NULL);

    if (profile_tracker_init() < 0) {
        return FALSE;
    }

    return TRUE;
}
void
ProfileBackend::initialize ()
{
    // initialization should be done only once...
    if (m_initialized)
        return;

    m_initialized = true;

#ifdef HAVE_LIBPROFILE
    // get the current profile name
    m_activeProfile = profile_get_profile ();

    char **profiles = NULL;

    // get the list of available profiles
    profiles = profile_get_profiles ();

    if (profiles != NULL)
    {
        for (int i = 0; profiles[i] != NULL; i++)
        {
            char *profile = profiles[i];

            int  volumeLevel = profile_get_value_as_int (profile, keyVolume);
            bool vibration = profile_get_value_as_bool (profile, keyVibration);

            SYS_DEBUG ("*** PROFILE : \"%s\" ***", profile);

            // fill the hash tables...
            m_profileVibrations[QString (profile)] = vibration;
            m_profileVolumes[QString (profile)]    = volumeLevel;
        }

        profile_free_profiles (profiles);
    }
    else
    {
        SYS_WARNING ("There are no available profiles on the system!");
    }

    // callback to track current profile changes...
    profile_track_add_profile_cb (
        (profile_track_profile_fn_data) &ProfileBackend::currentProfileChanged,
        this, NULL);

    // callback to track profile value changes...
    profile_track_add_change_cb (
        (profile_track_value_fn_data) &ProfileBackend::profileValueChanged,
        this, NULL);

    // callback to track current profile value changes...
    // XXX: is this call really necessary? FIXME
    profile_track_add_active_cb (
        (profile_track_value_fn_data) &ProfileBackend::profileValueChanged,
        this, NULL);

    // start the tracking of changes...
    profile_connection_enable_autoconnect ();
    profile_tracker_init ();
#endif // HAVE_LIBPROFILE
}