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); }
static int track(void) { int exit_code = EXIT_FAILURE; GMainLoop *mainloop = g_main_loop_new(NULL, FALSE); profile_track_set_profile_cb(track_profile); profile_track_set_active_cb(track_active); profile_track_set_change_cb(track_change); profile_tracker_init(); g_main_loop_run(mainloop); exit_code = EXIT_SUCCESS; profile_tracker_quit(); if( mainloop != 0 ) { g_main_loop_unref(mainloop); mainloop = 0; } return exit_code; }
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; }
static void tracker_init(void) { DBusError err = DBUS_ERROR_INIT; connection = dbus_bus_get(DBUS_BUS_SESSION, &err); assert( connection != 0 ); profile_track_set_profile_cb(track_profile); profile_track_set_active_cb(track_active); profile_track_set_change_cb(track_change); int rc = profile_tracker_init(); assert( rc == 0 ); dbus_error_free(&err); }
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 }