home *** CD-ROM | disk | FTP | other *** search
- /**************
- FILE : x11_proposal.ycp
- ***************
- PROJECT : YaST2
- :
- AUTHOR : Marcus Schäfer <ms@suse.de>
- :
- BELONGS TO : YaST2
- : (X11 integration part using SaX2/ISaX)
- :
- DESCRIPTION : Proposal function dispatcher for
- : X11 configuration
- :
- :
- STATUS : Development
- **************/
- /**
- * File: proposal/x11_proposal.ycp
- * Package: X11 Configuration
- * Summary: Installation Proposal for X11 stuff
- * Authors: Marcus Schaefer <ms@suse.de>
- *
- */
- {
- textdomain "x11";
-
- import "Report";
- import "Installation";
- import "Arch";
- import "Confirm";
- import "XMessages";
- import "XLib";
- import "Package";
-
- include "x11/x11Dialog.ycp";
-
- //===================================================
- // Initialize proposal parameters
- //---------------------------------------------------
- string func = (string) WFM::Args(0);
- map param = (map) WFM::Args(1);
- map ret = $[];
-
- //==========================================
- // Check for installed packages...
- //------------------------------------------
- if (
- (Arch::x11_setup_needed ()) ||
- (Installation::x11_setup_needed ())
- ) {
- list<string> requiredPacs = [
- "xorg-x11", "xorg-x11-server","xorg-x11-server-glx","libusb",
- "sax2", "sax2-gui", "sax2-ident", "sax2-tools","sax2-libsax",
- "sax2-libsax-perl"
- ];
-
- // remove unavailable packages
- requiredPacs = filter(string pac, requiredPacs, {return Pkg::PkgProperties(pac) != nil;} );
-
- y2milestone("required X11 packages: %1", requiredPacs);
-
- boolean package = Package::InstallAllMsg (
- requiredPacs, XMessages::pacsMissing
- );
- y2milestone ("x11 package status is: <%1>",package);
- if (! package) {
- return $[];
- }
- }
- //===================================================
- // Handle Arch flag
- //---------------------------------------------------
- if (
- (! Arch::x11_setup_needed ()) ||
- (! Installation::x11_setup_needed ()) ||
- (! Package::Installed ("sax2-gui"))
- ) {
- if ( func != "Description" ) {
- ret = $[
- "rich_text_title" : "",
- "menu_title" : "",
- "id" : "",
- "preformatted_proposal" : "<b> </b>",
- "success" : true
- ];
- return ret;
- } else {
- return ret;
- }
- }
- //===================================================
- // Create proposal for installation/configuration...
- //---------------------------------------------------
- if ( func == "MakeProposal" ) {
- //======================================
- // Initialize library cache
- //--------------------------------------
- if (! (boolean)XLib::isInitialized()) {
- y2milestone ("Loading library cache...");
- XLib::loadApplication();
- }
- //======================================
- // Reading library cache data
- //--------------------------------------
- y2milestone ("Reading libsax cache data...");
- string resolution = (string) XLib::getActiveResolution();
- string colorDepth = (string) XLib::getActiveColorDepth();
- string cardName = (string) XLib::getCardName();
- string monitorName = (string) XLib::getMonitorName();
- boolean has3D = (boolean) XLib::hasOpenGLFeatures();
- boolean is3DCard = (boolean) XLib::has3DCapabilities();
- boolean isNoteBook = (boolean) XLib::isExternalVGANoteBook();
- boolean isNoteBookHW= (boolean) XLib::isNoteBookHardware();
- boolean extVGAactive= (boolean) XLib::isExternalVGAactive();
- list monitorSize = (list) XLib::getDisplaySize();
- string monitorInch = (string) monitorSize[0]:"undef";
-
- //======================================
- // Prepare proposal
- //--------------------------------------
- string UL = "<ul>";
- string LU = "</ul>";
- string LI = "<li>";
- string IL = "</li>";
- string proposal = "";
- string colorCount = "";
- if (colorDepth == "24") {
- colorCount = "16.7 Mio. " + XMessages::colors;
- }
- if (colorDepth == "16") {
- colorCount = "65536 " + XMessages::colors;
- }
- if (colorDepth == "15") {
- colorCount = "32768 " + XMessages::colors;
- }
- if (colorDepth == "8") {
- colorCount = "256 " + XMessages::colors;
- }
- if (monitorName == "undef") {
- monitorName = XMessages::unconfigured;
- }
- //======================================
- // Create proposal
- //--------------------------------------
- proposal = UL;
- //======================================
- // Graphics card name...
- //--------------------------------------
- proposal = proposal
- + LI
- + XMessages::graphicsCard + cardName
- + IL;
- //======================================
- // Monitor name and resolution...
- //--------------------------------------
- if (monitorInch == "undef") {
- proposal = proposal
- + LI
- + XMessages::monitor + "<a href=\"sax-monitor\">"
- + monitorName + "</a> " + "(<a href=\"sax-displaysize\">"
- + XMessages::Aspect + " " + XMessages::unconfigured + "</a>)"
- + " - (<a href=\"sax-resolution\">" + resolution + "</a>)"
- + IL;
- } else {
- proposal = proposal
- + LI
- + XMessages::monitor + "<a href=\"sax-monitor\">"
- + monitorName + "</a> " + "(<a href=\"sax-displaysize\">"
- + monitorSize[0]:"" + " " + XMessages::Inches + ", "
- + XMessages::Aspect + " " + monitorSize[1]:"" + ":"
- + monitorSize[2]:"" + "</a>)" + " - (<a href=\"sax-resolution\">"
- + resolution + "</a>)"
- + IL;
- }
- //======================================
- // Colordepth and number of colors...
- //--------------------------------------
- proposal = proposal
- + LI
- + XMessages::colorDepth + "<a href=\"sax-colors\">"
- + colorDepth + "</a> Bit (" + colorCount + ")"
- + IL;
- //======================================
- // 3D acceleration status/availability
- //--------------------------------------
- if (is3DCard) {
- string status = XMessages::deactivated;
- if (has3D) {
- status = XMessages::activated;
- }
- proposal = proposal
- + LI
- + XMessages::acceleration + "<a href=\"sax-3d\">"
- + status + "</a>"
- + IL;
- }
- //======================================
- // External VGA on NoteBooks
- //--------------------------------------
- if (isNoteBook) {
- string status = XMessages::deactivated;
- if (extVGAactive) {
- status = XMessages::activated;
- }
- proposal = proposal
- + LI
- + XMessages::externalvga + "<a href=\"sax-ext-vga\">"
- + status + "</a>"
- + IL;
- } else {
- if ((isNoteBookHW) && (! XMessages::popupDone)) {
- XMessages::popupDone = true;
- y2milestone ("X11: DualHead Mode not supported with this NoteBook");
- //warnNoteBookPopup();
- }
- }
- //======================================
- // Test your configuration now
- //--------------------------------------
- proposal = proposal
- + LI
- + "<a href=\"sax-test\">"
- + XMessages::testConfig + "</a>"
- + IL;
- //======================================
- // End proposal...
- //--------------------------------------
- proposal = proposal + LU;
- ret = $[
- "preformatted_proposal" : proposal,
- "links" : [
- "sax-monitor",
- "sax-resolution",
- "sax-displaysize",
- "sax-colors",
- "sax-3d",
- "sax-ext-vga",
- "sax-test"
- ]
- ];
- return ret;
- }
- //===================================================
- // Handle user requests...
- //---------------------------------------------------
- else if ( func == "AskUser" ) {
- any chosenID = param["chosen_id"]:nil;
- if (chosenID == "sax-monitor") {
- y2milestone("X11: setup monitor...");
- string vendor = XLib::getMonitorVendor();
- string model = XLib::getMonitorModel();
- map<string,list> cdb = XLib::getMonitorCDB();
- list selectedMonitor = setupMonitor ( cdb,vendor,model );
- y2milestone("X11: setup monitor <%1>",selectedMonitor);
- XLib::setMonitorCDB ( (list<string>)selectedMonitor );
- }
- if (chosenID == "sax-resolution") {
- y2milestone("X11: setup resolution...");
- string selectedRes = setupResolutions (
- XLib::getAvailableResolutionNames(),
- XLib::getActiveResolutionString()
- );
- y2milestone("X11: setup resolution <%1>",selectedRes);
- XLib::setResolution ( selectedRes );
- }
- if (chosenID == "sax-displaysize") {
- y2milestone("X11: setup displaysize...");
- list<string> currentSize = XLib::getDisplaySize();
- list<string> selectedSize = setupDisplaySize (
- currentSize[0]:"15",
- currentSize[1]:"4" + "/" + currentSize[2]:"3"
- );
- y2milestone("X11: setup displaysize <%1>",selectedSize);
- XLib::setDisplaySize ( selectedSize );
- }
- if (chosenID == "sax-colors") {
- y2milestone("X11: setup color depth...");
- string depth = XLib::getActiveColorDepth();
- string colstr = "256 [ 8 bit ]";
- if (depth == "15") {
- colstr = "32768 [ 15 bit ]";
- }
- if (depth == "16") {
- colstr = "65536 [ 16 bit ]";
- }
- if (depth == "24") {
- colstr = "16.7 Mio. [ 24 Bit ]";
- }
- string selectedColor = setupColors ( colstr );
- y2milestone("X11: setup color depth <%1>",selectedColor);
- XLib::setDefaultColorDepth ( selectedColor );
- }
- if (chosenID == "sax-3d") {
- y2milestone("X11: setup 3D...");
- boolean has3D = XLib::hasOpenGLFeatures();
- y2milestone("X11: setup 3D <%1>",has3D);
- if (! has3D) {
- XLib::activate3D();
- } else {
- XLib::deactivate3D();
- }
- }
- if (chosenID == "sax-ext-vga") {
- y2milestone("X11: setup external VGA...");
- boolean extVGAactive = XLib::isExternalVGAactive();
- y2milestone("X11: setup external VGA <%1>",extVGAactive);
- if (! extVGAactive) {
- XLib::activateExternalVGA();
- } else {
- XLib::deactivateExternalVGA();
- }
- }
- if (chosenID == "sax-test") {
- y2milestone("X11: running a test server now...");
- boolean testStatus = XLib::testConfiguration();
- y2milestone("X11: test run returns <%1>",testStatus);
- y2milestone("X11: refer to /var/log/Xorg.99.log for details");
- }
- if (chosenID == "x11_conf") {
- infoPopup();
- }
- }
- //===================================================
- // Handle proposal description...
- //---------------------------------------------------
- else if ( func == "Description" ) {
- ret = $[
- "rich_text_title" : XMessages::proposalTitle,
- "menu_title" : XMessages::proposalMenuTitle,
- "id" : "x11_conf"
- ];
- }
- //===================================================
- // writing configuration
- //---------------------------------------------------
- else if ( func == "Write" ) {
- boolean success = XLib::writeConfiguration();
- ret = $[ "success" : success ];
- }
- return ret;
- }
-