Ignore:
Timestamp:
Jul 8, 2013 9:09:02 AM (10 months ago)
Author:
Kris Moore <kris@…>
Branches:
master, 9.2-release, releng/10.0, releng/10.0.1
Children:
5e1ad95, d9b0b9e8
Parents:
6eb01ac
Message:

Remove old Mirror tab in System Manager, not used now that we run via CDN

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src-qt4/pc-sysmanager/pbsystemtab.cpp

    rcf89547 rfbdee93  
    5151    loadBootData(); 
    5252 
    53     // Load the mirror configuration 
    54     loadMirrorConfig(); 
    55    
    5653    // Connect our various buttons 
    5754    connect(buttonGenerate, SIGNAL(clicked()), this, SLOT(startGenerateSheet()) ); 
    5855    connect(showBootCheck, SIGNAL(clicked()), this, SIGNAL(changed())); 
    5956    connect(splashSelect, SIGNAL(activated(int)), this, SIGNAL(changed())); 
    60     connect(pushRefreshList, SIGNAL( clicked() ), this, SLOT( slotUpdateMirrorList() ) ); 
    61     connect(pushMirrorSave, SIGNAL( clicked() ), this, SLOT( slotMirrorSave() ) ); 
    6257    connect(pushMiscSave, SIGNAL( clicked() ), this, SLOT( slotMiscSave() ) ); 
    6358 
    6459    connect(fetchSourceBut, SIGNAL( clicked() ), this, SLOT( fetchSourcePressed() ) ); 
    6560    connect(fetchPortsBut, SIGNAL( clicked() ), this, SLOT( fetchPortsPressed() ) ); 
    66  
    67     // Connect the mirror radio buttons, so we can enable disable objects based on status 
    68     connect(radioAutoMirror, SIGNAL( clicked() ), this, SLOT( slotCheckMirrorRadio() ) ); 
    69     connect(radioSelectMirror, SIGNAL( clicked() ), this, SLOT( slotCheckMirrorRadio() ) ); 
    70     connect(radioCustomMirror, SIGNAL( clicked() ), this, SLOT( slotCheckMirrorRadio() ) ); 
    71  
    72 } 
    73  
    74 void PBSystemTab::loadMirrorConfig() 
    75 { 
    76  
    77   QSettings settings("PCBSD"); 
    78   QString tmp; 
    79  
    80   // Get the current mirror 
    81   currentMirror = pcbsd::Utils::getMasterMirror(); 
    82  
    83   // Load our array of mirrors 
    84   comboMirrorList->clear(); 
    85   bool foundMirror = false; 
    86   bool usingMirrorList = false; 
    87   QString MirrorName, MirrorURL; 
    88  
    89   int size = settings.beginReadArray("/PC-BSD/SoftwareManager/mirrorList"); 
    90   for (int i = 0; i < size; ++i) { 
    91      foundMirror = true; 
    92      settings.setArrayIndex(i); 
    93      MirrorName = settings.value("MirrorName").toString(); 
    94      MirrorURL = settings.value("MirrorURL").toString(); 
    95      comboMirrorList->addItem( MirrorName ); 
    96      mirrorNames[i] = MirrorName; 
    97      mirrorURLs[i] = MirrorURL; 
    98      if ( currentMirror == MirrorURL ) { 
    99        comboMirrorList->setCurrentIndex(i); 
    100        radioSelectMirror->setChecked(true); 
    101        usingMirrorList = true; 
    102      } 
    103   } 
    104                  
    105   settings.endArray(); 
    106  
    107   // If our mirror list is empty, start a refresh of it now 
    108   if (!foundMirror) 
    109      slotUpdateMirrorList(); 
    110    
    111   // Check if we found a mirror in the PC-BSD list, otherwise default to custom mirror 
    112   if (!usingMirrorList) { 
    113       if ( currentMirror.isEmpty() ) 
    114         radioAutoMirror->setChecked(true); 
    115       else 
    116         radioCustomMirror->setChecked(true); 
    117       lineCustomMirror->setText(currentMirror); 
    118   } 
    119  
    120   slotCheckMirrorRadio(); 
    12161} 
    12262 
     
    344284    if (! screens.exists()) 
    345285    { 
    346         QMessageBox::critical( 0, tr("Refresh Mirrors"), PREFIX + "/share/pcbsd/splash-screens/ " + tr("doesn't exist!"), QMessageBox::Ok ); 
     286        QMessageBox::critical( 0, tr("File not found!"), PREFIX + "/share/pcbsd/splash-screens/ " + tr("doesn't exist!"), QMessageBox::Ok ); 
    347287        return; 
    348288    } 
     
    421361} 
    422362 
    423 void PBSystemTab::slotUpdateMirrorList() { 
    424   // Fetch from here http://updates.pcbsd.org/mirror-list.php 
    425   QString URL, LFILE; 
    426   URL= "http://updates.pcbsd.org/mirror-list.php"; 
    427  
    428   mirrorJob = new QNetworkAccessManager(this); 
    429   mirrorJobBuf.clear(); 
    430  
    431   QNetworkRequest netRequest; 
    432   netRequest.setUrl(QUrl(URL)); 
    433   mirrorReply = mirrorJob->get(netRequest); 
    434     
    435   connect(mirrorJob, SIGNAL(finished(QNetworkReply *)), this, SLOT(slotRefreshMirrorDone() ) ); 
    436   connect(mirrorReply, SIGNAL(readyRead()), this, SLOT(slotGetMirrorData() ) ); 
    437 } 
    438  
    439 void PBSystemTab::slotGetMirrorData() { 
    440         //while (mirrorReply->canReadLine() ) 
    441         //        mirrorJobBuf << mirrorReply->readLine().simplified(); 
    442  
    443         mirrorJobBuf = mirrorJobBuf + mirrorReply->readAll(); 
    444 } 
    445  
    446 void PBSystemTab::slotRefreshMirrorDone() { 
    447    QString MirrorName, MirrorURL, tmp; 
    448  
    449  
    450    if (mirrorReply->error() != QNetworkReply::NoError) 
    451    { 
    452       QMessageBox::critical( 0, tr("Refresh Mirrors"), tr("Error fetching mirror list! Check your internet connection, or try again later."), QMessageBox::Ok ); 
    453         return; 
    454    } 
    455  
    456    QStringList mirrorList; 
    457    mirrorList = mirrorJobBuf.split("\n"); 
    458    qDebug() << "Avail Mirrors:" << mirrorList; 
    459    // Clear the combo box   
    460    comboMirrorList->clear(); 
    461    int i = 0; 
    462  
    463    QString line; 
    464    for ( int z = 0; z < mirrorList.size(); z++ ) { 
    465      line = mirrorList.at(z); 
    466  
    467      tmp = line; 
    468      tmp.truncate(line.indexOf("=") -1 ); 
    469      MirrorName = tmp; 
    470      MirrorURL = line.remove(0, line.indexOf("=") + 1); 
    471      mirrorNames[i] = MirrorName; 
    472      mirrorURLs[i] = MirrorURL.simplified(); 
    473      comboMirrorList->addItem( MirrorName ); 
    474  
    475      if ( currentMirror == MirrorURL ) 
    476         comboMirrorList->setCurrentIndex(i); 
    477  
    478      i++; 
    479    } 
    480  
    481    // Close the array 
    482    mirrorNames[i] = ""; 
    483    mirrorURLs[i] = ""; 
    484  
    485    QSettings settings("PCBSD"); 
    486    settings.beginWriteArray("/PC-BSD/SoftwareManager/mirrorList"); 
    487    i = 0; 
    488    while ( !mirrorNames[i].isEmpty() ) 
    489    { 
    490       settings.setArrayIndex(i); 
    491       settings.setValue("MirrorName", mirrorNames[i]); 
    492       settings.setValue("MirrorURL", mirrorURLs[i].simplified()); 
    493       i++; 
    494    } 
    495  
    496    settings.endArray();  
    497 } 
    498  
    499  
    500 void PBSystemTab::slotCheckMirrorRadio() { 
    501  
    502     comboMirrorList->setEnabled(false); 
    503     pushRefreshList->setEnabled(false); 
    504     lineCustomMirror->setEnabled(false); 
    505     if( radioSelectMirror->isChecked() ) 
    506     { 
    507       comboMirrorList->setEnabled(true); 
    508       pushRefreshList->setEnabled(true); 
    509     } 
    510     if( radioCustomMirror->isChecked() ) 
    511       lineCustomMirror->setEnabled(true); 
    512 } 
    513  
    514363void PBSystemTab::slotMiscSave() { 
    515364    miscSavePressed(); 
     
    517366} 
    518367 
    519 void PBSystemTab::slotMirrorSave() { 
    520     saveMirrorConfig(); 
    521 } 
    522  
    523 void PBSystemTab::saveMirrorConfig() { 
    524     if( ! sanityCheckSettings() ) 
    525         return; 
    526  
    527  
    528     if ( ! radioSelectMirror->isChecked() ) { 
    529        pcbsd::Utils::setMasterMirror(lineCustomMirror->text()); 
    530     } else if (radioAutoMirror->isChecked() ) { 
    531        pcbsd::Utils::setMasterMirror(""); 
    532     } else { 
    533        // Check if we have a mirror selected and save it 
    534        QString curMirror; 
    535        int i = 0; 
    536        while ( !mirrorNames[i].isEmpty() ) 
    537        { 
    538           if ( comboMirrorList->currentText() == mirrorNames[i]) { 
    539             curMirror = mirrorURLs[i]; 
    540             break; 
    541           } 
    542           i++; 
    543        } 
    544          
    545        pcbsd::Utils::setMasterMirror(curMirror); 
    546     } 
    547 } 
    548  
    549368void PBSystemTab::slotClose() { 
    550369    close(); 
     
    553372bool PBSystemTab::sanityCheckSettings() 
    554373{ 
    555   if (radioCustomMirror->isChecked() ) { 
    556     if( lineCustomMirror->text().indexOf("http://") != 0 && lineCustomMirror->text().indexOf("ftp://") != 0 ) 
    557     { 
    558       tabWidget->setCurrentIndex(1); 
    559       QMessageBox::critical( 0, tr("Config Error"), tr("Error: Your custom mirror needs to begin with ftp:// or http://"), QMessageBox::Ok ); 
    560       return false; 
    561     } 
    562   } 
    563  
    564374  return true; 
    565375} 
Note: See TracChangeset for help on using the changeset viewer.