desktop.cpp

00001 /**************
00002 FILE          : desktop.cpp
00003 ***************
00004 PROJECT       : SaX2 - library interface
00005               :
00006 AUTHOR        : Marcus Schäfer <ms@suse.de>
00007               :
00008 BELONGS TO    : SaX2 - SuSE advanced X11 configuration 
00009               : 
00010               :
00011 DESCRIPTION   : native C++ class library to access SaX2
00012               : functionality. Easy to use interface for
00013               : //.../
00014               : - importing/exporting X11 configurations
00015               : - modifying/creating X11 configurations 
00016               : ---
00017               :
00018               :
00019 STATUS        : Status: Development
00020 **************/
00021 #include "desktop.h"
00022 
00023 namespace SaX {
00024 //====================================
00025 // Constructor...
00026 //------------------------------------
00027 SaXManipulateDesktop::SaXManipulateDesktop (
00028         SaXImport* desktop, SaXImport* card , SaXImport* path, int desktopID
00029 ) {
00030         // .../
00033         // ----
00034         if ( (! desktop) || (! card) ) {
00035                 excNullPointerArgument ();
00036                 qError (errorString(),EXC_NULLPOINTERARGUMENT);
00037                 return;
00038         }
00039         if ( desktop->getSectionID() != SAX_DESKTOP ) {
00040                 excDesktopImportBindFailed ( desktop->getSectionID() );
00041                 qError (errorString(),EXC_DESKTOPIMPORTBINDFAILED);
00042                 return;
00043         }
00044         if ( card->getSectionID() != SAX_CARD ) {
00045                 excCardImportBindFailed ( card->getSectionID() );
00046                 qError (errorString(),EXC_CARDIMPORTBINDFAILED);
00047                 return;
00048         }
00049         if ( path->getSectionID() != SAX_PATH ) {
00050                 excPathImportBindFailed ( path->getSectionID() );
00051                 qError (errorString(),EXC_PATHIMPORTBINDFAILED);
00052                 return;
00053         }
00054         mDesktopID = desktopID;
00055         mDesktop   = desktop;
00056         mCard      = card;
00057         mPath      = path;
00058         mDesktop -> setID ( mDesktopID );
00059         mCard    -> setID ( mDesktopID );
00060         mPath    -> setID ( 0 );
00061         mCDBMonitors = 0;
00062 }
00063 
00064 //====================================
00065 // set desktop ID
00066 //------------------------------------
00067 bool SaXManipulateDesktop::selectDesktop (int desktop) {
00068         // .../
00071         // ----
00072         if ((! mDesktop) || (! mCard) || (! mPath)) {
00073                 return false;
00074         }
00075         if ( (mDesktop->setID (desktop)) && (mCard->setID (desktop)) ) {
00076                 mDesktopID = desktop;
00077                 return true;
00078         }
00079         return false;
00080 }
00081 
00082 //====================================
00083 // calculateModelines
00084 //------------------------------------
00085 void SaXManipulateDesktop::calculateModelines (bool calc) {
00086         // .../
00090         // ----
00091         if ((! mDesktop) || (! mCard) || (! mPath)) {
00092                 return;
00093         }
00094         QString val ("no");
00095         if (calc) {
00096                 val = "on";
00097         }
00098         mDesktop -> setItem ( "CalcModelines",val );
00099 }
00100 
00101 //====================================
00102 // setResolution
00103 //------------------------------------
00104 void SaXManipulateDesktop::setResolution (int c,int x,int y) {
00105         // .../
00108         // ----
00109         if ((! mDesktop) || (! mCard) || (! mPath)) {
00110                 return;
00111         }
00112         QString key;
00113         QString val;
00114         key.sprintf ("Modes:%d",c);
00115         val.sprintf ("%dx%d",x,y);
00116         mDesktop -> setItem ( key,val );
00117 }
00118 
00119 //====================================
00120 // addResolution
00121 //------------------------------------
00122 void SaXManipulateDesktop::addResolution (int c,int x,int y) {
00123         // .../
00126         // ----
00127         if ((! mDesktop) || (! mCard) || (! mPath)) {
00128                 return;
00129         }
00130         QString key;
00131         QString val;
00132         key.sprintf ("Modes:%d",c);
00133         if (! mDesktop -> getItem (key).isEmpty()) {
00134                 val = mDesktop -> getItem (key);
00135         }
00136         QTextOStream (&val) << val << "," << x << "x" << y;
00137         val.replace (QRegExp("^,"),"");
00138         mDesktop -> setItem ( key,val );
00139 }
00140 
00141 //====================================
00142 // removeResolution
00143 //------------------------------------
00144 void SaXManipulateDesktop::removeResolution (int c,int x,int y) {
00145         // .../
00148         // ----
00149         if ((! mDesktop) || (! mCard) || (! mPath)) {
00150                 return;
00151         }
00152         QString key;
00153         QString val;
00154         key.sprintf ("Modes:%d",c);
00155         val.sprintf ("%dx%d",x,y);
00156         if (! mDesktop -> getItem (key).isEmpty()) {
00157                 mDesktop -> removeItem (key,val);
00158         }
00159 }
00160 
00161 //====================================
00162 // setVirtualResolution
00163 //------------------------------------
00164 void SaXManipulateDesktop::setVirtualResolution (int c,int x,int y) {
00165         // .../
00168         // ----
00169         if ((! mDesktop) || (! mCard) || (! mPath)) {
00170                 return;
00171         }
00172         QString key;
00173         QString val;
00174         key.sprintf ("Virtual:%d",c);
00175         val.sprintf ("%d %d",x,y);
00176         mDesktop -> setItem ( key,val );
00177 }
00178 
00179 //====================================
00180 // removeVirtualResolution
00181 //------------------------------------
00182 void SaXManipulateDesktop::removeVirtualResolution (int c) {
00183         // .../
00186         // ----
00187         if ((! mDesktop) || (! mCard) || (! mPath)) {
00188                 return;
00189         }
00190         QString key;
00191         key.sprintf ("Virtual:%d",c);
00192         if (! mDesktop -> getItem (key).isEmpty()) {
00193                 mDesktop -> setItem (key,"");
00194         }
00195 }
00196 
00197 //====================================
00198 // setColorDepth
00199 //------------------------------------
00200 void SaXManipulateDesktop::setColorDepth (int c) {
00201         // .../
00204         // ----
00205         if ((! mDesktop) || (! mCard) || (! mPath)) {
00206                 return;
00207         }
00208         QString color;
00209         color.sprintf ("%d",c);
00210         mDesktop -> setItem ( "ColorDepth",color );
00211 }
00212 
00213 //====================================
00214 // is3DCard
00215 //------------------------------------
00216 bool SaXManipulateDesktop::is3DCard (void) {
00217         // .../
00220         // ----
00221         if ((! mDesktop) || (! mCard) || (! mPath)) {
00222                 return false;
00223         }
00224         //====================================
00225         // get sysp card name
00226         //------------------------------------
00227         SaXImportSysp* pCard = new SaXImportSysp (SYSP_CARD);
00228         pCard -> doImport();
00229         if (! pCard -> setID ( mDesktopID )) {
00230                 return false;
00231         }
00232         QString mCardName;
00233         QTextOStream (&mCardName) <<
00234                 pCard->getItem("Vendor") << ":" << pCard->getItem("Device");
00235         //====================================
00236         // retrieve CDB card list
00237         //------------------------------------
00238         SaXProcess* CDBCards = new SaXProcess ();
00239         CDBCards -> start (CDB_CARDS);
00240         QDict< QDict<QString> > CDBData = CDBCards -> getTablePointerCDB ();
00241         QDict<QString>* cardData = CDBData.find ( mCardName );
00242         if ( cardData ) {
00243                 QString* flag = cardData -> find ("Flag");
00244                 if (flag) {
00245                         QString  driver = mCard -> getItem ("Driver");
00246                         QString* driver3D = cardData -> find ("3DDriver");
00247                         if ((driver3D) && (driver == *driver3D)) {
00248                                 //====================================
00249                                 // check 3D driver installation
00250                                 //------------------------------------
00251                                 if ( driver == "nvidia") {
00252                                         QString vendor = getVendorForDriver ( driver );
00253                                         if (vendor == "NVIDIA Corporation") {
00254                                                 return true;
00255                                         }
00256                                         return false;
00257                                 }
00258                                 return true;
00259                         }
00260                         return false;
00261                 }
00262                 return false;
00263         }
00264         //====================================
00265         // No CDB record found for cardName
00266         //------------------------------------
00267         excEmptyCDBGroup ( mCardName.data() );
00268         qError (errorString(),EXC_EMPTYCDBGROUP);
00269         return false;
00270 }
00271 
00272 //====================================
00273 // getDualHeadProfile
00274 //------------------------------------
00275 QString SaXManipulateDesktop::getDualHeadProfile ( void ) {
00276         // .../
00282         // ----
00283         if ((! mDesktop) || (! mCard) || (! mPath)) {
00284                 return QString();
00285         }
00286         //===================================
00287         // Check SaXMeta data...
00288         //-----------------------------------
00289         QDict<QString> metaData = getMetaData();
00290         if (metaData["SAX_NO_CDB_CHECK"]) {
00291                 QString driver  = mCard -> getItem ("Driver");
00292                 QString profile = getDriverOptionsDualHeadProfile ( driver );
00293                 return profile;
00294         }
00295         //====================================
00296         // check special laptop case
00297         //------------------------------------
00298         QString result;
00299         SaXManipulateCard cardInfo (mCard);
00300         if (cardInfo.isNoteBook()) {
00301                 QString driver = mCard -> getItem ("Driver");
00302                 result = getDriverOptionsDualHeadProfile ( driver );
00303                 return result;
00304         }
00305         //====================================
00306         // get sysp card name
00307         //------------------------------------
00308         SaXImportSysp* pCard = new SaXImportSysp (SYSP_CARD);
00309         pCard -> doImport();
00310         if (! pCard -> setID ( mDesktopID )) {
00311                 return QString();
00312         }
00313         QString mCardName;
00314         QTextOStream (&mCardName) <<
00315                 pCard->getItem("Vendor") << ":" << pCard->getItem("Device");
00316         //====================================
00317         // retrieve CDB card list
00318         //------------------------------------
00319         SaXProcess* CDBCards = new SaXProcess ();
00320         CDBCards -> start (CDB_CARDS);
00321         QDict< QDict<QString> > CDBData = CDBCards -> getTablePointerCDB ();
00322         QDict<QString>* cardData = CDBData.find ( mCardName );
00323         if ( cardData ) {
00324                 QString* profile = cardData -> find ("Profile");
00325                 if ((profile) && (profile->contains("DualHead_DriverOptions"))) {
00326                         //====================================
00327                         // check if drivers do match...
00328                         //------------------------------------
00329                         QString syspDriver = pCard -> getItem ("Module");
00330                         QString* CDB2DDriver = cardData -> find ("Driver");
00331                         QString* CDB3DDriver = cardData -> find ("3DDriver");
00332                         if (
00333                                 ((CDB2DDriver) && (syspDriver == *CDB2DDriver)) ||
00334                                 ((CDB3DDriver) && (syspDriver == *CDB2DDriver))
00335                         ) {
00336                                 QTextOStream (&result) << PROFILE_DIR << *profile;
00337                                 return result;
00338                         }
00339                         //====================================
00340                         // drivers don't match check driver...
00341                         //------------------------------------
00342                         result = getDriverOptionsDualHeadProfile ( syspDriver );
00343                         return result;
00344                 }
00345         }
00346         //====================================
00347         // No CDB record found for cardName
00348         //------------------------------------
00349         excEmptyCDBGroup ( mCardName.data() );
00350         qError (errorString(),EXC_EMPTYCDBGROUP);
00351         return QString();
00352 }
00353 
00354 //====================================
00355 // isXineramaMode
00356 //------------------------------------
00357 bool SaXManipulateDesktop::isXineramaMode (void) {
00358         // .../
00359         // check the meta data information if the configuration
00360         // workflow requested to use Xinerama instead of the
00361         // default dual mode workflow based on MergedFB
00362         // ----
00363         QDict<QString> metaData = getMetaData();
00364         if (metaData["SAX_NO_DUAL_MODE"]) {
00365                 return true;
00366         }
00367         return false;
00368 }
00369 
00370 //====================================
00371 // isDualHeadCard
00372 //------------------------------------
00373 bool SaXManipulateDesktop::isDualHeadCard (void) {
00374         // .../
00378         // ----
00379         if ((! mDesktop) || (! mCard) || (! mPath)) {
00380                 return false;
00381         }
00382         //===================================
00383         // Check SaXMeta data...
00384         //-----------------------------------
00385         QDict<QString> metaData = getMetaData();
00386         if (metaData["SAX_NO_CDB_CHECK"]) {
00387                 QString driver  = mCard -> getItem ("Driver");
00388                 QString profile = getDriverOptionsDualHeadProfile ( driver );
00389                 if (! profile.isEmpty()) {
00390                         return true;
00391                 }
00392                 return false;
00393         }
00394         //====================================
00395         // get sysp card name
00396         //------------------------------------
00397         SaXImportSysp* pCard = new SaXImportSysp (SYSP_CARD);
00398         pCard -> doImport();
00399         if (! pCard -> setID ( mDesktopID )) {
00400                 return false;
00401         }
00402         QString mCardName;
00403         QTextOStream (&mCardName) <<
00404                 pCard->getItem("Vendor") << ":" << pCard->getItem("Device");
00405         //====================================
00406         // retrieve CDB card list
00407         //------------------------------------
00408         SaXProcess* CDBCards = new SaXProcess ();
00409         CDBCards -> start (CDB_CARDS);
00410         QDict< QDict<QString> > CDBData = CDBCards -> getTablePointerCDB ();
00411         QDict<QString>* cardData = CDBData.find ( mCardName );
00412         if ( cardData ) {
00413                 QString* profile = cardData -> find ("Profile");
00414                 if ((profile) && (profile->contains("DualHead_DriverOptions"))) {
00415                         //====================================
00416                         // check if drivers do match...
00417                         //------------------------------------
00418                         QString syspDriver = pCard -> getItem ("Module");
00419                         QString* CDB2DDriver = cardData -> find ("Driver");
00420                         QString* CDB3DDriver = cardData -> find ("3DDriver");
00421                         if (
00422                                 ((CDB2DDriver) && (syspDriver != *CDB2DDriver)) &&
00423                                 ((CDB3DDriver) && (syspDriver != *CDB2DDriver))
00424                         ) {
00425                                 *profile = getDriverOptionsDualHeadProfile ( syspDriver );
00426                         }
00427                         if (profile->isEmpty()) {
00428                                 return false;
00429                         }
00430                         //====================================
00431                         // ask profile for changes if dynamic
00432                         //------------------------------------
00433                         SaXProcessCall* proc = new SaXProcessCall ();
00434                         proc -> addArgument ( SAX_PROFILE_CHECK );
00435                         proc -> addArgument ( *profile );
00436                         if ( ! proc -> start() ) {
00437                                 excProcessFailed();
00438                                 qError (errorString(),EXC_PROCESSFAILED);
00439                                 return false;
00440                         }
00441                         if (proc->exitStatus() == 0) {
00442                                 return true;
00443                         }
00444                         return false;
00445                 }
00446                 return false;
00447         }
00448         //====================================
00449         // No CDB record found for cardName
00450         //------------------------------------
00451         excEmptyCDBGroup ( mCardName.data() );
00452         qError (errorString(),EXC_EMPTYCDBGROUP);
00453         return false;
00454 }
00455 
00456 //====================================
00457 // enable3D
00458 //------------------------------------
00459 bool SaXManipulateDesktop::enable3D (void) {
00460         // .../
00469         // ----
00470         if ((! mDesktop) || (! mCard) || (! mPath)) {
00471                 return false;
00472         }
00473         //====================================
00474         // get sysp card name
00475         //------------------------------------
00476         SaXImportSysp* pCard = new SaXImportSysp (SYSP_CARD);
00477         pCard -> doImport();
00478         if (! pCard -> setID ( mDesktopID )) {
00479                 return false;
00480         }
00481         QString mCardName;
00482         QTextOStream (&mCardName) <<
00483                 pCard->getItem("Vendor") << ":" << pCard->getItem("Device");
00484 
00485         //====================================
00486         // retrieve CDB card list
00487         //------------------------------------
00488         SaXProcess* CDBCards = new SaXProcess ();
00489         CDBCards -> start (CDB_CARDS);
00490         QDict< QDict<QString> > CDBData = CDBCards -> getTablePointerCDB ();
00491 
00492         //====================================
00493         // get Extensions for the active card
00494         //------------------------------------
00495         SaXManipulateCard cardInfo (mCard,mDesktopID);
00496         QDict<QString>* cardData = CDBData.find ( mCardName );
00497         if ( cardData ) {
00498                 QString* driver3D= cardData -> find ("3DDriver");
00499                 QString* driver2D= cardData -> find ("Driver");
00500                 QString* extends = cardData -> find ("Extension");
00501                 QString* flag    = cardData -> find ("Flag");
00502                 //========================================
00503                 // check 3D flag
00504                 //----------------------------------------
00505                 if (! flag) {
00506                         return false;
00507                 }               
00508                 //========================================
00509                 // nvidia drv. needed, check if installed
00510                 //----------------------------------------
00511                 if ((driver3D) && (*driver3D == "nvidia")) {
00512                         bool foundBinaryNVidiaDriver = false;
00513                         if ((getVendorForDriver(*driver3D)) == "NVIDIA Corporation") {
00514                                 foundBinaryNVidiaDriver = true;
00515                         }
00516                         if (! foundBinaryNVidiaDriver) {
00517                                 excNvidiaDriverMissing();
00518                                 qError (errorString(),EXC_NVIDIADRIVERMISSING);
00519                                 return false;
00520                         }
00521                 }
00522                 //========================================
00523                 // have extension, add it
00524                 //----------------------------------------
00525                 if (extends) {
00526                         SaXManipulatePath pathInfo (mPath);
00527                         pathInfo.removeLoadableModule (*extends);
00528                         pathInfo.addLoadableModule (*extends);
00529                 }
00530                 //========================================
00531                 // set driver to use with 3D
00532                 //----------------------------------------
00533                 if (driver3D) {
00534                         QString currentDriver = cardInfo.getCardDriver();
00535                         if ((currentDriver != *driver3D) && (currentDriver != *driver2D)) {
00536                                 excDriverMismatch (driver3D->ascii(),currentDriver.ascii());
00537                                 qError (errorString(),EXC_DRIVERMISMATCH);
00538                         } else {
00539                                 cardInfo.setCardDriver (*driver3D);
00540                         }
00541                 }
00542         }
00543         //====================================
00544         // Import profiles if there are any
00545         //------------------------------------
00546         if (cardData) {
00547                 QStringList profiles;
00548                 QString* profile3D = cardData -> find ("3DProfile");
00549                 QString* driver3D  = cardData -> find ("3DDriver");
00550                 QString* driver2D  = cardData -> find ("Driver");
00551                 if ((profile3D) && (! profile3D->contains("DualHead"))) {
00552                         profiles += *profile3D;
00553                 }
00554                 if (driver2D != driver3D) {
00555                         SaXFile mapHandle (MAP_DIR + QString("Driver.map"));
00556                         QDict<QString> driverMap = mapHandle.readDict();
00557                         QString driver = cardInfo.getCardDriver();
00558                         if ((! driver.isEmpty()) && (driverMap[driver])) {
00559                                 QStringList items = QStringList::split ( ",", *driverMap[driver] );
00560                                 profiles += items;
00561                         }
00562                 }
00563                 for (
00564                         QStringList::Iterator it=profiles.begin();
00565                         it != profiles.end(); ++it
00566                 ) {
00567                         QString profile (*it);
00568                         SaXImportProfile* pProfile = new SaXImportProfile (
00569                                 PROFILE_DIR + profile
00570                         );
00571                         pProfile -> doImport();
00572                         //====================================
00573                         // handle Card Options
00574                         //------------------------------------
00575                         SaXImport* mImportCard = pProfile -> getImport ( SAX_CARD );
00576                         if ( mImportCard ) {
00577                                 QDict<QString> profileDriverOptions;
00578                                 SaXManipulateCard saxProfileCard ( mImportCard );
00579                                 profileDriverOptions = saxProfileCard.getOptions();
00580                                 QDictIterator<QString> it ( profileDriverOptions );
00581                                 for (; it.current(); ++it) {
00582                                         QString key = it.currentKey();
00583                                         QString val = *it.current();
00584                                         cardInfo.addCardOption (key,val);
00585                                 }
00586                         }
00587                         //====================================
00588                         // handle Desktop Options
00589                         //------------------------------------
00590                         SaXImport* mImportDesktop = pProfile -> getImport ( SAX_DESKTOP );
00591                         if ( mImportDesktop ) {
00592                                 QDict<QString> profileDriverOptions;
00593                                 SaXManipulateDesktop saxProfileDesktop (
00594                                         mImportDesktop,mCard,mPath
00595                                 );
00596                                 //====================================
00597                                 // Colordepth...
00598                                 //------------------------------------
00599                                 QString color = saxProfileDesktop.getColorDepth();
00600                                 if (! color.isEmpty()) {
00601                                         setColorDepth (color.toInt());
00602                                 }
00603                         }
00604                 }
00605                 return true;
00606         }
00607         //====================================
00608         // No CDB record found for mCardName
00609         //------------------------------------
00610         excEmptyCDBGroup ( mCardName.data() );
00611         qError (errorString(),EXC_EMPTYCDBGROUP);
00612         return false;
00613 }
00614 
00615 //====================================
00616 // disable3D
00617 //------------------------------------
00618 bool SaXManipulateDesktop::disable3D (void) {
00619         // ....
00625         // ----
00626         if ((! mDesktop) || (! mCard) || (! mPath)) {
00627                 return false;
00628         }
00629         //====================================
00630         // get sysp card name
00631         //------------------------------------
00632         SaXImportSysp* pCard = new SaXImportSysp (SYSP_CARD);
00633         pCard -> doImport();
00634         if (! pCard -> setID ( mDesktopID )) {
00635                 return false;
00636         }
00637         QString mCardName;
00638         QTextOStream (&mCardName) <<
00639                 pCard->getItem("Vendor") << ":" << pCard->getItem("Device");
00640 
00641         //====================================
00642         // retrieve CDB card list
00643         //------------------------------------
00644         SaXProcess* CDBCards = new SaXProcess ();
00645         CDBCards -> start (CDB_CARDS);
00646         QDict< QDict<QString> > CDBData = CDBCards -> getTablePointerCDB ();
00647 
00648         //====================================
00649         // get Extensions for the active card
00650         //------------------------------------
00651         SaXManipulateCard cardInfo (mCard);
00652         QDict<QString>* cardData = CDBData.find ( mCardName );
00653         if ( cardData ) {
00654                 QString* driver3D= cardData -> find ("3DDriver");
00655                 QString* driver2D= cardData -> find ("Driver");
00656                 QString* extends = cardData -> find ("Extension");
00657                 QString* flag    = cardData -> find ("Flag");
00658                 //========================================
00659                 // check 3D flag
00660                 //----------------------------------------
00661                 if (! flag) {
00662                         return false;
00663                 }
00664                 //========================================
00665                 // nvidia drv. needed, check if installed
00666                 //----------------------------------------
00667                 if ((driver3D) && (*driver3D == "nvidia")) {
00668                         if ((getVendorForDriver(*driver3D)) == "NVIDIA Corporation") {
00669                                 excNvidiaDriverInstalled();
00670                                 qError (errorString(),EXC_NVIDIADRIVERINSTALLED);
00671                                 return false;
00672                         }
00673                 }
00674                 //========================================
00675                 // have extension, remove it
00676                 //----------------------------------------
00677                 if (extends) {
00678                         SaXManipulatePath pathInfo (mPath);
00679                         pathInfo.removeLoadableModule (*extends);
00680                 }
00681                 //========================================
00682                 // set driver to use with 2D
00683                 //----------------------------------------
00684                 if ((driver2D) && (driver3D)) {
00685                         QString currentDriver = cardInfo.getCardDriver();
00686                         if ((currentDriver != *driver3D) && (currentDriver != *driver2D)) {
00687                                 excDriverMismatch (driver2D->ascii(),currentDriver.ascii());
00688                                 qError (errorString(),EXC_DRIVERMISMATCH);
00689                         } else {
00690                                 cardInfo.setCardDriver (*driver2D);
00691                         }
00692                 }
00693         }
00694         //====================================
00695         // Reset profiles if there are any
00696         //------------------------------------
00697         if (cardData) {
00698                 QStringList profiles;
00699                 QString* profile3D = cardData -> find ("3DProfile");
00700                 QString* driver3D  = cardData -> find ("3DDriver");
00701                 QString* driver2D  = cardData -> find ("Driver");
00702                 if ((profile3D) && (! profile3D->contains("DualHead"))) {
00703                         profiles += *profile3D;
00704                 }
00705                 if (driver2D != driver3D) {
00706                         SaXFile mapHandle (MAP_DIR + QString("Driver.map"));
00707                         QDict<QString> driverMap = mapHandle.readDict();
00708                         if ((driver3D) && (driverMap[*driver3D])) {
00709                                 QStringList items = QStringList::split ( ",",*driverMap[*driver3D] );
00710                                 profiles += items;
00711                         }
00712                 }
00713                 for (
00714                         QStringList::Iterator it=profiles.begin();
00715                         it != profiles.end(); ++it
00716                 ) {
00717                         QString profile (*it);
00718                         SaXImportProfile* pProfile = new SaXImportProfile (
00719                                 PROFILE_DIR + profile
00720                         );
00721                         pProfile -> doImport();
00722                         //====================================
00723                         // remove Card Options
00724                         //------------------------------------
00725                         SaXImport* mImportCard = pProfile -> getImport ( SAX_CARD );
00726                         if ( mImportCard ) {
00727                                 QDict<QString> profileDriverOptions;
00728                                 SaXManipulateCard saxProfileCard ( mImportCard );
00729                                 profileDriverOptions = saxProfileCard.getOptions();
00730                                 QDictIterator<QString> it ( profileDriverOptions );
00731                                 for (; it.current(); ++it) {
00732                                         QString key = it.currentKey();
00733                                         cardInfo.removeCardOption (key);
00734                                 }
00735                         }
00736                 }
00737                 return true;
00738         }
00739         //====================================
00740         // No CDB record found for mCardName
00741         //------------------------------------
00742         excEmptyCDBGroup ( mCardName.data() );
00743         qError (errorString(),EXC_EMPTYCDBGROUP);
00744         return false;
00745 }
00746 
00747 //====================================
00748 // setDisplaySize
00749 //------------------------------------
00750 void SaXManipulateDesktop::setDisplaySize (int width,int height) {
00751         // .../
00754         // ----
00755         if ((! mDesktop) || (! mCard) || (! mPath)) {
00756                 return;
00757         }
00758         QString size;
00759         size.sprintf ("%d %d",width,height);
00760         mDesktop -> setItem ( "DisplaySize",size );
00761 }
00762 
00763 //====================================
00764 // setDisplayRatioAndTraversal
00765 //------------------------------------
00766 void SaXManipulateDesktop::setDisplayRatioAndTraversal (
00767         double traversal,int aspect, int ratio
00768 ) {
00769         // .../
00772         // ----
00773         if ((! mDesktop) || (! mCard) || (! mPath)) {
00774                 return;
00775         }
00776         traversal = traversal * 25.4;
00777         double ar = (double)aspect / (double)ratio;
00778         double y = sqrt ( (traversal * traversal) / (ar * ar + 1.0) );
00779         double x = ar * y;
00780         setDisplaySize (
00781                 (int)(round(x)),(int)(round(y))
00782         );
00783 }
00784 
00785 //====================================
00786 // setHsyncRange
00787 //------------------------------------
00788 void SaXManipulateDesktop::setHsyncRange (double hsmin,double hsmax) {
00789         // .../
00792         // ----
00793         if ((! mDesktop) || (! mCard) || (! mPath)) {
00794                 return;
00795         }
00796         QString range;
00797         range.sprintf ("%.0f-%.0f",hsmin,hsmax);
00798         mDesktop -> setItem ( "HorizSync",range );
00799 }
00800 
00801 //====================================
00802 // setVsyncRange
00803 //------------------------------------
00804 void SaXManipulateDesktop::setVsyncRange (double vsmin,double vsmax) {
00805         // .../
00808         // ----
00809         if ((! mDesktop) || (! mCard) || (! mPath)) {
00810                 return;
00811         }
00812         QString range;
00813         range.sprintf ("%.0f-%.0f",vsmin,vsmax);
00814         mDesktop -> setItem ( "VertRefresh",range );
00815 }
00816 
00817 //====================================
00818 // enableDPMS
00819 //------------------------------------
00820 void SaXManipulateDesktop::enableDPMS (void) {
00821         // .../
00825         // ----
00826         if ((! mDesktop) || (! mCard) || (! mPath)) {
00827                 return;
00828     }
00829         mDesktop -> setItem ( "MonitorOptions","DPMS" );
00830 }
00831 
00832 //====================================
00833 // disableDPMS
00834 //------------------------------------
00835 void SaXManipulateDesktop::disableDPMS (void) {
00836         // .../
00839         // ----
00840         if ((! mDesktop) || (! mCard) || (! mPath)) {
00841                 return;
00842         }
00843         mDesktop -> setItem ( "MonitorOptions","" );
00844 }
00845 
00846 //====================================
00847 // setMonitorVendor
00848 //------------------------------------
00849 void SaXManipulateDesktop::setMonitorVendor (const QString& vendor) {
00850         // .../
00853         // ----
00854         if ((! mDesktop) || (! mCard) || (! mPath)) {
00855                 return;
00856         }
00857         mDesktop -> setItem ( "VendorName",vendor );
00858 }
00859 
00860 //====================================
00861 // setMonitorName
00862 //------------------------------------
00863 void SaXManipulateDesktop::setMonitorName (const QString& name) {
00864         // .../
00867         // ----
00868         if ((! mDesktop) || (! mCard) || (! mPath)) {
00869                 return;
00870         }
00871         mDesktop -> setItem ( "ModelName",name );
00872 }
00873 
00874 //====================================
00875 // is3DEnabled
00876 //------------------------------------
00877 bool SaXManipulateDesktop::is3DEnabled (void) {
00878         // .../
00883         // ----
00884         if ((! mDesktop) || (! mCard) || (! mPath)) {
00885                 return false;
00886         }
00887         if ( mCard -> getCount() > 1 ) {
00888                 return false;
00889         }
00890         QString driver = mCard -> getItem ("Driver");
00891         if (driver == "nvidia") {
00892                 QString vendor = getVendorForDriver ( driver );
00893                 if (vendor == "NVIDIA Corporation") {
00894                         return true;
00895                 }
00896                 return false;
00897         }
00898         SaXManipulatePath pathInfo (mPath);
00899         QList<QString> modules = pathInfo.getModules();
00900         QListIterator<QString> it (modules);
00901         for (; it.current();++it) {
00902         if (*it.current() == "dri") {
00903                 return true;
00904         }
00905         }
00906         return false;
00907 }
00908 
00909 //====================================
00910 // getResolutions
00911 //------------------------------------
00912 QList<QString> SaXManipulateDesktop::getResolutions (int color) {
00913         // .../
00917         // ----
00918         if ((! mDesktop) || (! mCard) || (! mPath)) {
00919                 return QList<QString>();
00920         }
00921         QString modes;
00922         modes.sprintf ("Modes:%d",color);
00923         QString resolutions = mDesktop -> getItem (modes);
00924         if (resolutions.isEmpty()) {
00925                 return QList<QString>();
00926         }
00927         QList<QString> result;
00928         QStringList resList = QStringList::split ( ",", resolutions );
00929         for (QStringList::Iterator it=resList.begin(); it!=resList.end();++ it) {
00930                 QString* data = new QString (*it);
00931                 result.append (data);
00932         }
00933         return result;
00934 }
00935 
00936 //====================================
00937 // getResolutionsFromServer
00938 //------------------------------------
00939 QList<QString> SaXManipulateDesktop::getResolutionFromServer ( void ) {
00940         // .../
00945         // ----
00946         if ((! mDesktop) || (! mCard) || (! mPath)) {
00947                 return QList<QString>();
00948         }
00949         QList<QString> defaultList;
00950         defaultList.append (new QString("800x600"));
00951         SaXProcessCall* proc = new SaXProcessCall();
00952         proc -> addArgument ( XQUERY );
00953         proc -> addArgument ( "-r" );
00954         if ( ! proc -> start() ) {
00955                 return defaultList;
00956         }
00957         QList<QString> data = proc->readStdout();
00958         QListIterator<QString> in (data);
00959         for (; in.current(); ++in) {
00960                 QRegExp modeExp ("(\\d+) (.*)");
00961                 int rpos = modeExp.search (*in.current(),0);
00962                 if (rpos >= 0) {
00963                         int id = modeExp.cap(1).toInt();
00964                         if (id == mDesktopID) {
00965                                 QList<QString> result;
00966                                 result.append (new QString (modeExp.cap(2)));
00967                                 return result;
00968                         }
00969                 }
00970         }
00971         return defaultList;
00972 }
00973 
00974 //====================================
00975 // getDisplaySize
00976 //------------------------------------
00977 QList<QString> SaXManipulateDesktop::getDisplaySize (void) {
00978         // .../
00984         // ----
00985         if ((! mDesktop) || (! mCard) || (! mPath)) {
00986                 return QList<QString>();
00987         }
00988         QString size = mDesktop -> getItem ("DisplaySize");
00989         if (size.isEmpty()) {
00990                 return QList<QString>();
00991         }
00992         QList<QString> result;
00993         QStringList sizeList = QStringList::split ( " ", size );
00994         result.append (
00995                 new QString(sizeList.first())
00996         );
00997         result.append (
00998                 new QString(sizeList.last())
00999         );
01000         return result;
01001 }
01002 
01003 //====================================
01004 // getDisplayTraversal
01005 //------------------------------------
01006 QString SaXManipulateDesktop::getDisplayTraversal (void) {
01007         // .../
01010         // ----
01011         if ((! mDesktop) || (! mCard) || (! mPath)) {
01012                 return QString();
01013         }
01014         QList<QString> size = getDisplaySize();
01015         if (size.isEmpty()) {
01016                 return QString();
01017         }
01018         int x = size.at(0)->toInt();
01019         int y = size.at(1)->toInt();
01020         double traversal = sqrt (x*x + y*y) / 25.4;
01021         QString result;
01022         QTextOStream (&result) << traversal;
01023         return result;
01024 }
01025 
01026 //====================================
01027 // getDisplayRatio
01028 //------------------------------------
01029 QList<QString> SaXManipulateDesktop::getDisplayRatio (void) {
01030         // .../
01033         // ----
01034         if ((! mDesktop) || (! mCard) || (! mPath)) {
01035                 return QList<QString>();
01036         }
01037         QString* setX = new QString ("4");
01038         QString* setY = new QString ("3");
01039         QList<QString> result;
01040         QList<QString> size = getDisplaySize();
01041         if (size.isEmpty()) {
01042                 return QList<QString>();
01043         }
01044         int x = size.at(0)->toInt();
01045         int y = size.at(1)->toInt();
01046         double ar = (double)x / (double)y;
01047         if ( ar > 1.4 ) {
01048                 *setX = "16";
01049                 *setY = "10";
01050         } else if (( ar <= 1.4 ) && ( ar > 1.3 )) {
01051                 *setX = "4";
01052                 *setY = "3";
01053         } else if ( ar <= 1.3 ) {
01054                 *setX = "5";
01055                 *setY = "4";
01056         }
01057         result.append (setX);
01058         result.append (setY);
01059         return result;
01060 }
01061 
01062 //====================================
01063 // getHsyncRange
01064 //------------------------------------
01065 QList<QString> SaXManipulateDesktop::getHsyncRange (void) {
01066         // .../
01070         // ----
01071         if ((! mDesktop) || (! mCard) || (! mPath)) {
01072                 return QList<QString>();
01073         }
01074         QString range = mDesktop -> getItem ("HorizSync");
01075         if (range.isEmpty()) {
01076                 return QList<QString>();
01077         }
01078         QList<QString> result;
01079         QStringList rangeList = QStringList::split ( "-", range );
01080         result.append (
01081                 new QString(rangeList.first())
01082         );
01083         result.append (
01084                 new QString(rangeList.last())
01085         );
01086         return result;
01087 }
01088 
01089 //====================================
01090 // getVsyncRange
01091 //------------------------------------
01092 QList<QString> SaXManipulateDesktop::getVsyncRange (void) {
01093         // .../
01097         // ----
01098         if ((! mDesktop) || (! mCard) || (! mPath)) {
01099                 return QList<QString>();
01100         }
01101         QString range = mDesktop -> getItem ("VertRefresh");
01102         if (range.isEmpty()) {
01103                 return QList<QString>();
01104         }
01105         QList<QString> result;
01106         QStringList rangeList = QStringList::split ( "-", range );
01107         result.append (
01108                 new QString(rangeList.first())
01109         );
01110         result.append (
01111                 new QString(rangeList.last())
01112         );
01113         return result;
01114 }
01115 
01116 //====================================
01117 // DPMSEnabled
01118 //------------------------------------
01119 bool SaXManipulateDesktop::DPMSEnabled (void) {
01120         // .../
01124         // ----
01125         if ((! mDesktop) || (! mCard) || (! mPath)) {
01126                 return false;
01127         }
01128         QString options = mDesktop -> getItem ("MonitorOptions");
01129         if (options == "DPMS") {
01130                 return true;
01131         }
01132         return false;
01133 }
01134 
01135 //====================================
01136 // getMonitorVendor
01137 //------------------------------------
01138 QString SaXManipulateDesktop::getMonitorVendor (void) {
01139         // .../
01142         // ----
01143         if ((! mDesktop) || (! mCard) || (! mPath)) {
01144                 return QString();
01145         }
01146         return mDesktop -> getItem ("VendorName");
01147 }
01148 
01149 //====================================
01150 // getMonitorName
01151 //------------------------------------
01152 QString SaXManipulateDesktop::getMonitorName (void) {
01153         // .../
01156         // ----
01157         if ((! mDesktop) || (! mCard) || (! mPath)) {
01158                 return QString();
01159         }
01160         return mDesktop -> getItem ("ModelName");
01161 }
01162 
01163 //====================================
01164 // getColorDepth
01165 //------------------------------------
01166 QString SaXManipulateDesktop::getColorDepth (void) {
01167         // .../
01170         // ----
01171         if ((! mDesktop) || (! mCard) || (! mPath)) {
01172                 return QString();
01173         }
01174         return mDesktop -> getItem ("ColorDepth");
01175 }
01176 
01177 //====================================
01178 // getModelineAlgorithm
01179 //------------------------------------
01180 QString SaXManipulateDesktop::getModelineAlgorithm (void) {
01181         // .../
01183         // ----
01184         if ((! mDesktop) || (! mCard) || (! mPath)) {
01185                 return QString();
01186         }
01187         return mDesktop -> getItem ("CalcAlgorithm");
01188 }
01189 
01190 //====================================
01191 // willCalculateModelines
01192 //------------------------------------
01193 bool SaXManipulateDesktop::willCalculateModelines (void) {
01194         // .../
01197         // ----
01198         if ((! mDesktop) || (! mCard) || (! mPath)) {
01199                 return false;
01200         }
01201         QString calculate = mDesktop -> getItem ("CalcModelines");
01202         if ((calculate == "on") || (calculate == "yes")) {
01203                 return true;
01204         }
01205         return false;
01206 }
01207 
01208 //====================================
01209 //getVirtualResolution
01210 //------------------------------------
01211 QString SaXManipulateDesktop::getVirtualResolution (int color) {
01212         // .../
01216         // ----
01217         if ((! mDesktop) || (! mCard) || (! mPath)) {
01218                 return QString();
01219         }
01220         QString key;
01221         QString val;
01222         key.sprintf ("Virtual:%d",color);
01223         val = mDesktop -> getItem (key);
01224         if (val.isEmpty()) {
01225                 return QString();
01226         }
01227         QStringList resList = QStringList::split ( " ", val );
01228         QString result (resList.join("x"));
01229         return result;
01230 }
01231 
01232 //====================================
01233 // set monitor record from the CDB
01234 //------------------------------------
01235 void SaXManipulateDesktop::setCDBMonitor ( const QString& group ) {
01236         // .../
01240         // ----
01241         if ( ! mCDBMonitors ) {
01242                 mCDBMonitors = new SaXProcess ();
01243                 mCDBMonitors -> start (CDB_MONITORS);
01244         }
01245         QList< QDict<QString> > data;
01246         data = mCDBMonitors -> getTablePointerCDB_DATA (
01247                 group
01248         );
01249         if (data.isEmpty()) {
01250                 excCDBRecordNotFound (group);
01251                 qError (errorString(),EXC_CDBRECORDNOTFOUND);
01252                 return;
01253         }
01254         QStringList nameList = QStringList::split ( ":", group );
01255         setMonitorVendor ( nameList.first() );
01256         setMonitorName   ( nameList.last() );
01257         mDesktop -> merge ( data );
01258 }
01259 
01260 //====================================
01261 // get list of CDB monitors
01262 //------------------------------------
01263 QList<QString> SaXManipulateDesktop::getCDBMonitorVendorList ( void ) {
01264         // .../
01267         // ----
01268         mCDBMonitorList.clear();
01269         if ( ! mCDBMonitors ) {
01270                 mCDBMonitors = new SaXProcess ();
01271                 mCDBMonitors -> start (CDB_MONITORS);
01272         }
01273         QDict< QDict<QString> > CDBData = mCDBMonitors -> getTablePointerCDB ();
01274         QDictIterator< QDict<QString> > it (CDBData);
01275         for (; it.current(); ++it) {
01276                 QStringList vnlist = QStringList::split ( ":", it.currentKey() );
01277                 QString* vendorName = new QString (vnlist.first());
01278                 int hasVendor = false;
01279                 QListIterator<QString> io (mCDBMonitorList);
01280                 for (; io.current(); ++io) {
01281                 if ( *io.current() == *vendorName ) {
01282                         hasVendor = true;
01283                         break;
01284                 }
01285                 }
01286                 if (! hasVendor ) {
01287                         mCDBMonitorList.append ( vendorName );
01288                 }
01289         }
01290         return mCDBMonitorList;
01291 }
01292 
01293 //====================================
01294 // get CDB monitor models per vendor
01295 //------------------------------------
01296 QList<QString> SaXManipulateDesktop::getCDBMonitorModelList (
01297         const QString& vendor
01298 ) {
01299         // .../
01302         // ----
01303         mCDBMonitorList.clear();
01304         if ( ! mCDBMonitors ) {
01305                 mCDBMonitors = new SaXProcess ();
01306                 mCDBMonitors -> start (CDB_MONITORS);
01307         }
01308         QDict< QDict<QString> > CDBData = mCDBMonitors -> getTablePointerCDB ();
01309         QDictIterator< QDict<QString> > it (CDBData);
01310         for (; it.current(); ++it) {
01311                 QStringList vnlist = QStringList::split ( ":", it.currentKey() );
01312                 QString vendorName = vnlist.first();
01313                 QString* modelName = new QString (vnlist.last());
01314                 if ( vendorName == vendor ) {
01315                         mCDBMonitorList.append ( modelName );
01316                 }
01317         }
01318         return mCDBMonitorList;
01319 }
01320 
01321 //====================================
01322 // get data dict for a CDB monitor
01323 //------------------------------------
01324 QDict<QString> SaXManipulateDesktop::getCDBMonitorData (
01325         const QString& vendor, const QString& name
01326 ) {
01327         // .../
01330         // ----
01331         QString key;
01332         QTextOStream (&key) << vendor << ":" << name;
01333         mCDBMonitorData.clear();
01334         if ( ! mCDBMonitors ) {
01335                 mCDBMonitors = new SaXProcess ();
01336                 mCDBMonitors -> start (CDB_MONITORS);
01337         }
01338         QDict< QDict<QString> > CDBData = mCDBMonitors -> getTablePointerCDB ();
01339         QDictIterator< QDict<QString> > it (CDBData);
01340         for (; it.current(); ++it) {
01341                 if ( it.currentKey() == key ) {
01342                         mCDBMonitorData = *it.current();
01343                         break;
01344                 }
01345         }
01346         return mCDBMonitorData;
01347 }
01348 //====================================
01349 // get data dict for a CDB monitor
01350 //------------------------------------
01351 QDict<QString> SaXManipulateDesktop::getCDBMonitorIDData (
01352         const QString& id
01353 ) {
01354         // .../
01357         // ----
01358         mCDBMonitorData.clear();
01359         if ( ! mCDBMonitors ) {
01360                 mCDBMonitors = new SaXProcess ();
01361                 mCDBMonitors -> start (CDB_MONITORS);
01362         }
01363         QDict< QDict<QString> > CDBData = mCDBMonitors -> getTablePointerCDB ();
01364         QDictIterator< QDict<QString> > it (CDBData);
01365         bool found = false;
01366         for (; it.current(); ++it) {
01367                 mCDBMonitorData = *it.current();
01368                 if ((mCDBMonitorData["DDC"]) && (*mCDBMonitorData["DDC"] == id)) {
01369                         mCDBMonitorData.insert ("Name",new QString(it.currentKey()));
01370                         found = true;
01371                         break;
01372                 }
01373         }
01374         if (! found) {
01375                 mCDBMonitorData.clear();
01376         }
01377         return mCDBMonitorData;
01378 }
01379 //====================================
01380 // add data dict to CDB (temporarly)
01381 //------------------------------------
01382 void SaXManipulateDesktop::setCDBMonitorData (
01383         const QString& vendor, const QString& name,
01384         const QString& key, const QString& value
01385 ) {
01386         // .../
01391         // ----
01392         QString group;
01393         QTextOStream (&group) << vendor << ":" << name;
01394         if ( ! mCDBMonitors ) {
01395                 mCDBMonitors = new SaXProcess ();
01396                 mCDBMonitors -> start (CDB_MONITORS);
01397         }
01398         mCDBMonitors -> addGroup (
01399                 group,key,value
01400         );
01401 }
01402 //====================================
01403 // getVendorForDriver
01404 //------------------------------------
01405 QString SaXManipulateDesktop::getVendorForDriver ( const QString& driver ) {
01406         // .../
01409         // ----
01410         SaXProcessCall* proc = new SaXProcessCall ();
01411         proc -> addArgument ( SYSP_VENDOR );
01412         proc -> addArgument ( driver );
01413         if ( ! proc -> start() ) {
01414                 excProcessFailed();
01415                 qError (errorString(),EXC_PROCESSFAILED);
01416         }
01417         QList<QString> data = proc -> readStdout();
01418         return *data.first();
01419 }
01420 //====================================
01421 // setExtraModelineString
01422 //------------------------------------
01423 void SaXManipulateDesktop::setExtraModelineString (
01424         const QString & mode
01425 ) {
01426         // .../
01429         // This method should be used carefully
01430         // ----
01431         if ((! mDesktop) || (! mCard) || (! mPath)) {
01432                 return;
01433         }
01434         mDesktop -> setItem ( "SpecialModeline",mode );
01435 }
01436 //====================================
01437 // setExtraModeline
01438 //------------------------------------
01439 void SaXManipulateDesktop::setExtraModeline (
01440         int x,int y,int refresh,int hsync
01441 ) {
01442         // .../
01446         // ----
01447         if ((! mDesktop) || (! mCard) || (! mPath)) {
01448                 return;
01449         }
01450         QString mode = calculateModeline ( x,y,refresh,hsync );
01451         mDesktop -> setItem ( "SpecialModeline",mode );
01452 }
01453 //====================================
01454 // addExtraModeline
01455 //------------------------------------
01456 void SaXManipulateDesktop::addExtraModeline (
01457         int x,int y,int refresh,int hsync
01458 ) {
01459         // .../
01463         // ----
01464         if ((! mDesktop) || (! mCard) || (! mPath)) {
01465                 return;
01466         }
01467         QString val;
01468         QString key = "SpecialModeline";
01469         QString mode = calculateModeline ( x,y,refresh,hsync );
01470         if (! mDesktop -> getItem (key).isEmpty()) {
01471                 val = mDesktop -> getItem (key);
01472         }
01473         QTextOStream (&val) << val << "," << mode;
01474         val.replace (QRegExp("^,"),"");
01475         mDesktop -> setItem ( key,val );
01476 }
01477 //====================================
01478 // removeExtraModeline
01479 //------------------------------------
01480 void SaXManipulateDesktop::removeExtraModeline ( int x,int y) {
01481         // .../
01484         // ----
01485         if ((! mDesktop) || (! mCard) || (! mPath)) {
01486                 return;
01487         }
01488         QString val;
01489         QString key = "SpecialModeline";
01490         val.sprintf ("\"%dx%d\"",x,y);
01491         QString current = mDesktop -> getItem (key);
01492         QStringList lines = QStringList::split ( ",", current );
01493         for (
01494                 QStringList::Iterator it=lines.begin();
01495                 it != lines.end(); ++it
01496         ) {
01497                 QString mode (*it);
01498                 if (mode.contains (val)) {
01499                         mDesktop -> removeItem (key,mode);
01500                 }
01501         }
01502 }
01503 //====================================
01504 // calculateModeline
01505 //------------------------------------
01506 QString SaXManipulateDesktop::calculateModeline (
01507         int x,int y,int refresh,int hsync
01508 ) {
01509         // .../
01513         // ----
01514         QString result;
01515         for (int r=refresh;r >= 50;r--) {
01516                 SaXProcessCall* proc = new SaXProcessCall ();
01517                 proc -> addArgument ( XMODE );
01518                 proc -> addArgument ( "-x" );
01519                 proc -> addArgument ( x );
01520                 proc -> addArgument ( "-y" );
01521                 proc -> addArgument ( y );
01522                 proc -> addArgument ( "-r" );
01523                 proc -> addArgument ( r + 2 );
01524                 if ( ! proc -> start() ) {
01525                         excProcessFailed();
01526                         qError (errorString(),EXC_PROCESSFAILED);
01527                 }
01528                 QList<QString> data = proc->readStdout();
01529                 int hs = data.at(0)->toInt();
01530                 result = *data.at(2);
01531                 if (hs <= hsync) {
01532                         break;
01533                 }
01534         }
01535         result.replace (QRegExp("^Modeline "),"");
01536         return result;
01537 }
01538 //====================================
01539 // getDriverOptionsDualHeadProfile
01540 //------------------------------------
01541 QString SaXManipulateDesktop::getDriverOptionsDualHeadProfile (
01542         const QString& driver
01543 ) {
01544         // .../
01548         // ----
01549         QString result;
01550         if ((driver == "i810") || (driver == "i915")) {
01551                 QTextOStream (&result)
01552                         << PROFILE_DIR << "Intel_DualHead_DriverOptions";
01553         }
01554         if (driver == "nvidia") {
01555                 QTextOStream (&result)
01556                         << PROFILE_DIR << "NVidia_DualHead_DriverOptions";
01557         }
01558         if (driver == "radeon") {
01559                 QTextOStream (&result)
01560                         << PROFILE_DIR << "Radeon_DualHead_DriverOptions";
01561         }
01562         if (driver == "fglrx") {
01563                 QTextOStream (&result)
01564                         << PROFILE_DIR << "FGLRX_DualHead_DriverOptions";
01565         }
01566         if (driver == "mga") {
01567                 QTextOStream (&result)
01568                         << PROFILE_DIR << "Matrox_DualHead_DriverOptions";
01569         }
01570         if (driver == "sis") {
01571                 QTextOStream (&result)
01572                         << PROFILE_DIR << "SiS_DualHead_DriverOptions";
01573         }
01574         return result;
01575 }
01576 //====================================
01577 // getMetaData
01578 //------------------------------------
01579 QDict<QString> SaXManipulateDesktop::getMetaData ( void ) {
01580         // .../
01586         QString cardID;
01587         QTextOStream (&cardID) << mDesktopID;
01588         QList<char> metaOptions;
01589         metaOptions.append ( "-c" );
01590         metaOptions.append ( cardID.ascii() );
01591         SaXProcess* proc = new SaXProcess ();
01592         proc->start ( metaOptions , SAX_META );
01593         QDict<QString> metaData = proc->getCurrentTable();
01594         return metaData;
01595 }
01596 } // end namespace

Generated on Tue Nov 28 19:09:12 2006 for libsax by  doxygen 1.5.0