Ignore:
Timestamp:
Jul 11, 2013 2:28:19 PM (9 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
ed51bc3
Parents:
8679296
Message:

Completely revamp how PCDM uses the previous login information. Now you no longer need to specify which desktop to auto-login to if you have auto-login selected. It will first try to check for previous login information for that user, then fall back on the last login for the system in order to try and auto login. Also fix the PCDMd script a bit so that autologins work properly when triggered.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/PCDM/src/pcdm-gui.cpp

    r1d2d46a r90dc161  
    2020PCDMgui::PCDMgui() : QMainWindow() 
    2121{ 
    22     lastUser.clear(); 
    23     lastDE.clear(); 
    2422    //Load the Theme 
    2523    loadTheme(); 
     
    5250    } 
    5351  } 
    54   //Load the data from the last successful login 
    55   loadLastUser(); 
    5652   
    5753} 
     
    178174    loginW = new LoginWidget; 
    179175    loginW->setUsernames(Backend::getSystemUsers()); //add in the detected users 
     176    QString lastUser = Backend::getLastUser(); 
    180177    if(!lastUser.isEmpty()){ //set the previously used user 
    181178        loginW->setCurrentUser(lastUser);  
    182         loadLastDE(lastUser); //make sure the DE switcher reflects the last user choice 
    183179    }  
    184180    //Set Icons from theme 
     
    248244  if(DEBUG_MODE){ qDebug() << " - Fill GUI with data"; } 
    249245  retranslateUi(); 
    250   if(simpleDESwitcher && !lastUser.isEmpty()){ 
    251      
    252   } 
    253246  if(DEBUG_MODE){ qDebug() << "Done with initialization"; } 
    254247 
     
    258251  //Get user inputs 
    259252  QString username = Backend::getUsernameFromDisplayname(displayname); 
    260   QString binary; 
     253  QString desktop; 
    261254  if(simpleDESwitcher){ 
    262     binary = Backend::getDesktopBinary(loginW->currentDE()); 
     255    desktop = loginW->currentDE(); 
    263256  }else{ 
    264     binary = Backend::getDesktopBinary(deSwitcher->currentItem()); 
     257    desktop = deSwitcher->currentItem(); 
    265258  } 
    266259  QString homedir = Backend::getUserHomeDir(username); 
     
    270263  toolbar->setEnabled(FALSE); 
    271264  //Try to login 
    272   emit xLoginAttempt(username, password, homedir, binary); 
     265  emit xLoginAttempt(username, password, homedir, desktop); 
    273266  //Return signals are connected to the slotLogin[Success/Failure] functions 
    274267   
     
    276269 
    277270void PCDMgui::slotLoginSuccess(){ 
    278   QString de; 
     271  /*QString de; 
    279272  if(simpleDESwitcher){ de = loginW->currentDE(); } 
    280273  else{ de = deSwitcher->currentItem(); } 
    281   saveLastLogin( loginW->currentUsername(), de ); 
     274  saveLastLogin( loginW->currentUsername(), de );*/ 
    282275  slotClosePCDM(); //now start to close down the PCDM GUI 
    283276} 
     
    316309  }else{ 
    317310    if(!simpleDESwitcher){ deSwitcher->setVisible(TRUE); } 
    318     //Try to load the user's last DE 
    319     loadLastDE(newuser); 
    320311    //Try to load the custom user icon 
    321312    slotUserChanged(newuser); 
     
    472463    //Get the new desktop list (translated) 
    473464    QStringList deList = Backend::getAvailableDesktops(); 
     465    QString lastDE = Backend::getLastDE(loginW->currentUsername()); 
    474466    //Now fill the switcher 
    475467    if(!simpleDESwitcher){ 
     
    497489      loginW->setDesktops(deList, deIcons, deInfo); 
    498490      //Set the switcher to the last used desktop environment 
    499       if( !lastDE.isEmpty() ){ loginW->setCurrentDE(lastDE); } 
    500     } 
    501  
    502 } 
    503  
    504 void PCDMgui::loadLastUser(){ 
    505   lastUser.clear(); 
    506   if(!QFile::exists("/usr/local/share/PCDM/.lastlogin")){ 
    507     Backend::log("PCDM: No previous login data found"); 
    508   }else{ 
    509     //Load the previous login data 
    510     QFile file("/usr/local/share/PCDM/.lastlogin"); 
    511     if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ 
    512       Backend::log("PCDM: Unable to open previous login data file");     
    513     }else{ 
    514       QTextStream in(&file); 
    515       lastUser= in.readLine(); 
    516       file.close(); 
    517     } 
    518   } 
    519 } 
    520  
    521 void PCDMgui::loadLastDE(QString user){ 
    522   lastDE.clear(); 
    523   QString LLpath = Backend::getUserHomeDir(user) + "/.lastlogin"; 
    524   if(!QFile::exists(LLpath)){ 
    525     Backend::log("PCDM: No previous user login data found for user: "+user); 
    526   }else{ 
    527     //Load the previous login data 
    528     QFile file(LLpath); 
    529     if(!file.open(QIODevice::ReadOnly | QIODevice::Text)){ 
    530       Backend::log("PCDM: Unable to open previous user login file: "+user);     
    531     }else{ 
    532       QTextStream in(&file); 
    533       lastDE= in.readLine(); 
    534       file.close(); 
    535     } 
    536   } 
    537  
    538 } 
    539  
    540 void PCDMgui::saveLastLogin(QString USER, QString DE){ 
    541   QFile file1("/usr/local/share/PCDM/.lastlogin"); 
    542   if(!file1.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)){ 
    543     Backend::log("PCDM: Unable to save last login data");          
    544   }else{ 
    545     QTextStream out(&file1); 
    546     out << USER; 
    547     file1.close(); 
    548   } 
    549   QFile file2( Backend::getUserHomeDir(USER) + "/.lastlogin" ); 
    550   if(!file2.open(QIODevice::Truncate | QIODevice::WriteOnly | QIODevice::Text)){ 
    551     Backend::log("PCDM: Unable to save last login data for user:"+USER);           
    552   }else{ 
    553     QTextStream out(&file2); 
    554     out << DE; 
    555     file2.close(); 
    556   } 
    557 } 
    558  
     491      loginW->setCurrentDE(lastDE); 
     492    } 
     493 
     494} 
     495 
Note: See TracChangeset for help on using the changeset viewer.