int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // Also create a debug console window // if(AllocConsole()) // { // freopen("CONOUT$", "w", stdout); // SetConsoleTitle(L"Debug Console"); // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); // } #endif Projekt theApp(hInstance); if (!theApp.Init()) return 0; return theApp.Run(); }
/****************************************************************************** * Register this application with the alarm daemon, and tell it to load the * calendar. * Set 'reregister' true in order to notify the daemon of a change in the * 'disable alarms if stopped' setting. */ bool Daemon::registerWith(bool reregister) { if (mRegisterTimer) return true; switch (mStatus) { case STOPPED: case RUNNING: return false; case REGISTERED: if (!reregister) return true; break; case READY: break; } bool disabledIfStopped = theApp()->alarmsDisabledIfStopped(); kdDebug(5950) << (reregister ? "Daemon::reregisterWith(): " : "Daemon::registerWith(): ") << (disabledIfStopped ? "NO_START" : "COMMAND_LINE") << endl; QCString appname = kapp->aboutData()->appName(); AlarmDaemonIface_stub s(DAEMON_APP_NAME, DAEMON_DCOP_OBJECT); if (reregister) s.registerChange(appname, !disabledIfStopped); else s.registerApp(appname, kapp->aboutData()->programName(), QCString(NOTIFY_DCOP_OBJECT), AlarmCalendar::activeCalendar()->urlString(), !disabledIfStopped); if (!s.ok()) { kdError(5950) << "Daemon::registerWith(" << reregister << "): DCOP error" << endl; registrationResult(reregister, KAlarmd::FAILURE); return false; } mRegisterTimer = new QTimer(mInstance); connect(mRegisterTimer, SIGNAL(timeout()), mInstance, SLOT(registerTimerExpired())); mRegisterTimer->start(REGISTER_TIMEOUT * 1000); // wait for the reply return true; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) { // Enable run-time memory check for debug builds. #if defined(DEBUG) | defined(_DEBUG) _CrtSetDbgFlag( _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF ); // Used to find memory leaks //_CrtSetBreakAlloc(1585977); //Also create a debug console window //if(AllocConsole()) //{ // freopen("CONOUT$", "w", stdout); // SetConsoleTitle(L"Debug Console"); // SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_RED); //} #endif //------Splash Screen-------// Gdiplus::GdiplusStartupInput gdiSI; Gdiplus::GdiplusStartupOutput gdiSO; ULONG_PTR gdiToken; ULONG_PTR gdiHookToken; gdiSI.SuppressBackgroundThread = TRUE; Gdiplus::GdiplusStartup(&gdiToken,&gdiSI,&gdiSO); gdiSO.NotificationHook(&gdiHookToken); //--------------------------// Projekt theApp(hInstance); if (!theApp.Init()) return 0; gdiSO.NotificationUnhook(gdiHookToken); Gdiplus::GdiplusShutdown(gdiToken); return theApp.Run(); }
int main() { //This log is required by the tests for checking that we don't do too much during elaboration lllog(1) << "dose_main entering main()" << std::endl; //ensure call to CrashReporter::Stop at application exit //Start is called in DoseMainApp boost::shared_ptr<void> crGuard(static_cast<void*>(0), [](void*){Safir::Utilities::CrashReporter::Stop();}); boost::asio::io_service ioService; boost::atomic<bool> success(true); try { Safir::Dob::Internal::DoseMainApp theApp(ioService); //Set number of threads to at least 2, or the number of cpu kernels auto nbrOfThreads = std::max<size_t>(10, boost::thread::hardware_concurrency()); const auto run = [&ioService,&theApp,&success] { try { ioService.run(); return; } catch (const std::exception & exc) { SEND_SYSTEM_LOG(Alert, << "DOSE_MAIN: Caught 'std::exception' exception from io_service.run(): " << " '" << exc.what() << "'."); success.exchange(false); } catch (...) { SEND_SYSTEM_LOG(Alert, << "DOSE_MAIN: Caught '...' exception from io_service.run()."); success.exchange(false); } theApp.Stop(); }; boost::thread_group threads; for (unsigned int i = 0; i < nbrOfThreads-1; ++i) { threads.create_thread(run); } run(); threads.join_all(); crGuard.reset(); //now check the thread count, all threads should be gone, except the main //thread. CheckThreadCount(); } catch (const std::exception & exc) { SEND_SYSTEM_LOG(Alert, << "DOSE_MAIN: Caught 'std::exception' exception: " << " '" << exc.what() << "'."); success.exchange(false); } catch (...) { SEND_SYSTEM_LOG(Alert, << "DOSE_MAIN: Caught '...' exception."); success.exchange(false); } if (success) { std::wcout << "DOSE_MAIN: Exiting..." << std::endl; } else { std::wcout << "DOSE_MAIN: Exiting due to error..." << std::endl; } return success ? 0 : 1; }
bool ckvdHandle::isFocused() { //return theApp()->isHandleSelected(getId()); return theApp()->getSelectedGrabber() == this; }
void SICliScriptDriver::appendCardLogLine(const QString &line) { theApp()->cardLog() << line << endl; }
int main(int argc, char **argv) { int c; std::string server_name = "localhost"; int server_port = 9090; std::string root_file_name = ""; std::string module_file_name = ""; while ((c = getopt(argc, argv, "hH:p:i:M:")) != -1) { switch (c) { case 'h': HelpMessage(); return 0; case 'H': server_name = optarg; break; case 'p': server_port = atoi(optarg); break; case 'i': root_file_name = optarg; break; case 'M': module_file_name = optarg; break; default: break; } } int fake_argc = 1; char fake_arg_str[256]; sprintf(fake_arg_str,"./online-display"); char *fake_argv[] = {fake_arg_str}; TApplication theApp("RMidas", &fake_argc, fake_argv); if (gROOT->IsBatch()) { printf("%s: cannot run in batch mode\n", argv[0]); return 1; } std::cout<<module_file_name<<std::endl; TOnlineFrame *onlineFrame = new TOnlineFrame(gClient->GetRoot(),module_file_name); if (root_file_name.length() != 0) onlineFrame->OpenRootFile(root_file_name.c_str()); else { onlineFrame->setServerName(server_name.c_str()); onlineFrame->setServerPort(server_port); onlineFrame->ConnectToServer(); onlineFrame->Print(); #if 0 // Get list of all histograms, then copy them to the current directory std::vector<TString> vHistTitles = onlineFrame->GetHistTitles(); for (unsigned int i = 0; i < vHistTitles.size(); ++i) { //printf("%d: %s\n", i, vHistTitles.at(i).Data()); TH1 *hist = onlineFrame->GetHist(vHistTitles.at(i).Data()); if(hist) { //hist->Draw(); hist->Clone(vHistTitles.at(i).Data()); } } #endif } //onlineFrame->runMacro("modules/common/root_init.C"); /* TThread *ct = new TThread(cycleThread, onlineFrame); ct->Run(); */ //theApp.SetIdleTimer(1,".q"); onlineFrame->UpdateDisplay(); theApp.Run(1); #if 0 time_t lastCycleTime = 0;//time(NULL); while(true) { theApp.Run(1); if(time(NULL) > lastCycleTime + onlineFrame->getAutoUpdateTime()) { //printf("Considering cycling\n"); onlineFrame->ConsiderCycling(); onlineFrame->ConsiderAutoupdate(); lastCycleTime = time(NULL); } else { usleep(10000); } } #endif return 0; }
void isis::app::Shutdown() { theApp().Shutdown(); }
int main(int argc, char * argv[]) { #ifdef OMIM_UNIT_TEST_WITH_QT_EVENT_LOOP QAPP theApp(argc, argv); UNUSED_VALUE(theApp); #else UNUSED_VALUE(argc); UNUSED_VALUE(argv); #endif my::g_LogLevel = LINFO; #if defined(OMIM_OS_MAC) || defined(OMIM_OS_LINUX) my::SetLogMessageFn(my::LogMessageTests); #endif vector<string> testNames; vector<bool> testResults; int numFailedTests = 0; ParseOptions(argc, argv, g_testingOptions); if (g_testingOptions.m_help) { Usage(argv[0]); return STATUS_SUCCESS; } regex filterRegExp; if (g_testingOptions.m_filterRegExp) filterRegExp.assign(g_testingOptions.m_filterRegExp); regex suppressRegExp; if (g_testingOptions.m_suppressRegExp) suppressRegExp.assign(g_testingOptions.m_suppressRegExp); for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; pTest = pTest->m_pNext) { string fileName(pTest->m_FileName); string testName(pTest->m_TestName); // Retrieve fine file name auto const lastSlash = fileName.find_last_of("\\/"); if (lastSlash != string::npos) fileName.erase(0, lastSlash + 1); testNames.push_back(fileName + "::" + testName); testResults.push_back(true); } if (GetTestingOptions().m_listTests) { for (auto const & name : testNames) cout << name << endl; return 0; } int iTest = 0; for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; ++iTest, pTest = pTest->m_pNext) { auto const & testName = testNames[iTest]; if (g_testingOptions.m_filterRegExp && !regex_match(testName.begin(), testName.end(), filterRegExp)) { continue; } if (g_testingOptions.m_suppressRegExp && regex_match(testName.begin(), testName.end(), suppressRegExp)) { continue; } LOG(LINFO, ("Running", testName)); if (!g_bLastTestOK) { // Somewhere else global variables have been reset. LOG(LERROR, ("\n\nSOMETHING IS REALLY WRONG IN THE UNIT TEST FRAMEWORK!!!")); return STATUS_BROKEN_FRAMEWORK; } my::HighResTimer timer(true); try { // Run the test. pTest->m_Fn(); if (g_bLastTestOK) { LOG(LINFO, ("OK")); } else { // You can set Break here if test failed, // but it is already set in OnTestFail - to fail immediately. testResults[iTest] = false; ++numFailedTests; } } catch (TestFailureException const & ) { testResults[iTest] = false; ++numFailedTests; } catch (std::exception const & ex) { LOG(LERROR, ("FAILED", "<<<Exception thrown [", ex.what(), "].>>>")); testResults[iTest] = false; ++numFailedTests; } catch (...) { LOG(LERROR, ("FAILED<<<Unknown exception thrown.>>>")); testResults[iTest] = false; ++numFailedTests; } g_bLastTestOK = true; uint64_t const elapsed = timer.ElapsedNano(); LOG(LINFO, ("Test took", elapsed / 1000000, "ms\n")); } if (numFailedTests != 0) { LOG(LINFO, (numFailedTests, " tests failed:")); for (size_t i = 0; i < testNames.size(); ++i) { if (!testResults[i]) LOG(LINFO, (testNames[i])); } LOG(LINFO, ("Some tests FAILED.")); return STATUS_FAILED; } LOG(LINFO, ("All tests passed.")); return STATUS_SUCCESS; }
int main(int argc, char* argv[]){ TApplication theApp("App",&argc,argv); //---------------------------------------// // Global variables: could be give as argument later //---------------------------------------// int nwnodes = 6; //8 to 10 is the optimal string macroName = "ProofSelectorRPVAnalysis.C+"; //"+" should be put at the end to use ACLIC complication - This macro should inherit from TSelector //In order to allow the node to access the xml, the name should be given with the full path string xmlFileName = string("/home/jlagram/scratch/NEWFORMAT/CMSSW_4_2_5/src/NTuple/NTupleAnalysis/config/RPVAnalysis.xml"); string outputFileName = "proof.root"; //---------------------------------------// // Decleration of TProof //---------------------------------------// //to be done before colling TProof system("../GeneralExamples/clean_proof.sh ; echo 'Wait few seconds ... ' ; sleep 6"); system("rm -r $HOME/.proof"); TProof *proof = TProof::Open(""); proof->SetParallel(nwnodes); //you should not have any package yet proof->ShowPackages(); //proof->ClearPackages(); //Loading package related to NTupleAnalysis cout<<" ## Upload package NTAna.par: "; proof->UploadPackage("../NTAna.par"); cout<<" DONE [don't worry with symlink error - do rm NTAna if you change NTAna.par in the meanwhile !] "<<endl; proof->EnablePackage("NTAna"); //Adding histograms for feedback: must exist in the TSelector ! proof->AddFeedback("fHist"); //give the "name" of the histogram and not the name of the variable TH1F* (could be the same !) //This line is required to display histograms durint the process TDrawFeedback fb(proof); //---------------------------------------// // Xml Loading & Dataset registration //---------------------------------------// vector < Dataset > datasets; AnalysisEnvironmentLoader anaEL (xmlFileName); anaEL.LoadSamples (datasets); // now the list of datasets written in the xml file is known cout<<" #------------------------------------# "<<endl; cout<<" PROOF DATASETS SUMMARY [normaly 0]"<<endl; proof->ShowDataSets(); cout<<" #------------------------------------# "<<endl; cout<<" # Registring dataset ... "<<endl; cout<<" Don't be worry with the checksum error message [at least I'm not ;-) ]"<<endl; cout<<" #------------------------------------# "<<endl; //Create datasets in proof format TFileCollection** fileCollec = new TFileCollection*[datasets.size()]; for(unsigned int i=0;i<datasets.size();i++){ fileCollec[i] = new TFileCollection(datasets[i].Name().c_str(),""); for(unsigned int j=0;j<datasets[i].Filenames().size();j++){ fileCollec[i]->Add(datasets[i].Filenames()[j].c_str()); } //register dataset in proof proof->RegisterDataSet(datasets[i].Name().c_str(),fileCollec[i]); proof->VerifyDataSet(datasets[i].Name().c_str()); } //summarize the list of datasets cout<<" #------------------------------------# "<<endl; cout<<" PROOF DATASETS SUMMARY"<<endl; proof->ShowDataSets(); cout<<" #------------------------------------# "<<endl; //---------------------------------------// // Loading of the xml file //---------------------------------------// //Possibility to give float ... ex: //Double_t f = 3.14; //proof->SetParameter("IN_FLOAT",f); //---------------------------------------// // Processing of the datasets //---------------------------------------// string outputFileNameModif = outputFileName.substr(0,outputFileName.size()-5); //string MergingCommand = "hadd "+outputFileNameModif+"_merged.root "+outputFileNameModif+"_*.root "; for(unsigned int i=0;i<datasets.size();i++){ proof->AddInput(new TNamed("PROOF_DATASETNAME", datasets[i].Name())); //---------------------------------------// // Loading of the xml file //---------------------------------------// //Possibility to give float ... ex: //Double_t f = 3.14; //proof->SetParameter("IN_FLOAT",f); proof->AddInput(new TNamed("PROOF_XMLFILENAME", xmlFileName)); proof->AddInput(new TNamed("PROOF_OUTPUTFILE", outputFileName)); cout<<"#------------------------------------# "<<endl; cout<<"PROOF PARAMETERS SUMMARY"<<endl; proof->ShowParameters(); cout<<"#------------------------------------# "<<endl; cout<<"################################################################"<<endl; cout<<"########### Processing the dataset "<<datasets[i].Name()<<endl; cout<<"################################################################"<<endl; proof->Process(datasets[i].Name().c_str(),macroName.c_str()); string newFileName = outputFileNameModif+"_"+datasets[i].Name()+".root"; //system("sleep 30"); cout<<"Copying the output file with the name "<<endl; //string command = "cp "+outputFileName+" "+newFileName; //MergingCommand+=newFileName+" "; //system(command.c_str()); proof->ClearInput(); } //cout<<"## Merging of all the dataset into one single file with hadd: "<<outputFileName<<endl; //system(MergingCommand.c_str()); cout << "start backuping proof root files " << endl; system("mkdir backup_outputProof`date +\"%d-%m-%y_%H-%M-%S\"`; mv proof*.root backup_outputProof`date +\"%d-%m-%y_%H-%M-%S\"`/."); return (0); }
float isis::app::AverageFrameRate() { return theApp().AverageFrameRate(); }
float isis::app::AverageFrameDuration() { return theApp().AverageFrameDuration(); }
void isis::app::Exit() { theApp().Exit(); }
int main(int argc, char** argv) { TApplication theApp("tapp", &argc, argv); produce_graphs(true, argv[1]); theApp.Run(); return 0; }
void PreviewLoader::Impl::startLoading(bool wait) { if (pending_.empty() || !pconverter_) return; // Only start the process off after the buffer is loaded from file. if (!buffer_.isFullyLoaded()) return; LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()"); // As used by the LaTeX file and by the resulting image files string const directory = buffer_.temppath(); string const filename_base = unique_filename(directory); // Create an InProgress instance to place in the map of all // such processes if it starts correctly. InProgress inprogress(filename_base, pending_, pconverter_->to); // clear pending_, so we're ready to start afresh. pending_.clear(); // Output the LaTeX file. FileName const latexfile(filename_base + ".tex"); // we use the encoding of the buffer Encoding const & enc = buffer_.params().encoding(); ofdocstream of; try { of.reset(enc.iconvName()); } catch (iconv_codecvt_facet_exception const & e) { LYXERR0("Caught iconv exception: " << e.what() << "\nUnable to create LaTeX file: " << latexfile); return; } TexRow texrow; otexstream os(of, texrow); OutputParams runparams(&enc); LaTeXFeatures features(buffer_, buffer_.params(), runparams); if (!openFileWrite(of, latexfile)) return; if (!of) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "Unable to create LaTeX file\n" << latexfile); return; } of << "\\batchmode\n"; dumpPreamble(os); // handle inputenc etc. buffer_.params().writeEncodingPreamble(os, features); of << "\n\\begin{document}\n"; dumpData(of, inprogress.snippets); of << "\n\\end{document}\n"; of.close(); if (of.fail()) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "File was not closed properly."); return; } double const font_scaling_factor = buffer_.isExporting() ? 75.0 * buffer_.params().html_math_img_scale : 0.01 * lyxrc.dpi * lyxrc.zoom * lyxrc.preview_scale_factor; // FIXME XHTML // The colors should be customizable. ColorCode const bg = buffer_.isExporting() ? Color_white : PreviewLoader::backgroundColor(); ColorCode const fg = buffer_.isExporting() ? Color_black : PreviewLoader::foregroundColor(); // The conversion command. ostringstream cs; cs << pconverter_->command << " " << quoteName(latexfile.toFilesystemEncoding()) << " --dpi " << int(font_scaling_factor) << " --fg " << theApp()->hexName(fg) << " --bg " << theApp()->hexName(bg); // FIXME what about LuaTeX? if (buffer_.params().useNonTeXFonts) cs << " --latex=xelatex"; if (buffer_.params().encoding().package() == Encoding::japanese) cs << " --latex=platex"; if (buffer_.params().bibtex_command != "default") cs << " --bibtex=" << quoteName(buffer_.params().bibtex_command); else if (buffer_.params().encoding().package() == Encoding::japanese) cs << " --bibtex=" << quoteName(lyxrc.jbibtex_command); else cs << " --bibtex=" << quoteName(lyxrc.bibtex_command); if (buffer_.params().bufferFormat() == "lilypond-book") cs << " --lilypond"; string const command = libScriptSearch(cs.str()); if (wait) { ForkedCall call(buffer_.filePath()); int ret = call.startScript(ForkedProcess::Wait, command); static int fake = (2^20) + 1; int pid = fake++; inprogress.pid = pid; inprogress.command = command; in_progress_[pid] = inprogress; finishedGenerating(pid, ret); return; } // Initiate the conversion from LaTeX to bitmap images files. ForkedCall::SignalTypePtr convert_ptr(new ForkedCall::SignalType); convert_ptr->connect(bind(&Impl::finishedGenerating, this, _1, _2)); ForkedCall call(buffer_.filePath()); int ret = call.startScript(command, convert_ptr); if (ret != 0) { LYXERR(Debug::GRAPHICS, "PreviewLoader::startLoading()\n" << "Unable to start process\n" << command); return; } // Store the generation process in a list of all such processes inprogress.pid = call.pid(); inprogress.command = command; in_progress_[inprogress.pid] = inprogress; }
int main(int argc, char * argv[]) { gStyle->SetOptStat(0); if(argc < 3) { std::cout << "USAGE:\t\t compareMap file1.root file2.root [file3.root] " << std::endl; std::cout << std::endl; return 1; } int N = argc - 1; std::string* arguments = new std::string[argc]; for(int i = 0 ; i < argc ; i++) { arguments[i] = argv[i]; } TApplication theApp("App", &argc, argv); //take the n of files, create the input tfiles and th2f TFile** inputFile = new TFile*[N]; TH2F*** inputMap = new TH2F**[N]; TH2F*** comparisonMap = new TH2F**[N-1]; TCanvas*** canvas = new TCanvas**[N-1]; for(int i = 0 ; i < N ; i++) { inputMap[i] = new TH2F*[2]; comparisonMap[i] = new TH2F*[2]; canvas[i] = new TCanvas*[2]; } //open input files for(int i = 0 ; i < N ; i++) { inputFile[i] = new TFile(arguments[i+1].c_str(),"READ"); } //take the th2fs for(int i = 0 ; i < N ; i++) { inputFile[i]->cd(); inputFile[i]->cd("head0"); inputMap[i][0] = (TH2F*) ((TCanvas*) gDirectory->Get("Peaks0"))->GetPrimitive("peaks0"); inputFile[i]->cd(); inputFile[i]->cd("head1"); inputMap[i][1] = (TH2F*) ((TCanvas*) gDirectory->Get("Peaks1"))->GetPrimitive("peaks1"); } for(int i = 0 ; i < N-1 ; i++) { //run on two input maps, produce the comparison map for(int j = 0 ; j < 2 ; j++) { std::stringstream sname; sname << "Head_" << j << " , (file" << i+2 << "-file" << i+1 << ")/(file" << i+1 << ")"; comparisonMap[i][j] = new TH2F(sname.str().c_str(),sname.str().c_str(),64,0,64,48,0,48); comparisonMap[i][j]->GetZaxis()->SetRangeUser(-0.05,0.05); sname.str(""); sname << "C_Head_" << j << " , (file" << i+2 << "-file" << i+1 << ")/(file" << i+1 << ")"; canvas[i][j] = new TCanvas(sname.str().c_str(),sname.str().c_str(),1200,800); for(int cx = 0 ; cx < 64 ; cx++) { for(int cy = 0 ; cy < 48 ; cy++) { float c1 = inputMap[i][j]->GetBinContent(cx+1,cy+1); float c2 = inputMap[i+1][j]->GetBinContent(cx+1,cy+1); if(c1 != 0) comparisonMap[i][j]->Fill(cx,cy,(c2-c1)/c1); } } canvas[i][j]->cd(); comparisonMap[i][j]->Draw("COLZ"); } } TFile *f = new TFile("outputCompareMap.root","RECREATE"); f->cd(); for(int i = 0 ; i < N-1 ; i++) { for(int j = 0 ; j < 2 ; j++) { canvas[i][j]->Write(); comparisonMap[i][j]->Write(); } } std::cout << "aaaaaaaa" << std::endl; // f->Close(); return 0; }
int main(int argc, char *argv[]) { #ifdef Q_OS_MAC // QTBUG-32789 - GUI widgets use the wrong font on OS X Mavericks QFont::insertSubstitution(".Lucida Grande UI", "Lucida Grande"); #endif SingleApplication theApp( argc, argv ); if(!theApp.shouldContinue())return 0; QStringList args = theApp.arguments(); QUrl proxy; int index = args.indexOf("-proxy"); if ( index != -1 ) proxy = QUrl( args.value(index + 1) ); else proxy = QUrl( qgetenv( "http_proxy" ) ); if ( !proxy.isEmpty() ) setApplicationProxy( proxy ); QByteArray encoding; index = args.indexOf( "-encoding" ); if ( index != -1 ) encoding = args.value( index + 1 ).toLocal8Bit(); else if ( !qgetenv( "COMMUNI_ENCODING" ).isEmpty()) encoding = qgetenv( "COMMUNI_ENCODING" ); if ( !encoding.isEmpty() ) SingleApplication::setEncoding( encoding ); // To enable this, run qmake with "DEFINES+=_SNAPSHOT_BUILD" #ifdef _SNAPSHOT_BUILD QDate oExpire = QDate::fromString( Version::BUILD_DATE, Qt::ISODate ).addDays( 60 ); if( QDate::currentDate() > oExpire ) { QMessageBox::information( NULL, QObject::tr( "Cool Software, but..." ), QObject::tr( "This build is expired. If you wish to continue using this " "Cool Software you must download either latest stable releas" "e or latest snapshot build from http://quazaa.sf.net/.\n\n" "The program will now terminate." ) ); return 0; } if( !args.contains("--no-alpha-warning") ) { int ret = QMessageBox::warning( NULL, QObject::tr("Snapshot/Debug Build Warning"), QObject::tr("WARNING: This is a SNAPSHOT BUILD of Quazaa. \n" "It is NOT meant for GENERAL USE, and is only for testi" "ng specific features in a controlled environment.\n" "It will frequently stop running, or will display debug" "information to assist testing.\n" "This build will expire on %1.\n\n" "Do you wish to continue?" ).arg( oExpire.toString( Qt::SystemLocaleLongDate ) ), QMessageBox::Yes | QMessageBox::No ); if( ret == QMessageBox::No ) return 0; } #endif qsrand( time( 0 ) ); #ifdef Q_OS_LINUX rlimit sLimit; memset( &sLimit, 0, sizeof( rlimit ) ); getrlimit( RLIMIT_NOFILE, &sLimit ); sLimit.rlim_cur = sLimit.rlim_max; if( setrlimit( RLIMIT_NOFILE, &sLimit ) == 0 ) { qDebug() << "Successfully raised resource limits"; } else { qDebug() << "Cannot set resource limits"; } #endif // Q_OS_LINUX theApp.setApplicationName( CQuazaaGlobals::APPLICATION_NAME() ); theApp.setApplicationVersion( CQuazaaGlobals::APPLICATION_VERSION_STRING() ); theApp.setOrganizationDomain( CQuazaaGlobals::APPLICATION_ORGANIZATION_DOMAIN() ); theApp.setOrganizationName( CQuazaaGlobals::APPLICATION_ORGANIZATION_NAME() ); theApp.setApplicationSlogan( QObject::tr("World class file sharing.") ); QIcon icon; icon.addFile( ":/Resource/Quazaa16.png" ); icon.addFile( ":/Resource/Quazaa24.png" ); icon.addFile( ":/Resource/Quazaa32.png" ); icon.addFile( ":/Resource/Quazaa48.png" ); icon.addFile( ":/Resource/Quazaa64.png" ); icon.addFile( ":/Resource/Quazaa128.png" ); qApp->setWindowIcon( icon ); // Initialize system log component translations systemLog.start(); // Setup Qt elements of signal queue necessary for operation signalQueue.setup(); //Initialize multilanguage support quazaaSettings.loadLanguageSettings(); quazaaSettings.translator.load( quazaaSettings.Language.File ); qApp->installTranslator( &quazaaSettings.translator ); //Create splash window CDialogSplash* dlgSplash = new CDialogSplash(); dlgSplash->show(); qApp->processEvents(); dlgSplash->updateProgress( 1, QObject::tr( "Loading settings..." ) ); qApp->processEvents(); //Initialize Settings quazaaSettings.loadSettings(); //Check if this is Quazaa's first run dlgSplash->updateProgress( 8, QObject::tr( "Checking for first run..." ) ); qApp->processEvents(); bool bFirstRun = quazaaSettings.isFirstRun(); if ( bFirstRun ) { CDialogLanguage* dlgLanguage = new CDialogLanguage(); dlgLanguage->exec(); dlgSplash->updateProgress( 10, QObject::tr( "Running Quick Start wizard..." ) ); quazaaSettings.saveFirstRun( false ); quazaaSettings.saveSettings(); quazaaSettings.saveProfile(); CWizardQuickStart* wzrdQuickStart = new CWizardQuickStart(); wzrdQuickStart->exec(); } // Load Security Manager dlgSplash->updateProgress( 15, QObject::tr( "Loading Security Manager..." ) ); qApp->processEvents(); if ( !securityManager.start() ) systemLog.postLog( LogSeverity::Information, QObject::tr( "Security data file was not available." ) ); // Load Discovery Services Manager dlgSplash->updateProgress( 22, QObject::tr( "Loading Discovery Services Manager..." ) ); qApp->processEvents(); discoveryManager.start(); //Load profile dlgSplash->updateProgress( 25, QObject::tr( "Loading Profile..." ) ); qApp->processEvents(); quazaaSettings.loadProfile(); //Load Host Cache dlgSplash->updateProgress( 30, QObject::tr( "Loading Host Cache..." ) ); qApp->processEvents(); hostCache.m_pSection.lock(); hostCache.load(); hostCache.m_pSection.unlock(); //initialize geoip list geoIP.loadGeoIP(); //Load the library dlgSplash->updateProgress( 38, QObject::tr( "Loading Library..." ) ); qApp->processEvents(); QueryHashMaster.Create(); ShareManager.Start(); // Load Download Manager dlgSplash->updateProgress( 60, QObject::tr( "Loading Transfer Manager..." ) ); qApp->processEvents(); Transfers.start(); dlgSplash->updateProgress( 80, QObject::tr( "Loading User Interface..." ) ); qApp->processEvents(); MainWindow = new CWinMain(); if ( quazaaSettings.WinMain.Visible ) { if(bFirstRun) MainWindow->showMaximized(); else MainWindow->show(); } dlgSplash->updateProgress( 90, QObject::tr( "Loading Tray Icon..." ) ); qApp->processEvents(); MainWindow->loadTrayIcon(); dlgSplash->updateProgress( 100, QObject::tr( "Welcome to Quazaa!" ) ); qApp->processEvents(); dlgSplash->deleteLater(); dlgSplash = 0; // Start networks if needed if ( quazaaSettings.System.ConnectOnStartup ) { if ( quazaaSettings.Gnutella2.Enable ) { Network.Connect(); } } return theApp.exec(); }
bool WorkAreaManager::unhide(Buffer * buf) { if (!work_areas_.empty()) return true; return theApp()->unhide(buf); }
void InsetInfo::updateInfo() { BufferParams const & bp = buffer().params(); switch (type_) { case UNKNOWN_INFO: error("Unknown Info: %1$s"); break; case SHORTCUT_INFO: case SHORTCUTS_INFO: { FuncRequest const func = lyxaction.lookupFunc(name_); if (func.action() == LFUN_UNKNOWN_ACTION) { error("Unknown action %1$s"); break; } KeyMap::Bindings bindings = theTopLevelKeymap().findBindings(func); if (bindings.empty()) { // It is impropriate to use error() for undefined shortcut setText(_("undefined")); break; } if (type_ == SHORTCUT_INFO) setText(bindings.begin()->print(KeySequence::Portable)); else setText(theTopLevelKeymap().printBindings(func, KeySequence::Portable)); break; } case LYXRC_INFO: { ostringstream oss; if (name_.empty()) { setText(_("undefined")); break; } lyxrc.write(oss, true, name_); string result = oss.str(); if (result.size() < 2) { setText(_("undefined")); break; } string::size_type loc = result.rfind("\n", result.size() - 2); loc = loc == string::npos ? 0 : loc + 1; if (result.size() < loc + name_.size() + 1 || result.substr(loc + 1, name_.size()) != name_) { setText(_("undefined")); break; } // remove leading comments and \\name and space result = result.substr(loc + name_.size() + 2); // remove \n and "" result = rtrim(result, "\n"); result = trim(result, "\""); setText(from_utf8(result)); break; } case PACKAGE_INFO: // check in packages.lst setText(LaTeXFeatures::isAvailable(name_) ? _("yes") : _("no")); break; case TEXTCLASS_INFO: { // name_ is the class name LayoutFileList const & list = LayoutFileList::get(); bool available = false; if (list.haveClass(name_)) available = list[name_].isTeXClassAvailable(); setText(available ? _("yes") : _("no")); break; } case MENU_INFO: { docstring_list names; FuncRequest const func = lyxaction.lookupFunc(name_); if (func.action() == LFUN_UNKNOWN_ACTION) { error("Unknown action %1$s"); break; } // iterate through the menubackend to find it if (!theApp()->searchMenu(func, names)) { error("No menu entry for action %1$s"); break; } // if found, return its path. clear(); Paragraph & par = paragraphs().front(); Font const f(inherit_font, buffer().params().language); //Font fu = f; //fu.fontInfo().setUnderbar(FONT_ON); docstring_list::const_iterator beg = names.begin(); docstring_list::const_iterator end = names.end(); for (docstring_list::const_iterator it = beg ; it != end ; ++it) { // do not insert > for the top level menu item if (it != beg) par.insertInset(par.size(), new InsetSpecialChar(InsetSpecialChar::MENU_SEPARATOR), Change(Change::UNCHANGED)); //FIXME: add proper underlines here. This // involves rewriting searchMenu used above to // return a vector of menus. If we do not do // that, we might as well use below // Paragraph::insert on each string (JMarc) for (size_type i = 0; i != it->length(); ++i) par.insertChar(par.size(), (*it)[i], f, Change(Change::UNCHANGED)); } break; } case ICON_INFO: { FuncRequest func = lyxaction.lookupFunc(name_); docstring icon_name = theApp()->iconName(func, true); //FIXME: We should use the icon directly instead of // going through FileName. The code below won't work // if the icon is embedded in the executable through // the Qt resource system. FileName file(to_utf8(icon_name)); if (!file.exists()) break; InsetGraphics * inset = new InsetGraphics(buffer_); InsetGraphicsParams igp; igp.filename = file; inset->setParams(igp); clear(); paragraphs().front().insertInset(0, inset, Change(Change::UNCHANGED)); break; } case BUFFER_INFO: { if (name_ == "name") { setText(from_utf8(buffer().fileName().onlyFileName())); break; } if (name_ == "path") { setText(from_utf8(buffer().filePath())); break; } if (name_ == "class") { setText(from_utf8(bp.documentClass().name())); break; } // everything that follows is for version control. // nothing that isn't version control should go below this line. if (!buffer().lyxvc().inUse()) { setText(_("No version control")); break; } LyXVC::RevisionInfo itype = LyXVC::Unknown; if (name_ == "vcs-revision") itype = LyXVC::File; else if (name_ == "vcs-tree-revision") itype = LyXVC::Tree; else if (name_ == "vcs-author") itype = LyXVC::Author; else if (name_ == "vcs-time") itype = LyXVC::Time; else if (name_ == "vcs-date") itype = LyXVC::Date; string binfo = buffer().lyxvc().revisionInfo(itype); if (binfo.empty()) setText(bformat(_("[[%1$s unknown]]"), from_utf8(name_))); else setText(from_utf8(binfo)); break; } case LYX_INFO: if (name_ == "version") setText(from_ascii(PACKAGE_VERSION)); break; } }