void MLPluginController::doPresetMenu(int result) { switch(result) { // do another menu command case (0): // dismiss break; case (1): // save as version in current dir if(getProcessor()->saveStateAsVersion() != MLProc::OK) { AlertWindow::showMessageBox (AlertWindow::NoIcon, String::empty, "", "OK"); } break; case (2): // save over previous if(getProcessor()->saveStateOverPrevious() != MLProc::OK) { AlertWindow::showMessageBox (AlertWindow::NoIcon, String::empty, "", "OK"); } break; case (3): // save as ... { String errStr; File userPresetsFolder = getDefaultFileLocation(kPresetFiles); if (userPresetsFolder != File::nonexistent) { bool nativeChooserUI = true; FileChooser fc ("Save preset as...", userPresetsFolder, String::empty, nativeChooserUI); if (fc.browseForFileToSave (true)) { File saveFile = fc.getResult(); std::string fullSavePath(saveFile.getFullPathName().toUTF8()); getProcessor()->saveStateToLongFileName(fullSavePath); } } else { errStr = ("Error: user presets folder did not exist and could not be created."); AlertWindow::showMessageBox (AlertWindow::NoIcon, String::empty, errStr, "OK"); } } break; case (4): // revert getProcessor()->returnToLatestStateLoaded(); break; case (5): // copy SystemClipboard::copyTextToClipboard (getProcessor()->getStateAsText()); break; case (6): // paste getProcessor()->setPatchStateFromText (SystemClipboard::getTextFromClipboard()); break; #if SHOW_CONVERT_PRESETS #if ML_MAC case (7): // show convert alert box convertPresets(); getProcessor()->scanAllFilesImmediate(); break; #endif #endif default: // load preset loadPresetByMenuIndex(result); break; } }
uint32 FileDownloader::DownloadFile() { Logger::Instance()->Debug("Start download"); fileForWrite = NULL; FilePath fullSavePath(GetSourceUrl()); fullSavePath.ReplaceDirectory(GetSavePath()); // Check file exist fileForWrite = File::Create(fullSavePath, File::OPEN | File::READ); if (fileForWrite == NULL) { // If fole not exist create new file fileForWrite = File::Create(fullSavePath, File::CREATE | File::WRITE); } else if (reloadFile == false) { // Open file for APPEND and get pos to resume download SafeRelease(fileForWrite); fileForWrite = File::Create(fullSavePath, File::APPEND | File::WRITE); } else { // Reload exist file from server SafeRelease(fileForWrite); fileForWrite = File::Create(fullSavePath, File::CREATE | File::WRITE); } // Error read, write or create file if ( fileForWrite == NULL && delegate != NULL) { delegate->DownloadComplete(FileDownloaderDelegate::DL_ERROR_FILE_SYSTEM); return CURL_LAST; } uint32 status; do { if (reconnectCnt > 0 && delegate != NULL) { delegate->DownloadReconnect(); } status = CurlDownload(); ++reconnectCnt; } while ( status != CURLE_OK && ( reconnectCnt < reconnectMax || reconnectMax == -1 ) ); SafeRelease(fileForWrite); // if ( status == CURLE_OK && delegate != NULL ) { delegate->DownloadComplete(FileDownloaderDelegate::DL_SUCCESS); } else if ( delegate != NULL ) { delegate->DownloadComplete(FileDownloaderDelegate::DL_ERROR_DOWNLOAD); } Logger::Instance()->Debug("End download"); return status; }