Changeset 6e77702


Ignore:
Timestamp:
07/31/13 14:35:20 (17 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1, releng/10.0.2, releng/10.0.3, releng/10.1
Children:
033a33f
Parents:
59d0cef
Message:

Clean up how the mount tray detects new devices - now it should pick up on devices that do not create a new device node (like some SD card readers).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-mounttray/mountTray.cpp

    r242767e r6e77702  
    189189   
    190190  if(DEBUG_MODE){ qDebug() << "Checking for Device Changes:"; } 
    191   //oldsysdev is the old device list for the system 
    192   QStringList osd = oldsysdev; 
     191  //Get the current list of devices 
    193192  QStringList nsd = DCheck->devChildren(""); 
    194   nsd.sort(); 
    195   oldsysdev = nsd; //save the new list as the old list for later 
    196   //Now determine new/missing devices 
    197   nsd.sort(); 
    198   QStringList rmList; 
    199   for(int i=0; i<osd.length(); i++){ 
    200     int ni = nsd.indexOf(osd[i]); //new index 
    201     if( ni == -1){ //device removed 
    202       rmList << osd[i]; 
    203       osd.removeAt(i); 
     193  //Remove all the currently managed devices 
     194  for(int i=0; i<deviceList.length(); i++){ 
     195    QString dev = deviceList[i]->device; 
     196    int ni = nsd.indexOf(dev); 
     197    if(ni == -1){ 
     198      //Device Removed 
     199      removeDevice(dev); 
    204200      i--; 
    205     }else{ //both lists have device 
    206       osd.removeAt(i); i--; 
     201    }else{ 
     202      //Probe the device for validity if not currently mounted 
     203      if( !deviceList[i]->isMounted() ){ 
     204        QString ja, jb, jc, jd; //junk variables 
     205        if( !DCheck->devInfo(dev,&ja,&jb,&jc,&jd) ){ 
     206          //no longer valid device 
     207          removeDevice(dev); 
     208          i--; 
     209        } 
     210      } 
    207211      nsd.removeAt(ni); 
    208212    } 
    209213  } 
    210   //all that is left in nsd is the new additions 
    211  
    212   //Remove any devices that have been disconnected 
    213   if(DEBUG_MODE){ qDebug() << " -Device Removals:" << rmList; } 
    214   for(int i=0; i<rmList.length(); i++){ 
    215     removeDevice(rmList[i]); 
    216   } 
    217   //Add any devices that have been connected 
    218   if(DEBUG_MODE){ qDebug() << " -Device Additions:" << nsd; }  
     214  //Now Iterate through all available devices and probe them for validity 
     215  // (This should catch devices that do not "announce" their presence by creating a new device node) 
    219216  for(int i=0; i<nsd.length(); i++){ 
    220217    //Check if it is a good device 
     
    232229    } 
    233230  } 
    234   //==== CD/DVD Devices ==== 
    235   //Always check cd/dvd devices because the device node will never be added/removed 
    236   QStringList diskList; 
    237   diskList << DCheck->devChildren("cd"); 
    238   diskList << DCheck->devChildren("acd"); 
    239   if(DEBUG_MODE){ qDebug() << " -Checking CD/DVD devices:" << diskList; } 
    240   for(int i=0; i<diskList.length(); i++){ 
    241     if( rmList.contains(diskList[i]) || nsd.contains(diskList[i]) ){ 
    242       continue; //do not double check a device that was just checked;        
    243     } 
    244     //Check if it is a good device 
    245     QString dlabel, dtype, dfs, dsize; //additional output info 
    246     bool good = DCheck->devInfo(diskList[i],&dtype,&dlabel,&dfs,&dsize); 
    247     if(good){ 
    248       //Now create a new entry for this device 
    249       addDevice(diskList[i],dlabel,dtype,dfs);   
    250       //Show a message bubble 
    251       if(showPopup){ 
    252         QString title = tr("New Device"); 
    253         QString message = QString( tr("%1 can now be accessed")).arg(dlabel); 
    254         slotDisplayPopup(title, message); 
    255       } 
    256     }else{ //not good device 
    257       removeDevice(diskList[i]);             
    258     } 
    259   } //end loop over cd/dvd devices 
    260231   
    261232  //Run the disk space check if appropriate 
Note: See TracChangeset for help on using the changeset viewer.