Changeset 65268 in vbox
- Timestamp:
- Jan 12, 2017 7:05:49 PM (8 years ago)
- Location:
- trunk/src/VBox/Frontends/VirtualBox/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.cpp
r64429 r65268 2166 2166 } 2167 2167 2168 void UIMessageCenter::cannotValidateGuestAdditionsSHA256Sum(const QString &strUrl, const QString &strSrc) const 2169 { 2170 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error, 2171 tr("<p>The <b>VirtualBox Guest Additions</b> disk image file has been successfully downloaded " 2172 "from <nobr><a href=\"%1\">%1</a></nobr> " 2173 "and saved locally as <nobr><b>%2</b>, </nobr>" 2174 "but the SHA-256 checksum verification failed.</p>" 2175 "<p>Please do the download, installation and verification manually.</p>") 2176 .arg(strUrl, strSrc)); 2177 } 2178 2168 2179 void UIMessageCenter::cannotUpdateGuestAdditions(const CProgress &progress) const 2169 2180 { … … 2271 2282 0 /* auto-confirm id */, 2272 2283 tr("Delete", "extension pack")); 2284 } 2285 2286 void UIMessageCenter::cannotValidateExtentionPackSHA256Sum(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const 2287 { 2288 alert(windowManager().networkManagerOrMainWindowShown(), MessageType_Error, 2289 tr("<p>The <b><nobr>%1</nobr></b> has been successfully downloaded " 2290 "from <nobr><a href=\"%2\">%2</a></nobr> " 2291 "and saved locally as <nobr><b>%3</b>, </nobr>" 2292 "but the SHA-256 checksum verification failed.</p>" 2293 "<p>Please do the download, installation and verification manually.</p>") 2294 .arg(strExtPackName, strFrom, strTo)); 2273 2295 } 2274 2296 #endif /* VBOX_GUI_WITH_NETWORK_MANAGER */ -
trunk/src/VBox/Frontends/VirtualBox/src/globals/UIMessageCenter.h
r63762 r65268 329 329 void cannotSaveGuestAdditions(const QString &strURL, const QString &strTarget) const; 330 330 bool proposeMountGuestAdditions(const QString &strUrl, const QString &strSrc) const; 331 void cannotValidateGuestAdditionsSHA256Sum(const QString &strUrl, const QString &strSrc) const; 331 332 void cannotUpdateGuestAdditions(const CProgress &progress) const; 332 333 bool cannotFindUserManual(const QString &strMissedLocation) const; … … 338 339 void cannotSaveExtensionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const; 339 340 bool proposeInstallExtentionPack(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const; 341 void cannotValidateExtentionPackSHA256Sum(const QString &strExtPackName, const QString &strFrom, const QString &strTo) const; 340 342 bool proposeDeleteExtentionPack(const QString &strTo) const; 341 343 bool proposeDeleteOldExtentionPacks(const QStringList &strFiles) const; -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloader.cpp
r62493 r65268 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 /// This class requires proper doxy. 19 /// For now I'm keeping the old style consistent. 17 20 18 21 #ifdef VBOX_WITH_PRECOMPILED_HEADERS … … 49 52 void UIDownloader::sltStartDownloading() 50 53 { 51 /* Set state to acknowledging: */54 /* Set state to downloading: */ 52 55 m_state = UIDownloaderState_Downloading; 53 56 54 57 /* Send GET request: */ 55 58 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << m_source); 59 } 60 61 /* Verifying start: */ 62 void UIDownloader::sltStartVerifying() 63 { 64 /* Set state to verifying: */ 65 m_state = UIDownloaderState_Verifying; 66 67 /* Send GET request: */ 68 createNetworkRequest(UINetworkRequestType_GET, QList<QUrl>() << m_strPathSHA256SumsFile); 56 69 } 57 70 … … 63 76 connect(this, SIGNAL(sigToStartAcknowledging()), this, SLOT(sltStartAcknowledging()), Qt::QueuedConnection); 64 77 connect(this, SIGNAL(sigToStartDownloading()), this, SLOT(sltStartDownloading()), Qt::QueuedConnection); 78 connect(this, SIGNAL(sigToStartVerifying()), this, SLOT(sltStartVerifying()), Qt::QueuedConnection); 65 79 } 66 80 … … 73 87 case UIDownloaderState_Acknowledging: return tr("Looking for %1..."); 74 88 case UIDownloaderState_Downloading: return tr("Downloading %1..."); 89 case UIDownloaderState_Verifying: return tr("Verifying %1..."); 75 90 default: break; 76 91 } … … 113 128 break; 114 129 } 130 case UIDownloaderState_Verifying: 131 { 132 handleVerifyingResult(pNetworkReply); 133 break; 134 } 115 135 default: 116 136 break; … … 143 163 handleDownloadedObject(pNetworkReply); 144 164 165 /* Check whether we should do verification: */ 166 if (!m_strPathSHA256SumsFile.isEmpty()) 167 { 168 /* Start verifying: */ 169 startDelayedVerifying(); 170 } 171 else 172 { 173 /* Delete downloader: */ 174 deleteLater(); 175 } 176 } 177 178 void UIDownloader::handleVerifyingResult(UINetworkReply *pNetworkReply) 179 { 180 /* Handle verified object: */ 181 handleVerifiedObject(pNetworkReply); 182 145 183 /* Delete downloader: */ 146 184 deleteLater(); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloader.h
r62493 r65268 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 /// This class requires proper doxy. 19 /// For now I'm keeping the old style consistent. 17 20 18 21 #ifndef __UIDownloader_h__ … … 42 45 /* Signal to start downloading: */ 43 46 void sigToStartDownloading(); 47 /* Signal to start verifying: */ 48 void sigToStartVerifying(); 44 49 45 50 public: … … 54 59 /* Downloading part: */ 55 60 void sltStartDownloading(); 61 /* Verifying part: */ 62 void sltStartVerifying(); 56 63 57 64 protected: … … 62 69 UIDownloaderState_Null, 63 70 UIDownloaderState_Acknowledging, 64 UIDownloaderState_Downloading 71 UIDownloaderState_Downloading, 72 UIDownloaderState_Verifying, 65 73 }; 66 74 … … 80 88 const QString& target() const { return m_strTarget; } 81 89 90 /* SHA-256 stuff, 91 * allows to set/get SHA-256 sum dictionary file for downloaded source. */ 92 QString pathSHA256SumsFile() const { return m_strPathSHA256SumsFile; } 93 void setPathSHA256SumsFile(const QString &strPathSHA256SumsFile) { m_strPathSHA256SumsFile = strPathSHA256SumsFile; } 94 82 95 /** Returns description of the current network operation. */ 83 96 virtual const QString description() const; … … 87 100 /* Start delayed downloading: */ 88 101 void startDelayedDownloading() { emit sigToStartDownloading(); } 102 /* Start delayed verifying: */ 103 void startDelayedVerifying() { emit sigToStartVerifying(); } 89 104 90 105 /* Network-reply progress handler: */ … … 99 114 /* Handle downloading result: */ 100 115 virtual void handleDownloadingResult(UINetworkReply *pNetworkReply); 116 /* Handle verifying result: */ 117 virtual void handleVerifyingResult(UINetworkReply *pNetworkReply); 101 118 102 119 /* Pure virtual function to ask user about downloading confirmation: */ … … 104 121 /* Pure virtual function to handle downloaded object: */ 105 122 virtual void handleDownloadedObject(UINetworkReply *pNetworkReply) = 0; 123 /* Base virtual function to handle verified object: */ 124 virtual void handleVerifiedObject(UINetworkReply * /* pNetworkReply */) {} 106 125 107 126 private: … … 112 131 QUrl m_source; 113 132 QString m_strTarget; 133 QString m_strPathSHA256SumsFile; 114 134 }; 115 135 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderAdditions.cpp
r62493 r65268 34 34 #endif /* !VBOX_WITH_PRECOMPILED_HEADERS */ 35 35 36 #include <iprt/sha.h> 37 36 38 37 39 /* static */ … … 81 83 82 84 /* Prepare source/target: */ 83 const QString &strName = QString("VBoxGuestAdditions_%1.iso").arg(strVersion); 84 const QString &strSource = QString("http://download.virtualbox.org/virtualbox/%1/").arg(strVersion) + strName; 85 const QString &strTarget = QDir(vboxGlobal().homeFolder()).absoluteFilePath(strName); 85 const QString strSourceName = QString("VBoxGuestAdditions_%1.iso").arg(strVersion); 86 const QString strSourceFolder = QString("http://download.virtualbox.org/virtualbox/%1/").arg(strVersion); 87 const QString strSource = strSourceFolder + strSourceName; 88 const QString strPathSHA256SumsFile = QString("https://www.virtualbox.org/download/hashes/%1/SHA256SUMS").arg(strVersion); 89 const QString strTarget = QDir(vboxGlobal().homeFolder()).absoluteFilePath(strSourceName); 86 90 87 91 /* Set source/target: */ 88 92 setSource(strSource); 89 93 setTarget(strTarget); 94 setPathSHA256SumsFile(strPathSHA256SumsFile); 90 95 } 91 96 … … 111 116 { 112 117 /* Read received data into the buffer: */ 113 QByteArray receivedData(pReply->readAll()); 118 m_receivedData = pReply->readAll(); 119 } 120 121 void UIDownloaderAdditions::handleVerifiedObject(UINetworkReply *pReply) 122 { 123 /* Try to verify the SHA-256 checksum: */ 124 bool fSuccess = false; 125 do 126 { 127 /* Read received data into the buffer: */ 128 const QByteArray receivedData(pReply->readAll()); 129 /* Make sure it's not empty: */ 130 if (receivedData.isEmpty()) 131 break; 132 133 /* Parse buffer contents to dictionary: */ 134 const QStringList dictionary(QString(receivedData).split("\n", QString::SkipEmptyParts)); 135 /* Make sure it's not empty: */ 136 if (dictionary.isEmpty()) 137 break; 138 139 /* Parse each record to tags, look for the required one: */ 140 foreach (const QString &strRecord, dictionary) 141 { 142 const QString strFileName = strRecord.section(" *", 1); 143 const QString strDownloadedSumm = strRecord.section(" *", 0, 0); 144 if (strFileName == QFileInfo(source().toString()).fileName()) 145 { 146 /* Calculate the SHA-256 on the bytes, creating a string: */ 147 uint8_t abHash[RTSHA256_HASH_SIZE]; 148 RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash); 149 char szDigest[RTSHA256_DIGEST_LEN + 1]; 150 int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest)); 151 if (RT_FAILURE(rc)) 152 { 153 AssertRC(rc); 154 szDigest[0] = '\0'; 155 } 156 157 const QString strCalculatedSumm(szDigest); 158 // printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData()); 159 // printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData()); 160 /* Make sure checksum is valid: */ 161 fSuccess = strDownloadedSumm == strCalculatedSumm; 162 break; 163 } 164 } 165 } 166 while (false); 167 168 /* If SHA-256 checksum verification failed: */ 169 if (!fSuccess) 170 { 171 /* Warn the user about additions-image was downloaded and saved but checksum is invalid: */ 172 msgCenter().cannotValidateGuestAdditionsSHA256Sum(source().toString(), QDir::toNativeSeparators(target())); 173 return; 174 } 175 114 176 /* Serialize that buffer into the file: */ 115 177 while (true) … … 120 182 { 121 183 /* Write buffer into the file: */ 122 file.write( receivedData);184 file.write(m_receivedData); 123 185 file.close(); 124 186 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderAdditions.h
r62493 r65268 50 50 bool askForDownloadingConfirmation(UINetworkReply *pReply); 51 51 void handleDownloadedObject(UINetworkReply *pReply); 52 void handleVerifiedObject(UINetworkReply *pReply); 52 53 53 54 /* Variables: */ 54 55 static UIDownloaderAdditions *m_spInstance; 56 QByteArray m_receivedData; 55 57 }; 56 58 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.cpp
r62493 r65268 61 61 62 62 /* Prepare source/target: */ 63 QString strVersion = vboxGlobal().vboxVersionStringNormalized(); 63 64 QString strExtPackUnderscoredName(QString(GUI_ExtPackName).replace(' ', '_')); 64 65 QString strTemplateSourcePath("http://download.virtualbox.org/virtualbox/%1/"); 65 66 QString strTemplateSourceName(QString("%1-%2.vbox-extpack").arg(strExtPackUnderscoredName)); 66 QString strSourcePath(strTemplateSourcePath.arg( vboxGlobal().vboxVersionStringNormalized()));67 QString strSourceName(strTemplateSourceName.arg( vboxGlobal().vboxVersionStringNormalized()));67 QString strSourcePath(strTemplateSourcePath.arg(strVersion)); 68 QString strSourceName(strTemplateSourceName.arg(strVersion)); 68 69 QString strSource(strSourcePath + strSourceName); 70 QString strPathSHA256SumsFile = QString("https://www.virtualbox.org/download/hashes/%1/SHA256SUMS").arg(strVersion); 69 71 QString strTargetPath(vboxGlobal().homeFolder()); 70 72 QString strTargetName(strSourceName); … … 74 76 setSource(strSource); 75 77 setTarget(strTarget); 78 setPathSHA256SumsFile(strPathSHA256SumsFile); 76 79 } 77 80 … … 97 100 { 98 101 /* Read received data into the buffer: */ 99 QByteArray receivedData(pReply->readAll()); 102 m_receivedData = pReply->readAll(); 103 } 104 105 void UIDownloaderExtensionPack::handleVerifiedObject(UINetworkReply *pReply) 106 { 107 /* Try to verify the SHA-256 checksum: */ 108 bool fSuccess = false; 109 do 110 { 111 /* Read received data into the buffer: */ 112 const QByteArray receivedData(pReply->readAll()); 113 /* Make sure it's not empty: */ 114 if (receivedData.isEmpty()) 115 break; 116 117 /* Parse buffer contents to dictionary: */ 118 const QStringList dictionary(QString(receivedData).split("\n", QString::SkipEmptyParts)); 119 /* Make sure it's not empty: */ 120 if (dictionary.isEmpty()) 121 break; 122 123 /* Parse each record to tags, look for the required one: */ 124 foreach (const QString &strRecord, dictionary) 125 { 126 const QString strFileName = strRecord.section(" *", 1); 127 const QString strDownloadedSumm = strRecord.section(" *", 0, 0); 128 if (strFileName == QFileInfo(source().toString()).fileName()) 129 { 130 /* Calculate the SHA-256 on the bytes, creating a string: */ 131 uint8_t abHash[RTSHA256_HASH_SIZE]; 132 RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash); 133 char szDigest[RTSHA256_DIGEST_LEN + 1]; 134 int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest)); 135 if (RT_FAILURE(rc)) 136 { 137 AssertRC(rc); 138 szDigest[0] = '\0'; 139 } 140 141 const QString strCalculatedSumm(szDigest); 142 // printf("Downloaded SHA-256 summ: [%s]\n", strDownloadedSumm.toUtf8().constData()); 143 // printf("Calculated SHA-256 summ: [%s]\n", strCalculatedSumm.toUtf8().constData()); 144 /* Make sure checksum is valid: */ 145 fSuccess = strDownloadedSumm == strCalculatedSumm; 146 break; 147 } 148 } 149 } 150 while (false); 151 152 /* If SHA-256 checksum verification failed: */ 153 if (!fSuccess) 154 { 155 /* Warn the user about additions-image was downloaded and saved but checksum is invalid: */ 156 msgCenter().cannotValidateExtentionPackSHA256Sum(GUI_ExtPackName, source().toString(), QDir::toNativeSeparators(target())); 157 return; 158 } 159 100 160 /* Serialize that buffer into the file: */ 101 161 while (true) … … 106 166 { 107 167 /* Write buffer into the file: */ 108 file.write( receivedData);168 file.write(m_receivedData); 109 169 file.close(); 110 170 111 171 /* Calc the SHA-256 on the bytes, creating a string: */ 112 172 uint8_t abHash[RTSHA256_HASH_SIZE]; 113 RTSha256( receivedData.constData(),receivedData.length(), abHash);173 RTSha256(m_receivedData.constData(), m_receivedData.length(), abHash); 114 174 char szDigest[RTSHA256_DIGEST_LEN + 1]; 115 175 int rc = RTSha256ToString(abHash, szDigest, sizeof(szDigest)); -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIDownloaderExtensionPack.h
r62493 r65268 50 50 bool askForDownloadingConfirmation(UINetworkReply *pReply); 51 51 void handleDownloadedObject(UINetworkReply *pReply); 52 void handleVerifiedObject(UINetworkReply *pReply); 52 53 53 54 /* Variables: */ 54 55 static UIDownloaderExtensionPack *m_spInstance; 56 QByteArray m_receivedData; 55 57 }; 56 58 -
trunk/src/VBox/Frontends/VirtualBox/src/net/UIUpdateManager.cpp
r64772 r65268 56 56 57 57 58 #if 059 58 /* enable to test the version update check */ 60 #define VBOX_NEW_VERSION_TEST "0.0.0_0 http://unknown.unknown.org/0.0.0/VirtualBox-0.0.0-0-unknown.pkg" 61 #endif 59 //#define VBOX_NEW_VERSION_TEST "5.1.12_0 http://unknown.unknown.org/0.0.0/VirtualBox-0.0.0-0-unknown.pkg" 62 60 63 61 /* Forward declarations: */
Note:
See TracChangeset
for help on using the changeset viewer.