/** @param s The sound file to be closed (This pointer will become invalid after returning) //@param ask If true (default), the user will be asked to save the file if it's been modified. @return 0 if the file was closed, 1 if canclled, -1 if error */ int GData::closeFile(SoundFile *s, int theSavingMode/*, bool ask*/) { if(s == NULL) return -1; QString newFilename; QString oldFilename(s->filename); //#ifdef WINDOWS // oldFilename.replace(QChar('/'), QChar('\\')); //#endif oldFilename = QDir::convertSeparators(oldFilename); if(gdata->audioThread.playSoundFile() == s || gdata->audioThread.recSoundFile() == s) { gdata->stop(); } if(s->saved()) { //file is already saved removeFileFromList(s); delete s; return 0; } if(theSavingMode == ALWAYS_ASK) { QString filename = QString(getFilenamePart(oldFilename.latin1())); int option = QMessageBox::question(NULL, QString("Save changes to file '") + filename + "' ?", QString("Save changes to the file '") + filename + QString("' ?\n"), "&Yes", "&No", "&Cancel", 0, 2); switch(option) { case 0: //Yes newFilename = saveFileAsk(oldFilename); if(newFilename.isNull()) return 1; removeFileFromList(s); delete s; //printf("move file %s to %s\n", oldFilename.latin1(), newFilename.latin1()); fflush(stdout); break; case 1: //No removeFileFromList(s); delete s; //printf("remove file %s\n", oldFilename.latin1()); fflush(stdout); break; default: //Cancelled return 1; } } else if(theSavingMode == NEVER_SAVE) { removeFileFromList(s); delete s; } else if(theSavingMode == ALWAYS_SAVE) { removeFileFromList(s); delete s; } return 0; /* if(ret == -1) { QMessageBox::warning(mainWindow, "Error", QString("Error removing file '") + QString(oldFilename) + QString("'"), QMessageBox::Ok, Qt::NoButton); } return ret;*/ }
void Logger::log(Severity theSeverity, const char *theModule, int theId, const std::string &theText) { std::stringstream stream; std::string myLogTag(_myTopLevelLogTag); std::ostringstream myText; myText << theText; if (theSeverity > SEV_PRINT) { if(m_use_timestamp) stream << currentDateTime(); myText<<" [" << getFilenamePart(theModule) << " at:" << theId << "]"; if(m_use_thread_id) myText<<" [thread-id: "<< std::this_thread::get_id() <<"]"; } switch (theSeverity) { case SEV_TRACE: stream <<" TRACE: " << myText.str(); break; case SEV_DEBUG: stream <<" DEBUG: " << myText.str(); break; case SEV_INFO: stream <<" INFO: " << myText.str(); break; case SEV_WARNING: stream <<" WARNING: " << myText.str(); break; case SEV_PRINT: stream << myText.str(); break; case SEV_ERROR: stream <<" ERROR: " << myText.str(); break; default: throw Exception("Unknown logger severity"); break; } // pass log string to outstreams std::list<std::ostream*>::iterator stream_it = m_out_streams.begin(); for (; stream_it != m_out_streams.end(); ++stream_it) { (**stream_it) << stream.str() << std::endl; } #if ANDROID switch (theSeverity) { case SEV_TRACE : __android_log_print(ANDROID_LOG_VERBOSE, myLogTag.c_str(), myText.str().c_str());//__VA_ARGS__) break; case SEV_DEBUG : __android_log_print(ANDROID_LOG_DEBUG, myLogTag.c_str(), myText.str().c_str());//__VA_ARGS__) break; case SEV_WARNING : __android_log_print(ANDROID_LOG_WARN, myLogTag.c_str(), myText.str().c_str());//__VA_ARGS__) break; case SEV_INFO : case SEV_PRINT : __android_log_print(ANDROID_LOG_INFO, myLogTag.c_str(), myText.str().c_str());//__VA_ARGS__) break; case SEV_ERROR : __android_log_print(ANDROID_LOG_ERROR, myLogTag.c_str(), myText.str().c_str());//__VA_ARGS__) break; default: throw Exception("Unknown logger severity"); break; } #endif }