Author: lslezak Date: Tue Oct 7 18:22:18 2008 New Revision: 51938 URL: http://svn.opensuse.org/viewcvs/yast?rev=51938&view=rev Log: - use 'setup-pulseaudio' script for configuring PulseAudio (bnc#425475) - 2.17.6 Modified: trunk/sound/VERSION trunk/sound/package/yast2-sound.changes trunk/sound/sound/src/PulseAudio.ycp trunk/sound/sound/src/complex.ycp trunk/sound/sound/src/sound.ycp trunk/sound/sound/src/sound_auto.ycp Modified: trunk/sound/VERSION URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/VERSION?rev=51938&r1=51937&r2=51938&view=diff ============================================================================== --- trunk/sound/VERSION (original) +++ trunk/sound/VERSION Tue Oct 7 18:22:18 2008 @@ -1 +1 @@ -2.17.5 +2.17.6 Modified: trunk/sound/package/yast2-sound.changes URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/package/yast2-sound.changes?rev=51938&r1=51937&r2=51938&view=diff ============================================================================== --- trunk/sound/package/yast2-sound.changes (original) +++ trunk/sound/package/yast2-sound.changes Tue Oct 7 18:22:18 2008 @@ -1,4 +1,11 @@ ------------------------------------------------------------------- +Tue Oct 7 17:10:01 CEST 2008 - lslezak@suse.cz + +- use 'setup-pulseaudio' script for configuring PulseAudio + (bnc#425475) +- 2.17.6 + +------------------------------------------------------------------- Mon Oct 6 17:18:43 CEST 2008 - lslezak@suse.cz - fixed storing additional module parameters (bnc#404900) Modified: trunk/sound/sound/src/PulseAudio.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/PulseAudio.ycp?rev=51938&r1=51937&r2=51938&view=diff ============================================================================== --- trunk/sound/sound/src/PulseAudio.ycp (original) +++ trunk/sound/sound/src/PulseAudio.ycp Tue Oct 7 18:22:18 2008 @@ -32,19 +32,68 @@ module "PulseAudio"; textdomain "sound"; +import "FileUtils"; +import "Summary"; + boolean pa_enabled = nil; boolean modified = false; +// path to the configuration script +const string pa_setup_script = "/usr/bin/setup-pulseaudio"; + global boolean Read() { + // reset the modification flag modified = false; - y2warning("PulseAudio::Read() is not implemented!"); + + if (FileUtils::Exists(pa_setup_script)) + { + map out = (map)SCR::Execute(.target.bash_output, pa_setup_script + " --status"); + y2milestone("Read status: %1", out); + + pa_enabled = regexpmatch(out["stdout"]:"", "^enabled"); + + y2milestone("PulseAudio is %1", pa_enabled ? "enabled" : "disabled"); + } + else + { + y2warning("PulseAudio setup script %1 is not present!", pa_setup_script); + return false; + } + return true; } global boolean Write() { - y2warning("PulseAudio::Write() is not implemented!"); + y2milestone("PulseAudio::Write(): pa_enabled: %1, modified: %2", pa_enabled, modified); + + if (pa_enabled != nil && modified) + { + if (FileUtils::Exists(pa_setup_script)) + { + y2milestone("%1 PulseAudio support", pa_enabled ? "Enabling" : "Disabling"); + + map out = (map)SCR::Execute(.target.bash_output, pa_setup_script + + (pa_enabled ? " --enable" : " --disable")); + + y2milestone("Write status: %1", out); + + // reset the modification flag + modified = false; + } + else + { + y2error("PulseAudio setup script %1 is not present, cannot activate the configuration!", pa_setup_script); + return false; + } + } + else + { + y2error("PulseAudio is not configured, cannot save activate configuration"); + return false; + } + return true; } @@ -52,15 +101,16 @@ { if (pa_enabled == nil) { - y2warning("PulseAudio is not configured"); - // summary string - return _("PulseAudio is not configured"); + return ""; } - // summary string, %1 is "enabled" or "disabled" - return sformat(_("PulseAudio is %1"), - // part of a summary text (disabled/enabled status) - pa_enabled ? _("enabled") : _("disabled")); + list<string> retlist = [ + Summary::Device("PulseAudio", + // part of a summary text (PulseAudio is disabled/enabled) + (pa_enabled ? _("Enabled") : _("Disabled")) + )]; + + return Summary::DevicesList(retlist); } global void Reset() @@ -70,6 +120,36 @@ modified = false; } +global map Export() +{ + if (pa_enabled == nil) + { + return $[]; + } + + return $[ + "pulse_audio_status" : pa_enabled + ]; +} + +global boolean Import(map settings) +{ + if (haskey(settings, "pulse_audio_status")) + { + pa_enabled = settings["pulse_audio_status"]:false; + modified = true; + + y2milestone("Imported PulseAudio configuration: pa_enabled: %1", pa_enabled); + } + else + { + y2milestone("The imported configuration doesn't contain PulseAudio configuration."); + pa_enabled = nil; + } + + return true; +} + global void Enable(boolean enable) { if (enable == nil) Modified: trunk/sound/sound/src/complex.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/complex.ycp?rev=51938&r1=51937&r2=51938&view=diff ============================================================================== --- trunk/sound/sound/src/complex.ycp (original) +++ trunk/sound/sound/src/complex.ycp Tue Oct 7 18:22:18 2008 @@ -312,6 +312,14 @@ void PulseAudioPopup() { + if (!Mode::config() && PulseAudio::Enabled() == nil) + { + y2error("PulseAudio status is nil - the setup script is missing?"); + // error popup message + Popup::Error(_("PulseAudio is not installed or cannot be configured.")); + return; + } + term dlg = `HBox( `HSpacing(1), @@ -323,7 +331,7 @@ `VSpacing(0.5), `Left(`CheckBox(`id(`pulseaudio), // check box label - _("&Enable PulseAudio Support"), PulseAudio::Enabled() != false) + _("&Enable PulseAudio Support"), PulseAudio::Enabled() == true) ), `VSpacing(0.5) ) Modified: trunk/sound/sound/src/sound.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/sound.ycp?rev=51938&r1=51937&r2=51938&view=diff ============================================================================== --- trunk/sound/sound/src/sound.ycp (original) +++ trunk/sound/sound/src/sound.ycp Tue Oct 7 18:22:18 2008 @@ -77,7 +77,9 @@ Sound::use_ui = false; block<boolean> abort_block = ``{return false;}; - boolean ret = Sound::Read (false) && Joystick::Read(abort_block) && PulseAudio::Read(); + boolean ret = Sound::Read (false) && Joystick::Read(abort_block); + // PulseAudio is optional, it may fail + PulseAudio::Read(); return ret; } Modified: trunk/sound/sound/src/sound_auto.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/sound_auto.ycp?rev=51938&r1=51937&r2=51938&view=diff ============================================================================== --- trunk/sound/sound/src/sound_auto.ycp (original) +++ trunk/sound/sound/src/sound_auto.ycp Tue Oct 7 18:22:18 2008 @@ -109,11 +109,12 @@ /* Create a summary*/ if(func == "Import") { - ret = Sound::Import(param); + ret = Sound::Import(param) && PulseAudio::Import(param); } /* Create a summary*/ else if(func == "Summary") { - ret = Sound::Summary(); + ret = Sound::Summary() + PulseAudio::Summary(); + y2milestone("Sound card configuration summary: %1", ret); } else if (func == "GetModified") { ret = Sound::GetModified(); @@ -125,6 +126,7 @@ /* Reset configuration */ else if (func == "Reset") { Sound::Import($[]); + PulseAudio::Reset(); ret = $[]; } /* Change configuration (run AutoSequence) TODO */ @@ -142,6 +144,11 @@ /* Return actual state */ else if (func == "Export") { ret = Sound::Export(); + // add PulseAudio config if it's defined + if (PulseAudio::Enabled() != nil) + { + ret = union((map)ret, PulseAudio::Export()); + } } else if (func == "Read") { PulseAudio::Read(); -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org