From a9cd25ef135b52160faad1f085395d8b0e99b85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ladislav=20Slez=C3=A1k?= Date: Mon, 2 Aug 2004 08:38:06 +0000 Subject: [PATCH] - initial version svn path=/trunk/bluetooth/; revision=18331 --- .cvsignore | 20 +++ MAINTAINER | 1 + Makefile.cvs | 18 +++ RPMNAME | 1 + VERSION | 1 + agents/.cvsignore | 2 + agents/Makefile.am | 8 + agents/bt_hcid.scr | 39 +++++ agents/cfg_bluetooth.scr | 19 +++ configure.in.in | 12 ++ doc/.cvsignore | 2 + doc/Makefile.am | 10 ++ src/.cvsignore | 4 + src/Bluetooth.ycp | 263 +++++++++++++++++++++++++++++++ src/Makefile.am | 24 +++ src/bluetooth.desktop | 23 +++ src/bluetooth.ycp | 74 +++++++++ src/bluetooth_auto.ycp | 98 ++++++++++++ src/bluetooth_proposal.ycp | 87 +++++++++++ src/complex.ycp | 61 ++++++++ src/dialogs.ycp | 306 +++++++++++++++++++++++++++++++++++++ src/helps.ycp | 117 ++++++++++++++ src/wizards.ycp | 106 +++++++++++++ testsuite/.cvsignore | 11 ++ testsuite/Makefile.am | 21 +++ yast2-bluetooth.spec.in | 32 ++++ 26 files changed, 1360 insertions(+) create mode 100644 .cvsignore create mode 100644 MAINTAINER create mode 100644 Makefile.cvs create mode 100644 RPMNAME create mode 100644 VERSION create mode 100644 agents/.cvsignore create mode 100644 agents/Makefile.am create mode 100644 agents/bt_hcid.scr create mode 100644 agents/cfg_bluetooth.scr create mode 100644 configure.in.in create mode 100644 doc/.cvsignore create mode 100644 doc/Makefile.am create mode 100644 src/.cvsignore create mode 100644 src/Bluetooth.ycp create mode 100644 src/Makefile.am create mode 100644 src/bluetooth.desktop create mode 100644 src/bluetooth.ycp create mode 100644 src/bluetooth_auto.ycp create mode 100644 src/bluetooth_proposal.ycp create mode 100644 src/complex.ycp create mode 100644 src/dialogs.ycp create mode 100644 src/helps.ycp create mode 100644 src/wizards.ycp create mode 100644 testsuite/.cvsignore create mode 100644 testsuite/Makefile.am create mode 100644 yast2-bluetooth.spec.in diff --git a/.cvsignore b/.cvsignore new file mode 100644 index 0000000..2dacf75 --- /dev/null +++ b/.cvsignore @@ -0,0 +1,20 @@ +Makefile +Makefile.am +Makefile.am.common +Makefile.in +aclocal.m4 +config.cache +config.guess +config.h.in +config.log +config.status +config.sub +configure +configure.in +depcomp +install-sh +missing +mkinstalldirs +stamp-h +bluetooth.pot +autom4te.cache diff --git a/MAINTAINER b/MAINTAINER new file mode 100644 index 0000000..81346c0 --- /dev/null +++ b/MAINTAINER @@ -0,0 +1 @@ +Ladislav Slezak diff --git a/Makefile.cvs b/Makefile.cvs new file mode 100644 index 0000000..1126d55 --- /dev/null +++ b/Makefile.cvs @@ -0,0 +1,18 @@ +# +# Makefile.cvs +# +configure: all + ./configure + +all: + y2tool y2autoconf + y2tool y2automake + autoreconf --force --install + +install: configure + make + make install + +reconf: all + ./config.status --recheck + ./config.status diff --git a/RPMNAME b/RPMNAME new file mode 100644 index 0000000..b3f02ad --- /dev/null +++ b/RPMNAME @@ -0,0 +1 @@ +yast2-bluetooth diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..10c2c0c --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +2.10.0 diff --git a/agents/.cvsignore b/agents/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/agents/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/agents/Makefile.am b/agents/Makefile.am new file mode 100644 index 0000000..fd0d4ea --- /dev/null +++ b/agents/Makefile.am @@ -0,0 +1,8 @@ +# Makefile.am for bluetooth/agents + +agent_SCRIPTS = + +scrconf_DATA = bt_hcid.scr \ + cfg_bluetooth.scr + +EXTRA_DIST = $(agent_SCRIPTS) $(scrconf_DATA) diff --git a/agents/bt_hcid.scr b/agents/bt_hcid.scr new file mode 100644 index 0000000..68eb88f --- /dev/null +++ b/agents/bt_hcid.scr @@ -0,0 +1,39 @@ +/** + * File: bt_hcid.scr + * Summary: Agent for rading and writing of /etc/bluetooth/hcid.conf file + * Author: Ladislav Slezak + * Access: read, write + * + * $Id$ + * + * This file is based on dns_named.conf + */ +.bluetooth.hcid + +// TODO: INI agent isn't optimal, in this file multiple occurences of one key +// in one section may be possible, section on one line is handled as a +// single value, and many many other problems are to be expected.... +// should be replaced in future by some better agent + +`ag_ini( + `IniAgent( "/etc/bluetooth/hcid.conf", + $[ + "options" : [ "global_values", "repeat_names" ], + "comments" : [ "^[ \t]*#.*$", "^[ \t]*$" ], + "params" : [ + $[ "match" : [ "([^ \t]+)[ \t]([^ \t]+(.*[^ \t]+)+)[ \t]*;$", "%s %s;" ]], + // (...)* made the agent crash when it did not match, + // changed it to ((...)*), #39597 + // Still don't know why this is here at all + $[ "match" : [ "([^ \t]+)((.*[^ \t]+)*)[ \t]*\\{.*\\}[ \t]*;", "%s %s;" ]], + ], + "sections" : [ + $[ + "begin" : [ "[ \t]*([^ \t]+(.*[^ \t]+)*)[ \t]*\\{$", "%s {" ], + "end" : [ "^[ \t]*\\}", "}" ], + ], + ], + "subindent" : "\t" + ] +)) + diff --git a/agents/cfg_bluetooth.scr b/agents/cfg_bluetooth.scr new file mode 100644 index 0000000..51588ef --- /dev/null +++ b/agents/cfg_bluetooth.scr @@ -0,0 +1,19 @@ +/** + * File: + * cfg_bluetooth.scr + * Summary: + * SCR Agent for reading/writing /etc/sysconfig/bluetooth + * using the ini-agent + * Access: + * read/write + * Authors: + * Ladislav Slezak + * + * $Id$ + * + */ +.sysconfig.bluetooth + +`ag_ini( + `SysConfigFile("/etc/sysconfig/bluetooth") +) diff --git a/configure.in.in b/configure.in.in new file mode 100644 index 0000000..0a9d639 --- /dev/null +++ b/configure.in.in @@ -0,0 +1,12 @@ +## YCP module configure.in.in + +## Initialize +@YAST2-INIT-COMMON@ +@YAST2-INIT-YCP@ + +## some common checks +@YAST2-CHECKS-COMMON@ +@YAST2-CHECKS-YCP@ + +## and generate the output... +@YAST2-OUTPUT@ diff --git a/doc/.cvsignore b/doc/.cvsignore new file mode 100644 index 0000000..282522d --- /dev/null +++ b/doc/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/doc/Makefile.am b/doc/Makefile.am new file mode 100644 index 0000000..b522501 --- /dev/null +++ b/doc/Makefile.am @@ -0,0 +1,10 @@ +# Makefile.am for bluetooth/doc + +SUBDIRS = autodocs + +htmldir = $(docdir) + +doc_DATA = +html_DATA = + +EXTRA_DIST = $(doc_DATA) $(html_DATA) diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 0000000..cb59cbd --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,4 @@ +Makefile +Makefile.in +*.ybc +.dep diff --git a/src/Bluetooth.ycp b/src/Bluetooth.ycp new file mode 100644 index 0000000..bdb5dce --- /dev/null +++ b/src/Bluetooth.ycp @@ -0,0 +1,263 @@ +/** + * File: modules/Bluetooth.ycp + * Package: Configuration of bluetooth + * Summary: Bluetooth settings, input and output functions + * Authors: Ladislav Slezak + * + * $Id$ + * + * Representation of the configuration of bluetooth devices. + * Input and output routines. + */ + +{ + +module "Bluetooth"; +textdomain "bluetooth"; + +import "Progress"; +import "Report"; +import "Summary"; + +/** + * Prototypes + */ +global boolean Modified(); + +/** + * Data was modified? + */ +global boolean modified = false; + +/** + */ +global boolean proposal_valid = false; + +/** + * Write only, used during autoinstallation. + * Don't run services and SuSEconfig, it's all done at one place. + */ +global boolean write_only = false; + +/** + * Abort function + * return boolean return true if abort + */ +global boolean() AbortFunction = Modified; + +/** + * Abort function + * @return boolean return true if abort + */ +global define boolean Abort() ``{ + if(AbortFunction != nil) + { + return AbortFunction () == true; + } + return false; +} + +/** + * Data was modified? + * @return true if modified + */ +global boolean Modified() { + y2debug("modified=%1",modified); + return modified; +} + + +global boolean enabled = false; + +global boolean authentification = false; + +global boolean encryption = false; + +global list > daemons = []; + +global string pin = ""; + +/** + * Read all bluetooth settings + * @return true on success + */ +global boolean Read() { + + /* Bluetooth read dialog caption */ + string caption = _("Initializing bluetooth Configuration"); + + // TODO FIXME Set the right number of stages + integer steps = 4; + + integer sl = 0; + sleep(sl); + + // TODO FIXME Names of real stages + // We do not set help text here, because it was set outside + Progress::New( caption, " ", steps, [ + /* Progress stage 1/3 */ + _("Read the database"), + /* Progress stage 2/3 */ + _("Read the previous settings"), + /* Progress stage 3/3 */ + _("Detect the devices") + ], [ + /* Progress step 1/3 */ + _("Reading the database..."), + /* Progress step 2/3 */ + _("Reading the previous settings..."), + /* Progress step 3/3 */ + _("Detecting the devices..."), + /* Progress finished */ + _("Finished") + ], + "" + ); + + // read database + if(Abort()) return false; + Progress::NextStage(); + /* Error message */ + if(false) Report::Error(_("Cannot read the database1.")); + sleep(sl); + + // read another database + if(Abort()) return false; + Progress::NextStep(); + /* Error message */ + if(false) Report::Error(_("Cannot read the database2.")); + sleep(sl); + + // read current settings + if(Abort()) return false; + Progress::NextStage(); + /* Error message */ + if(false) Report::Error(_("Cannot read current settings.")); + sleep(sl); + + // detect devices + if(Abort()) return false; + Progress::NextStage(); + /* Error message */ + if(false) Report::Warning(_("Cannot detect devices.")); + sleep(sl); + + if(Abort()) return false; + /* Progress finished */ + Progress::NextStage(); + sleep(sl); + + if(Abort()) return false; + modified = false; + return true; +} + +/** + * Write all bluetooth settings + * @return true on success + */ +global boolean Write() { + + /* Bluetooth read dialog caption */ + string caption = _("Saving bluetooth Configuration"); + + // TODO FIXME And set the right number of stages + integer steps = 2; + + integer sl = 0; + sleep(sl); + + // TODO FIXME Names of real stages + // We do not set help text here, because it was set outside + Progress::New(caption, " ", steps, [ + /* Progress stage 1/2 */ + _("Write the settings"), + /* Progress stage 2/2 */ + _("Run SuSEconfig") + ], [ + /* Progress step 1/2 */ + _("Writing the settings..."), + /* Progress step 2/2 */ + _("Running SuSEconfig..."), + /* Progress finished */ + _("Finished") + ], + "" + ); + + // write settings + if(Abort()) return false; + Progress::NextStage(); + /* Error message */ + if(false) Report::Error (_("Cannot write settings.")); + sleep(sl); + + // run SuSEconfig + if(Abort()) return false; + Progress::NextStage (); + /* Error message */ + if(false) Report::Error (_("SuSEconfig script failed.")); + sleep(sl); + + if(Abort()) return false; + /* Progress finished */ + Progress::NextStage(); + sleep(sl); + + if(Abort()) return false; + return true; +} + +/** + * Get all bluetooth settings from the first parameter + * (For use by autoinstallation.) + * @param settings The YCP structure to be imported. + * @return boolean True on success + */ +global boolean Import (map settings) { + // TODO FIXME: your code here (fill the above mentioned variables)... + return true; +} + +/** + * Dump the bluetooth settings to a single map + * (For use by autoinstallation.) + * @return map Dumped settings (later acceptable by Import ()) + */ +global map Export () { + // TODO FIXME: your code here (return the above mentioned variables)... + return $[]; +} + +/** + * Create a textual summary and a list of unconfigured cards + * @return summary of the current configuration + */ +global list Summary() { + // TODO FIXME: your code here... + /* Configuration summary text for autoyast */ + return [ _("Configuration summary ..."), [] ]; +} + +/** + * Create an overview table with all configured cards + * @return table items + */ +global list Overview() { + // TODO FIXME: your code here... + return []; +} + +/** + * Return packages needed to be installed and removed during + * Autoinstallation to insure module has all needed software + * installed. + * @return map with 2 lists. + */ +global map AutoPackages() { + // TODO FIXME: your code here... + return $[ "install":[], "remove":[] ]; +} + +/* EOF */ +} diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..3d57376 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,24 @@ +# Makefile.am for bluetooth/src + +yncludedir = @yncludedir@/bluetooth + +client_DATA = \ + bluetooth.ycp \ + bluetooth_auto.ycp \ + bluetooth_proposal.ycp + +ynclude_DATA = \ + helps.ycp \ + wizards.ycp \ + dialogs.ycp \ + complex.ycp + +desktop_DATA = \ + bluetooth.desktop + +module_DATA = \ + Bluetooth.ycp + +EXTRA_DIST = $(client_DATA) $(ynclude_DATA) $(module_DATA) $(desktop_DATA) + +include $(top_srcdir)/Makefile.am.common diff --git a/src/bluetooth.desktop b/src/bluetooth.desktop new file mode 100644 index 0000000..311e2fe --- /dev/null +++ b/src/bluetooth.desktop @@ -0,0 +1,23 @@ +[Desktop Entry] +Type=Application +Categories=Qt;X-SuSE-YaST;X-SuSE-YaST-Misc; + +X-KDE-ModuleType=Library +X-KDE-RootOnly=true +X-KDE-HasReadOnlyMode=true +X-KDE-Library=yast2 +X-SuSE-YaST-Call=bluetooth + +X-SuSE-YaST-Group=Hardware +X-SuSE-YaST-Argument= +X-SuSE-YaST-RootOnly=true +X-SuSE-YaST-AutoInst= +X-SuSE-YaST-Geometry= +X-SuSE-YaST-SortKey= +X-SuSE-YaST-AutoInstResource=bluetooth + +Icon=bluetooth +Exec=/sbin/yast2 bluetooth + +Name=Bluetooth +GenericName=Bluetooth Configuration diff --git a/src/bluetooth.ycp b/src/bluetooth.ycp new file mode 100644 index 0000000..e8507cf --- /dev/null +++ b/src/bluetooth.ycp @@ -0,0 +1,74 @@ +/** + * File: clients/bluetooth.ycp + * Package: Configuration of bluetooth + * Summary: Main file + * Authors: Ladislav Slezak + * + * $Id$ + * + * Main file for bluetooth configuration. Uses all other files. + */ + +{ + +/*** + *

Configuration of bluetooth

+ */ + +textdomain "bluetooth"; + +/* The main () */ +y2milestone ("----------------------------------------"); +y2milestone ("Bluetooth module started"); + +import "Progress"; +import "Report"; +import "Summary"; +import "Bluetooth"; + +import "CommandLine"; +include "bluetooth/wizards.ycp"; + +map cmdline_description = $[ + "id" : "bluetooth", + /* Command line help text for the Xbluetooth module */ + "help" : _("Configuration of bluetooth"), + "guihandler" : BluetoothSequence, + "initialize" : Bluetooth::Read, + "finish" : Bluetooth::Write, + "actions" : $[ + // FIXME TODO: fill the functionality description here + ], + "options" : $[ + // FIXME TODO: fill the option descriptions here + ], + "mapping" : $[ + // FIXME TODO: fill the mappings of actions and options here + ] +]; + +/* is this proposal or not? */ +boolean propose = false; +list args = WFM::Args(); +if(size(args) > 0) { + if(is(WFM::Args(0), path) && WFM::Args(0) == .propose) { + y2milestone("Using PROPOSE mode"); + propose = true; + } +} + +/* main ui function */ +any ret = nil; + +if(propose) ret = BluetoothAutoSequence(); +else ret = CommandLine::Run(cmdline_description); +y2debug("ret=%1", ret); + +/* Finish */ +y2milestone("Bluetooth module finished"); +y2milestone("----------------------------------------"); + +return ret; + +/* EOF */ +} diff --git a/src/bluetooth_auto.ycp b/src/bluetooth_auto.ycp new file mode 100644 index 0000000..dec337a --- /dev/null +++ b/src/bluetooth_auto.ycp @@ -0,0 +1,98 @@ +/** + * File: clients/bluetooth_auto.ycp + * Package: Configuration of bluetooth + * Summary: Client for autoinstallation + * Authors: Ladislav Slezak + * + * $Id$ + * + * This is a client for autoinstallation. It takes its arguments, + * goes through the configuration and return the setting. + * Does not do any changes to the configuration. + */ + +/** + * @param function to execute + * @param map/list of bluetooth settings + * @return map edited settings, Summary or boolean on success depending on called function + * @example map mm = $[ "FAIL_DELAY" : "77" ]; + * @example map ret = WFM::CallFunction ("bluetooth_auto", [ "Summary", mm ]); + */ + +{ + +textdomain "bluetooth"; + +y2milestone("----------------------------------------"); +y2milestone("Bluetooth auto started"); + +import "Bluetooth"; +include "bluetooth/wizards.ycp"; + +any ret = nil; +string func = ""; +map param = $[]; + +/* Check arguments */ +if(size(WFM::Args()) > 0 && is(WFM::Args(0), string)) { + func = (string)WFM::Args(0); + if(size(WFM::Args()) > 1 && is(WFM::Args(1), map)) + param = (map) WFM::Args(1); +} +y2debug("func=%1", func); +y2debug("param=%1", param); + +/* Create a summary*/ +if(func == "Summary") { + ret = select(Bluetooth::Summary(), 0, ""); +} +/* Reset configuration */ +else if (func == "Reset") { + Bluetooth::Import($[]); + ret = $[]; +} +/* Change configuration (run AutoSequence) */ +else if (func == "Change") { + ret = BluetoothAutoSequence(); +} +/* Import configuration */ +else if (func == "Import") { + ret = Bluetooth::Import(param); +} +/* Return actual state */ +else if (func == "Export") { + ret = Bluetooth::Export(); +} +/* Return needed packages */ +else if (func == "Packages") { + ret = Bluetooth::AutoPackages(); +} +/* Read current state */ +else if (func == "Read") { + import "Progress"; + Progress::off(); + ret = Bluetooth::Read(); + Progress::on(); +} +/* Write givven settings */ +else if (func == "Write") { + import "Progress"; + Progress::off(); + Bluetooth::write_only = true; + ret = Bluetooth::Write(); + Progress::on(); +} +/* Unknown function */ +else { + y2error("Unknown function: %1", func); + ret = false; +} + +y2debug("ret=%1", ret); +y2milestone("Bluetooth auto finished"); +y2milestone("----------------------------------------"); + +return ret; + +/* EOF */ +} diff --git a/src/bluetooth_proposal.ycp b/src/bluetooth_proposal.ycp new file mode 100644 index 0000000..f4c8889 --- /dev/null +++ b/src/bluetooth_proposal.ycp @@ -0,0 +1,87 @@ +/** + * File: clients/bluetooth_proposal.ycp + * Package: Configuration of bluetooth + * Summary: Proposal function dispatcher. + * Authors: Ladislav Slezak + * + * $Id$ + * + * Proposal function dispatcher for bluetooth configuration. + * See source/installation/proposal/proposal-API.txt + */ + +{ + +textdomain "bluetooth"; + +import "Bluetooth"; +import "Progress"; + +/* The main () */ +y2milestone("----------------------------------------"); +y2milestone("Bluetooth proposal started"); + +string func = (string) WFM::Args(0); +map param = (map) WFM::Args(1); +map ret = $[]; + +/* create a textual proposal */ +if(func == "MakeProposal") { + string proposal = ""; + string warning = nil; + symbol warning_level = nil; + boolean force_reset = param["force_reset"]:false; + + if(force_reset || !Bluetooth::proposal_valid) { + Bluetooth::proposal_valid = true; + Progress::off(); + Bluetooth::Read(); + } + list sum = Bluetooth::Summary(); + proposal = sum[0]:""; + Progress::on(); + + ret = $[ + "preformatted_proposal" : proposal, + "warning_level" : warning_level, + "warning" : warning, + ]; +} +/* run the module */ +else if(func == "AskUser") { + map stored = Bluetooth::Export(); + symbol seq = (symbol) WFM::CallFunction("bluetooth", [.propose]); + if(seq != `next) Bluetooth::Import(stored); + y2debug("stored=%1",stored); + y2debug("seq=%1",seq); + ret = $[ + "workflow_sequence" : seq + ]; +} +/* create titles */ +else if(func == "Description") { + ret = $[ + /* Rich text title for Bluetooth in proposals */ + "rich_text_title" : _("Bluetooth"), + /* Menu title for Bluetooth in proposals */ + "menu_title" : _("&Bluetooth"), + "id" : "bluetooth", + ]; +} +/* write the proposal */ +else if(func == "Write") { + Bluetooth::Write(); +} +/* unknown function */ +else { + y2error("unknown function: %1", func); +} + +/* Finish */ +y2debug("ret=%1",ret); +y2milestone("Bluetooth proposal finished"); +y2milestone("----------------------------------------"); +return ret; + +/* EOF */ +} diff --git a/src/complex.ycp b/src/complex.ycp new file mode 100644 index 0000000..3a5da12 --- /dev/null +++ b/src/complex.ycp @@ -0,0 +1,61 @@ +/** + * File: include/bluetooth/complex.ycp + * Package: Configuration of bluetooth + * Summary: Dialogs definitions + * Authors: Ladislav Slezak + * + * $Id$ + */ + +{ + +textdomain "bluetooth"; + +import "Label"; +import "Popup"; +import "Wizard"; +import "Wizard_hw"; +import "Bluetooth"; + +include "bluetooth/helps.ycp"; + +/** + * Return a modification status + * @return true if data was modified + */ +boolean Modified() { + return Bluetooth::Modified(); +} + +boolean ReallyAbort() { + return !Bluetooth::Modified() || Popup::ReallyAbort(true); +} + +boolean PollAbort() { + return UI::PollInput() == `abort; +} + +/** + * Read settings dialog + * @return `abort if aborted and `next otherwise + */ +symbol ReadDialog() { + Wizard::RestoreHelp(HELPS["read"]:""); + // Bluetooth::AbortFunction = PollAbort; + boolean ret = Bluetooth::Read(); + return ret ? `next : `abort; +} + +/** + * Write settings dialog + * @return `abort if aborted and `next otherwise + */ +symbol WriteDialog() { + Wizard::RestoreHelp(HELPS["write"]:""); + // Bluetooth::AbortFunction = PollAbort; + boolean ret = Bluetooth::Write(); + return ret ? `next : `abort; +} + +/* EOF */ +} diff --git a/src/dialogs.ycp b/src/dialogs.ycp new file mode 100644 index 0000000..7d2d887 --- /dev/null +++ b/src/dialogs.ycp @@ -0,0 +1,306 @@ +/** + * File: include/bluetooth/dialogs.ycp + * Package: Configuration of bluetooth + * Summary: Dialogs definitions + * Authors: Ladislav Slezak + * + * $Id$ + */ + +{ + +textdomain "bluetooth"; + +import "Label"; +import "Wizard"; +import "Bluetooth"; + +include "bluetooth/helps.ycp"; + +/** + * Show global settings dialog - enable/disable bluetooth support, some global general options + * @return symbol dialog result + */ +symbol GlobalOptionsDialog () { + + /* Bluetooth global settings dialog caption */ + string caption = _("Bluetooth Configuration"); + + /* Bluetooth global settings dialog content */ + term contents = `RadioButtonGroup(`id(`rb), + `HBox( + `HSpacing(3), + `VBox( + `Left(`RadioButton(`id(`BTenable), _("&Disable Bluetooth services"))), + `VSpacing(1), + `Left(`RadioButton(`id(`BTdisable), _("&Enable Bluetooth services"))), + `VSpacing(0.5), + + `HBox( + `HSpacing(4), + `Frame(_("Basic configuration"), + `VBox( + `Left(`Password(`id(`pin), _("I&dentification number (PIN)"))) + ) + ), + `HSpacing(1) + ), + + `VSpacing(1), + `PushButton(`id(`services), _("Advanced &Daemon Configuration...")), + `VSpacing(0.5), + `PushButton(`id(`security), _("&Security Options...")) + ) + ) + ); + + Wizard::SetContentsButtons(caption, contents, HELPS["global"]:"", + Label::BackButton(), Label::FinishButton()); + + Wizard::HideBackButton(); + Wizard::SetAbortButton(`abort, Label::CancelButton()); + + // allow only numbers in PIN widget + UI::ChangeWidget(`id(`pin), `ValidChars, "0132456789"); + + symbol ret = nil; + + while (true) { + + ret = (symbol) UI::UserInput(); + + /* abort? */ + if (ret == `abort || ret == `cancel) { + if (ReallyAbort()) break; + else continue; + } + else if (ret == `next || ret == `back || ret == `security || ret == `services) { + break; + } + else { + y2error("unexpected retcode: %1", ret); + continue; + } + } + + Wizard::RestoreBackButton(); + Wizard::RestoreAbortButton(); + + return ret; +} + +/** + * Dialog for expert configuration of the selected bluetooth daemon. + * @return map dialog result + */ +map DaemonExpertPopup(string daemon, string arguments) { + + /* Dialog caption - daemon configuration */ + string caption = sformat(_("%1 Daemon Configuration"), daemon); + + term pand_option = `VBox( + `VSpacing(1), + `RadioButtonGroup(`id(`rbg), + `VBox( + `Left(`RadioButton(`id(`listen), _("Set network dameon to &listen mode"))), + `VSpacing(0.2), + `Left(`RadioButton(`id(`search), _("Set network daemon to &search mode"))), + `VSpacing(0.2), + `Left(`RadioButton(`id(`other), _("&Other settings"))) + ) + ) + ); + + /* Daemon configuration dialog content */ + term contents = `VBox( + `Heading(caption), + (daemon == "PAND") ? pand_option : `Empty(), + `HBox( + (daemon == "PAND") ? `HSpacing(3) : `HSpacing(1), + `TextEntry(`id(`args), _("&Daemon Arguments"), arguments), + `HSpacing(1) + ), + `VSpacing(1), + `HBox( + `HStretch(), + `HWeight(1, `PushButton(`id(`ok), `opt(`key_F10, `default), Label::OKButton())), + `HSpacing(2), + `HWeight(1, `PushButton(`id(`cancel), `opt(`key_F9), Label::CancelButton())), + `HStretch() + ) + ); + + UI::OpenDialog(contents); + + UI::SetFocus(`id(`ok)); + + symbol ret = nil; + + while (true) { + ret = (symbol) UI::UserInput(); + + if (ret == `ok || ret == `cancel) { + break; + } + else { + y2error("unexpected retcode: %1", ret); + continue; + } + } + + map r = $[ "ret" : ret]; + + if (ret == `ok) + { + string text = (string) UI::QueryWidget(`id(`args), `Value); + r = add(r, "text", text); + } + + UI::CloseDialog(); + + return r; +} + +/** + * Dialog for configuration bluetooth daemons. + * @return symbol dialog result + */ +symbol DaemonDialog () { + + /* caption in bluetooth services configuration dialog */ + string caption = _("Bluetooth Daemon Configuration"); + + list table = [`item(`id(`HCID), "HCID", "yes", "HCI Daemon descriptive summary..."), + `item(`id(`SDP), "SDP", "yes", "SDP Daemon"), + `item(`id(`OPD), "OPD", "yes", "OPD Daemon"), + `item(`id(`RFCOMM), "RFCOMM", "yes", "RFCOMM Daemon"), + `item(`id(`PAND), "PAND", "yes", "PAND Daemon"), + `item(`id(`DUND), "DUND", "yes", "DUND Daemon"), + `item(`id(`HID), "HID", "yes", "HID Daemon"), + `item(`id(`HID2HCI), "HID2HCI", "yes", "HID2HCI Daemon"), + ]; + + /* Bluetooth configuration dialog content */ + term contents = `VBox( + `Left(`Label(_("Current Available Daemons:"))), + `Table(`id(`daemons), `header(_("Daemon"), _("Enabled"), _("Description")), table), + `VSpacing(0.5), + `HBox( + `PushButton(`id(`enable), _("&Enable")), + `PushButton(`id(`disable), _("&Disable")), + `HSpacing(2), + `PushButton(`id(`expert), _("E&dit...")), + `HStretch() + ), + `VSpacing(1) + ); + + Wizard::SetContentsButtons(caption, contents, HELPS["daemon"]:"", + Label::BackButton(), Label::OKButton()); + + symbol ret = nil; + + while (true) { + ret = (symbol) UI::UserInput(); + + /* abort? */ + if (ret == `abort || ret == `cancel) { + if (ReallyAbort()) break; + else continue; + } + else if (ret == `enable || ret == `disable) + { + // TODO handle buttons + } + else if (ret == `next || ret == `back) { + break; + } + else if (ret == `expert) + { + DaemonExpertPopup("PAND", "-a -b -c"); + } + else { + y2error("unexpected retcode: %1", ret); + continue; + } + } + + return ret; +} + + +/** + * Dialog for configuration bluetooth daemons. + * @return symbol dialog result + */ +symbol SecurityDialog () { + + /* caption in bluetooth services configuration dialog */ + string caption = _("Security options"); + + + /* Bluetooth configuration dialog content */ + term contents = `HBox( + `HSpacing(3), + `VBox( + `VSpacing(1), + `Frame(_("Authentification and Encryption"), + `VBox( + `VSpacing(0.2), + `Left(`CheckBox(`id(`auth), _("&Enable Authentification"))), + `VSpacing(0.5), + `Left(`CheckBox(`id(`encrypt), _("Enable En&cryption"))), + `VSpacing(0.2) + ) + ), + `VSpacing(2), + `Frame(_("Scan Options"), + `VBox( + `VSpacing(0.2), + `Left(`CheckBox(`id(`inq), _("Enable &Inquiry Scan"))), + `VSpacing(0.5), + `Left(`CheckBox(`id(`page), _("Enable &Page Scan"))), + `VSpacing(0.2) + ) + ), + `VSpacing(1) + ), + `HSpacing(3) + ); + + Wizard::SetContentsButtons(caption, contents, HELPS["security"]:"", + Label::BackButton(), Label::OKButton()); + + symbol ret = nil; + + while (true) { + ret = (symbol) UI::UserInput(); + + /* abort? */ + if (ret == `abort || ret == `cancel) { + if (ReallyAbort()) break; + else continue; + } + else if (ret == `enable || ret == `disable) + { + // TODO handle buttons + } + else if (ret == `next || ret == `back) { + break; + } + else if (ret == `expert) + { + DaemonExpertPopup("HCID", "-a -b -c"); + } + else { + y2error("unexpected retcode: %1", ret); + continue; + } + } + + return ret; +} + + +/* EOF */ +} diff --git a/src/helps.ycp b/src/helps.ycp new file mode 100644 index 0000000..1eab673 --- /dev/null +++ b/src/helps.ycp @@ -0,0 +1,117 @@ +/** + * File: include/bluetooth/helps.ycp + * Package: Configuration of bluetooth + * Summary: Help texts of all the dialogs + * Authors: Ladislav Slezak + * + * $Id$ + */ + +{ + +textdomain "bluetooth"; + +/** + * All helps are here + */ +map HELPS = $[ + + /* Read dialog help 1/2 */ + "read" : _("

Initializing bluetooth Configuration
+Please wait...

+") + + + /* Read dialog help 2/2 */ + _("

Aborting Initialization:
+Safely abort the configuration utility by pressing Abort now.

+"), + + /* Write dialog help 1/2 */ + "write" : _("

Saving bluetooth Configuration
+Please wait...

+") + + + /* Write dialog help 2/2 */ +_("

Aborting Saving:
+Abort the save procedure by pressing Abort. +An additional dialog informs whether it is safe to do so. +

+"), + + + /* Help text for global settings dialog */ + "global" : _("

Configure Bluetooth support

") + + +_("

If you enable Bluetooth support, the Bluetooth system will be started +automatically by the hotplug system after a Bluetooth adapter is found in your +computer.

") + + +_("

Which services (or Profiles as they are called in Bluetooth) are available +when the Bluetooth system is started is assigned in Advanced Daemon Configuration.

") + + +_("

Some devices require a PIN for identification. Usually this is a four or +five digit number. If no PIN is required choose '00000'.

"), + + + /* Help text for service configuration dialog */ + "daemon" : _("

Daemon Configuration

") + + +_("

The daemons here provide various services. If you want to change daemon +settings press Edit button.

") + + +_("

HCID - The Host Controller Interface Daemon manages all Bluetooth +devices in your computer.

") + + +_("

SDPD - The Service Discovery Protocol Daemon is needed from remote devices to +find out which bluetooth-services are available on your computer. The other +daemons connect to this one.

") + + +_("

OPD - The OBEX Push Daemon is needed if you want to e.g. transfer files from a device +onto your computer.

") + + +_("

RFCOMM - It's a Serial Cable Emulation Protocol needed for some devices and +services. It's not a 'real' daemon, but a process configuring the existing +bluetooth-devices.

") + + +_("

PAND - The Personal Area Network Daemon is used to create +networks using Bluetooth. It creates a kind of 'wireless ethernet'-network.

") + + +_("

DUND - The Dial-Up networking daemon allows to have LAN access over +PPP. You need it if you have a Bluetooth-modem.

") + + +_("

HID - The Human Interface Device Profil is used for devices like +keyboard and mouse.

") + + +_("

HID2HCI - This is actually no 'real' daemon, but a help-util to switch +a HID-adapter into HCI-mode (or vice versa). Normally you shouldn't need it.

"), + + /* Help text for detailed service configuration dialog */ + "security" : _("

Security Options

") + + +_("

To enhance security you should enable Authentification and Encryption.

") + + +_("

Encryption can only be done if authentification is enabled. Activating both +enhances security a little bit, but you often run into problems if you do so: +Not all devices support encryption. If you have problems connecting to a remote +device, try it with encryption disabled.

") + + +_("

With Inquiry Scan option you can decide if remote devices detect your +adapter when scanning for available devices.

") + + +_("

Enabled Page Scan option allows remote devices to connect to your device.

") + +]; + +map daemon_descriptions = $[ + "HCID" : _("Bluetooth device manager"), + "SDPD" : _("Device annoucement"), + "OPD" : _("File transfer service"), + "RFCOMM" : _("Serial cable emulation"), + "PAND" : _("Network connection"), + "DUND" : _("Dial-up connection"), + "HID" : _("Input device support (keyboard, mouse)"), + "HID2HCI" : _("Use HID device in HCID mode") +]; + +/* EOF */ +} diff --git a/src/wizards.ycp b/src/wizards.ycp new file mode 100644 index 0000000..98055c5 --- /dev/null +++ b/src/wizards.ycp @@ -0,0 +1,106 @@ +/** + * File: include/bluetooth/wizards.ycp + * Package: Configuration of bluetooth + * Summary: Wizards definitions + * Authors: Ladislav Slezak + * + * $Id$ + */ + +{ + +textdomain "bluetooth"; + +import "Sequencer"; +import "Wizard"; + +include "bluetooth/complex.ycp"; +include "bluetooth/dialogs.ycp"; + +/** + * Main workflow of the bluetooth configuration + * @return sequence result + */ +any MainSequence() { + + // sequencer aliases + map aliases = $[ + "global" : ``(GlobalOptionsDialog()), + "services" : ``(DaemonDialog()), + "security" : ``(SecurityDialog()) + ]; + + // sequence of dialogs + map sequence = $[ + "ws_start" : "global", + "global" : $[ + `services : "services", + `security : "security", + `abort : `abort, + `next : `next + ], + "services" : $[ + `next : "global", + `abort : `abort + ], + "security" : $[ + `next : "global", + `abort : `abort + ] + ]; + + return Sequencer::Run(aliases, sequence); +} + +/** + * Whole configuration of bluetooth + * @return sequence result + */ +any BluetoothSequence() { + + map aliases = $[ + "read" : [ ``( ReadDialog() ), true ], + "main" : ``( MainSequence() ), + "write" : [ ``( WriteDialog() ), true ] + ]; + + map sequence = $[ + "ws_start" : "read", + "read" : $[ + `abort : `abort, + `next : "main" + ], + "main" : $[ + `abort : `abort, + `next : "write" + ], + "write" : $[ + `abort : `abort, + `next : `next + ] + ]; + + Wizard::CreateDialog(); + + any ret = Sequencer::Run(aliases, sequence); + + UI::CloseDialog(); + return ret; +} + +/** + * Whole configuration of bluetooth but without reading and writing. + * For use with autoinstallation. + * @return sequence result + */ +any BluetoothAutoSequence() { + + Wizard::CreateDialog(); + any ret = MainSequence(); + + UI::CloseDialog(); + return ret; +} + +/* EOF */ +} diff --git a/testsuite/.cvsignore b/testsuite/.cvsignore new file mode 100644 index 0000000..24f1e26 --- /dev/null +++ b/testsuite/.cvsignore @@ -0,0 +1,11 @@ +Makefile +Makefile.in +site.exp +*.sum +*.log +tmp.out* +tmp.err* +tmp.log* +config +run +*.test diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am new file mode 100644 index 0000000..d9b12b0 --- /dev/null +++ b/testsuite/Makefile.am @@ -0,0 +1,21 @@ +# +# Makefile.am for .../testsuite +# +# Do not edit this file (Makefile.am) as it will be overwritten! +# + +AUTOMAKE_OPTIONS = dejagnu +EXTRA_DIST = $(wildcard tests/*.out) $(wildcard tests/*.err) $(wildcard tests/*.ycp) $(wildcard tests/*.yh) + +testsuite_prepare = @ydatadir@/testsuite/Makefile.testsuite + +all-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) + +clean-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) clean + +check-local: $(testsuite_prepare) + make -f $(testsuite_prepare) RPMNAME=$(RPMNAME) srcdir=$(srcdir) check + +# EOF diff --git a/yast2-bluetooth.spec.in b/yast2-bluetooth.spec.in new file mode 100644 index 0000000..3adcda9 --- /dev/null +++ b/yast2-bluetooth.spec.in @@ -0,0 +1,32 @@ +@HEADER-COMMENT@ +# neededforbuild yast2-devel-packages + +@HEADER@ +Requires: yast2 + +BuildArchitectures: noarch + +Summary: Bluetooth configuration module + +%description +- + +@PREP@ + +@BUILD@ + +@INSTALL@ + +@CLEAN@ + +%files +%defattr(-,root,root) +%dir @yncludedir@/bluetooth +@yncludedir@/bluetooth/* +@clientdir@/bluetooth.ycp +@clientdir@/bluetooth_*.ycp +@moduledir@/Bluetooth.* +@scrconfdir@/bt_hcid.scr +@scrconfdir@/cfg_bluetooth.scr +@desktopdir@/bluetooth.desktop +%doc @docdir@