| 1181 | } |
| 1182 | |
| 1183 | void CaptureContext::RecompressCapture() |
| 1184 | { |
| 1185 | QString destFilename = GetCaptureFilename(); |
| 1186 | QString tempFilename; |
| 1187 | |
| 1188 | qint64 oldSize = QFile(destFilename).size(); |
| 1189 | |
| 1190 | ICaptureFile *cap = NULL; |
| 1191 | ICaptureFile *tempCap = NULL; |
| 1192 | |
| 1193 | bool inplace = false; |
| 1194 | |
| 1195 | if(IsCaptureTemporary() || !IsCaptureLocal()) |
| 1196 | { |
| 1197 | QMessageBox::StandardButton res = |
| 1198 | RDDialog::question(m_MainWindow, tr("Unsaved capture"), |
| 1199 | tr("To recompress a capture you must save it first. Save this capture?"), |
| 1200 | QMessageBox::Yes | QMessageBox::No | QMessageBox::Cancel); |
| 1201 | |
| 1202 | if(res == QMessageBox::Cancel || res == QMessageBox::No) |
| 1203 | return; |
| 1204 | |
| 1205 | destFilename = m_MainWindow->GetSavePath(); |
| 1206 | |
| 1207 | // if it's already local, we'll do the save as part of the recompression convert. If it's |
| 1208 | // remote, we need to copy it first, but we copy it to a temporary so we can do the conversion |
| 1209 | // to the target location |
| 1210 | |
| 1211 | if(IsCaptureLocal()) |
| 1212 | { |
| 1213 | tempFilename = GetCaptureFilename(); |
| 1214 | } |
| 1215 | else |
| 1216 | { |
| 1217 | tempFilename = TempCaptureFilename(lit("recompress")); |
| 1218 | Replay().CopyCaptureFromRemote(GetCaptureFilename(), tempFilename, m_MainWindow); |
| 1219 | |
| 1220 | if(!QFile::exists(tempFilename)) |
| 1221 | { |
| 1222 | RDDialog::critical(m_MainWindow, tr("Failed to save capture"), |
| 1223 | tr("Capture couldn't be saved from remote.")); |
| 1224 | return; |
| 1225 | } |
| 1226 | } |
| 1227 | } |
| 1228 | else |
| 1229 | { |
| 1230 | // if we're doing this inplace on an already saved capture, then we need to recompress to a |
| 1231 | // temporary and close/move it afterwards. |
| 1232 | inplace = true; |
| 1233 | destFilename = TempCaptureFilename(lit("recompress")); |
| 1234 | } |
| 1235 | |
| 1236 | if(IsCaptureLocal()) |
| 1237 | { |
| 1238 | // for local files we already have a handle. We'll reuse it, then re-open |
| 1239 | cap = m_Replay.GetCaptureFile(); |
| 1240 | } |
nothing calls this directly
no test coverage detected