Example #1
0
bool FileType::operator==(const FileType &pFileType) const
{
    // Return whether the current item is equal to the given one

    return    !mMimeType.compare(pFileType.mimeType())
           && !mFileExtension.compare(pFileType.fileExtension());
}
Example #2
0
void ConsoleTools::profile(int loopCount){
  clock_t msecs;

  // parsers factory
  ParserFactory pf(catalogPath);
  // Source file text lines store.
  TextLinesStore textLinesStore;
  textLinesStore.loadFile(inputFileName, inputEncoding, true);
  // Base editor to make primary parse
  BaseEditor baseEditor(&pf, &textLinesStore);
  // HRD RegionMapper linking
  baseEditor.setRegionMapper(&DString("console"), hrdName);
  FileType *type = selectType(pf.getHRCParser(), &textLinesStore);
  type->getBaseScheme();
  baseEditor.setFileType(type);

  msecs = clock();
  while(loopCount--){
    baseEditor.modifyLineEvent(0);
    baseEditor.lineCountEvent(textLinesStore.getLineCount());
    baseEditor.validate(-1, false);
  }
  msecs = clock() - msecs;

  printf("%ld\n", (msecs*1000)/CLOCKS_PER_SEC );
}
Example #3
0
bool FileGroup::AddFile(const FileType &NewFile)
// Never will there be duplicate files within a FileGroup...
// It is just not gonna be allowed by definition.
{
	if (NewFile.IsValid())
	{
		if (!binary_search(myFiles.begin(), myFiles.end(), NewFile))
		{
			myFiles.insert(lower_bound(myFiles.begin(), myFiles.end(), NewFile), 
				       NewFile);
		}
		else
		{
			// If the filenames are the same, then check to see which one is bigger (filesize-wise)
			// and keep that one.
			FileIter FileIter = lower_bound(myFiles.begin(), myFiles.end(), NewFile);
			if (NewFile.GiveFileSize() > FileIter->GiveFileSize())
			{
				// The NewFile's filesize is larger than the one I already have.  Replace it!
				*FileIter = NewFile;
			}
		}

		return(true);
	}
	else
	{
		return(false);
	}
}
Example #4
0
void ConsoleTools::listTypes(bool load, bool useNames){
  Writer *writer = null;
  try{
    writer = new StreamWriter(stdout, outputEncodingIndex, bomOutput);
    ParserFactory pf(catalogPath);
    HRCParser *hrcParser = pf.getHRCParser();
    fprintf(stderr, "\nloading file types...\n");
    for(int idx = 0;; idx++){
      FileType *type = hrcParser->enumerateFileTypes(idx);
      if (type == null) break;
      if (useNames){
        writer->write(StringBuffer(type->getName())+"\n");
      }else{
        if (type->getGroup() != null){
          writer->write(StringBuffer(type->getGroup()) + ": ");
        }
        writer->write(type->getDescription());
        writer->write(DString("\n"));
      }

      if (load) type->getBaseScheme();
    }
    delete writer;
  }catch(Exception &e){
    delete writer;
    fprintf(stderr, "%s\n", e.getMessage()->getChars());
  }
}
FileType *ColorerFilter::selectType(HRCParser *hrcParser, String *fline)
{
    FileType *type = null;
    if (typeDescription != null) {
        type = hrcParser->getFileType(typeDescription);
        if (type == null) {
            for(int idx = 0;; idx++)
            {
                type = hrcParser->enumerateFileTypes(idx);
                if (type == null) {
                    break;
                }
                if (type->getDescription() != null &&
                    type->getDescription()->length() >= typeDescription->length() &&
                    DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) {
                    break;
                }
                if (type->getName()->length() >= typeDescription->length() &&
                    DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription)) {
                    break;
                }
                type = null;
            }
        }
    }

    if (typeDescription == null || type == null) {
        type = hrcParser->chooseFileType(inputFileName, fline, 0);
    }
    return type;
}
Example #6
0
FileType *ConsoleTools::selectType(HRCParser *hrcParser, LineSource *lineSource){
  FileType *type = null;
  if (typeDescription != null){
    type = hrcParser->getFileType(typeDescription);
    if (type == null){
      for(int idx = 0;; idx++){
        type = hrcParser->enumerateFileTypes(idx);
        if (type == null) break;
        if (type->getDescription() != null &&
            type->getDescription()->length() >= typeDescription->length() &&
            DString(type->getDescription(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription))
          break;
        if (type->getName()->length() >= typeDescription->length() &&
            DString(type->getName(), 0, typeDescription->length()).equalsIgnoreCase(typeDescription))
          break;
        type = null;
      }
    }
  }
  if (typeDescription == null || type == null){
    StringBuffer textStart;
    int totalLength = 0;
    for(int i = 0; i < 4; i++){
      String *iLine = lineSource->getLine(i);
      if (iLine == null) break;
      textStart.append(iLine);
      textStart.append(DString("\n"));
      totalLength += iLine->length();
      if (totalLength > 500) break;
    }
    type = hrcParser->chooseFileType(inputFileName, &textStart, 0);
  }
  return type;
}
Example #7
0
FileType *BaseEditor::chooseFileType(const String *fileName)
{
  if (lineSource == null)
  {
    currentFileType = hrcParser->chooseFileType(fileName, null);
  }
  else
  {
    int chooseStr=CHOOSE_STR, chooseLen=CHOOSE_LEN;
    DString dsd("default");
    FileType *def = hrcParser->getFileType(&dsd);
    if(def)
    {
      chooseStr = def->getParamValueInt(DString("firstlines"), chooseStr);
      chooseLen = def->getParamValueInt(DString("firstlinebytes"), chooseLen);
    }
    
    currentFileType = chooseFileTypeCh(fileName, chooseStr, chooseLen);
  }
  setFileType(currentFileType);
  return currentFileType;
}
 void loadInitialMaps_(vector<MapType>& maps, StringList& ins, 
                       FileType& input_file)
 {
   // custom progress logger for this task:
   ProgressLogger progresslogger;
   progresslogger.setLogType(TOPPMapAlignerBase::log_type_);
   progresslogger.startProgress(0, ins.size(), "loading input files");
   for (Size i = 0; i < ins.size(); ++i)
   {
     progresslogger.setProgress(i);
     input_file.load(ins[i], maps[i]);
   }
   progresslogger.endProgress();
 }
Example #9
0
bool FileInfo::IsImageFile(FileType fileType)
{
	switch(fileType.ToInt())
	{
	case FileType::jpeg.IntValue:
	case FileType::png.IntValue:
	case FileType::pvr.IntValue:
	case FileType::gif.IntValue:
		return true;
	default:
		return false;

	}
}
 void storeTransformedMaps_(vector<MapType>& maps, StringList& outs, 
                            FileType& output_file)
 {
   // custom progress logger for this task:
   ProgressLogger progresslogger;
   progresslogger.setLogType(log_type_);
   progresslogger.startProgress(0, outs.size(), "writing output files");
   for (Size i = 0; i < outs.size(); ++i)
   {
     progresslogger.setProgress(i);
     // annotate output with data processing info:
     addDataProcessing_(maps[i], 
                        getProcessingInfo_(DataProcessing::ALIGNMENT));
     output_file.store(outs[i], maps[i]);
   }
   progresslogger.endProgress();
 }
Example #11
0
template<class FileType> void ZMO::init(FileType& file) {
	char buf[0x10] = { 0x00 };
	file.readStringWithGivenLength(8, buf);
	if (_stricmp("ZMO0002", buf))
		return;

	this->animationInfo.framesPerSecond = static_cast<word_t>(file.read<dword_t>());
	this->animationInfo.framesInTotal = static_cast<word_t>(file.read<dword_t>())+1;

	this->animationInfo.defaultTime = static_cast<word_t>(static_cast<float>(this->animationInfo.framesInTotal) / static_cast<float>(this->animationInfo.framesPerSecond) * 1000);

	//last 4 bytes are the ZMO-version type (e.g. 3ZMO)
	//The previous 10 bytes: an offset or anything of the sorts seems to be hiddin in there.
	file.setPosition(file.getTotalSize() - 14 - sizeof(word_t)*this->animationInfo.framesInTotal);
#ifdef __ROSE_ZMO_OUTPUT__
	std::cout << "[" << this->filePath.c_str() << "] Total time: " << this->animationInfo.defaultTime << "\n";
#endif
	word_t *newContent = new word_t[this->animationInfo.framesInTotal];
	for (unsigned int i = 0; i < this->animationInfo.framesInTotal; i++) {
		word_t currentType = file.read<word_t>();
		newContent[i] = currentType;
		if (i > 0 && (currentType >= 21 && currentType <= 29)) { //Dunno what this means, but it seems to be a valid indicator?

			/* current frame - 3, because the server may need up to 100ms to perform the actual action. 
				(3 * (1000ms / 30FPS) = 100ms -> the offset we need. 
			*/
			float percentage = static_cast<float>(i-3) / static_cast<float>(this->animationInfo.framesInTotal);
			ZMO::TimingInfo::Frame newFrame;

			dword_t storedPosition = file.getPosition();
			file.setPosition(storedPosition - sizeof(word_t)*3);
			newFrame.motionType = file.read<word_t>();
			file.setPosition(storedPosition);

			newFrame.timeToReach = static_cast<word_t>(percentage * this->animationInfo.defaultTime);
			this->timingInfo.attacksAtFrames.insert(std::pair<word_t, ZMO::TimingInfo::Frame>(i - 3, newFrame));
#ifdef __ROSE_ZMO_OUTPUT__
			auto it = this->timingInfo.attacksAtFrames.at(i - 3);
			std::cout << "Found attackPattern at " << percentage * 100.0f << "%\t| " << it.timeToReach << "ms\n";
#endif
		}
	}
	this->content.init(newContent, this->animationInfo.framesInTotal);

	delete[] newContent;
	newContent = nullptr;

	this->animationInfo.framesInTotal--;
#ifdef __ROSE_ZMO_OUTPUT__
		std::cout << "\n";
#endif
}
Example #12
0
void
SessionImpl::RegisterFileType (/*[in]*/ FileType	fileType,
                                        /*[in]*/ const char *	lpszFileType,
                                        /*[in]*/ const char *	lpszApplication,
                                        /*[in]*/ const char *	lpszFileNameExtensions,
                                        /*[in]*/ const char *	lpszAlternateExtensions,
                                        /*[in]*/ const char *	lpszDefaultSearchPath,
                                        /*[in]*/ const char *	lpszEnvVarNames)
{
    MIKTEX_ASSERT_STRING (lpszFileType);
    MIKTEX_ASSERT_STRING_OR_NIL (lpszApplication);
    InternalFileTypeInfo fti;
    fti.fileType = fileType;
    fti.fileTypeString = lpszFileType;
    if (lpszApplication != 0)
    {
        fti.applicationName = lpszApplication;
    }
    string section = "ft.";
    section += lpszFileType;
    fti.fileNameExtensions =
        GetConfigValue(section.c_str(),
                       "extensions",
                       lpszFileNameExtensions );
    fti.alternateExtensions = GetConfigValue(section.c_str(),
                              "alternate_extensions",
                              lpszAlternateExtensions == 0 ? "" : lpszAlternateExtensions);
    fti.searchPath =
        GetConfigValue(section.c_str(),
                       "path",
                       lpszDefaultSearchPath);
    fti.envVarNames =
        GetConfigValue(section.c_str(),
                       "env",
                       lpszEnvVarNames);
    fileTypes.resize (FileType::E_N_D);
    fileTypes[fileType.Get()] = fti;
}
  void NewFileChooser::setFileTypes(QPtrList<FileType> filetypes) {
    for(FileType * filetype = filetypes.first();
	filetype;
	filetype=filetypes.next()) {

      if (filetype->enabled()) {

	if (filetype->subtypes().count()==0)
          addType(filetype);

	QPtrList<FileType> subtypes = filetype->subtypes();
	for(FileType * subtype = subtypes.first();
	    subtype;
	    subtype=subtypes.next()) {
	  if (subtype->enabled())
            addType(subtype);

	}

      }

    }

  }
Example #14
0
void FarEditor::reloadTypeSettings()
{
  FileType *ftype = baseEditor->getFileType();
  HRCParser *hrcParser = parserFactory->getHRCParser();

  FileType *def = hrcParser->getFileType(&DString("default"));
  if (def == null){
    throw Exception(DString("No 'default' file type found"));
  }

  int backparse = 2000;

  UnicodeTools::getNumber(def->getParamValue(DString("backparse")), &backparse);
  UnicodeTools::getNumber(def->getParamValue(DString("maxlinelength")), &maxLineLength);
  UnicodeTools::getNumber(def->getParamValue(DString("default-fore")), &newfore);
  UnicodeTools::getNumber(def->getParamValue(DString("default-back")), &newback);
  const String *value;
  value = def->getParamValue(DString("fullback"));
  if (value != null && value->equals("no")) fullBackground = false;
  value = def->getParamValue(DString("show-cross"));
  if (value != null && value->equals("none")){
    showHorizontalCross = false;
    showVerticalCross   = false;
  };
  if (value != null && value->equals("vertical")){
    showHorizontalCross = false;
    showVerticalCross   = true;
  };
  if (value != null && value->equals("horizontal")){
    showHorizontalCross = true;
    showVerticalCross   = false;
  };
  if (value != null && value->equals("both")){
    showHorizontalCross = true;
    showVerticalCross   = true;
  };
  value = def->getParamValue(DString("cross-zorder"));
  if (value != null && value->equals("top")) crossZOrder = 1;

  // installs custom file properties
  UnicodeTools::getNumber(ftype->getParamValue(DString("backparse")), &backparse);
  UnicodeTools::getNumber(ftype->getParamValue(DString("maxlinelength")), &maxLineLength);
  UnicodeTools::getNumber(ftype->getParamValue(DString("default-fore")), &newfore);
  UnicodeTools::getNumber(ftype->getParamValue(DString("default-back")), &newback);
  value = ftype->getParamValue(DString("fullback"));
  if (value != null && value->equals("no")) fullBackground = false;
  value = ftype->getParamValue(DString("show-cross"));
  if (value != null && value->equals("none")){
    showHorizontalCross = false;
    showVerticalCross   = false;
  };
  if (value != null && value->equals("vertical")){
    showHorizontalCross = false;
    showVerticalCross   = true;
  };
  if (value != null && value->equals("horizontal")){
    showHorizontalCross = true;
    showVerticalCross   = false;
  };
  if (value != null && value->equals("both")){
    showHorizontalCross = true;
    showVerticalCross   = true;
  };
  value = ftype->getParamValue(DString("cross-zorder"));
  if (value != null && value->equals("top")) crossZOrder = 1;

  baseEditor->setBackParse(backparse);
}
Example #15
0
bool
SessionImpl::TryCreateFile (/*[in]*/ const char * lpszFileName,
                                     /*[in]*/ FileType	  fileType)
{
    CommandLineBuilder commandLine;
    PathName makeUtility;
    char szBasename[BufferSizes::MaxPath];
    PathName::Split (lpszFileName, 0, 0, szBasename, BufferSizes::MaxPath, 0, 0);
    switch (fileType.Get())
    {
    case FileType::BASE:
    case FileType::FMT:
        if (! FindFile(MIKTEX_INITEXMF_EXE, FileType::EXE, makeUtility))
        {
            FATAL_MIKTEX_ERROR ("SessionImpl::TryCreateFile",
                                T_("The MiKTeX configuration utility could not be found."),
                                0);
        }
        commandLine.AppendOption ("--dump-by-name=", szBasename);
        if (fileType == FileType::FMT)
        {
            commandLine.AppendOption ("--engine=", GetEngine());
        }
        break;
    case FileType::TFM:
        if (! FindFile(MIKTEX_MAKETFM_EXE, FileType::EXE, makeUtility))
        {
            FATAL_MIKTEX_ERROR ("SessionImpl::TryCreateFile",
                                T_("The MakeTFM utility could not be found."),
                                0);
        }
        commandLine.AppendOption ("-v");
        commandLine.AppendArgument (szBasename);
        break;
    default:
        return (false);
    }
    const size_t BUF_SIZE = 50000;
    char * szBuf = reinterpret_cast<char*>(malloc(BUF_SIZE));
    if (szBuf == 0)
    {
        OUT_OF_MEMORY ("malloc");
    }
    AutoMemoryPointer xxx (szBuf);
    size_t size = BUF_SIZE;
    int exitCode;
    if (! Process::Run(makeUtility,
                       commandLine.Get(),
                       szBuf,
                       &size,
                       &exitCode))
    {
        return (false);
    }
    if (exitCode != 0)
    {
        TraceError (T_("Make failed; output follows"));
        TraceError ("%.*s", static_cast<int>(size), szBuf);
        return (false);
    }
    return (true);
}
void FileType::setSubtypesEnabled(bool enabled) {
  for(FileType * subtype = m_subtypes.first();
      subtype;subtype=m_subtypes.next())
    subtype->setEnabled(enabled);
}
	const bool operator ==(const FileType& file, const std::wstring& type)
	{
		return file.RelationType() == type;
	}
	const bool operator ==(const std::wstring& type, const FileType& file)
	{
		return type == file.RelationType();
	}
Example #19
0
void ConsoleTools::genOutput(bool useTokens){
  try{
    // Source file text lines store.
    TextLinesStore textLinesStore;
    textLinesStore.loadFile(inputFileName, inputEncoding, true);
    // parsers factory
    ParserFactory pf(catalogPath);
    // HRC loading
    HRCParser *hrcParser = pf.getHRCParser();
    // HRD RegionMapper creation
    bool useMarkup = false;
    RegionMapper *mapper = null;
    if (!useTokens){
      try{
        mapper = pf.createStyledMapper(&DString("rgb"), hrdName);
      }catch(ParserFactoryException &){
        useMarkup = true;
        mapper = pf.createTextMapper(hrdName);
      }
    }
    // Base editor to make primary parse
    BaseEditor baseEditor(&pf, &textLinesStore);
    // Using compact regions
    baseEditor.setRegionCompact(true);
    baseEditor.setRegionMapper(mapper);
    baseEditor.lineCountEvent(textLinesStore.getLineCount());
    // Choosing file type
    FileType *type = selectType(hrcParser, &textLinesStore);
    baseEditor.setFileType(type);

    //  writing result into HTML colored stream...
    const RegionDefine *rd = null;
    if (mapper != null) rd = baseEditor.rd_def_Text;

    Writer *escapedWriter = null;
    Writer *commonWriter = null;
    try{
      if (outputFileName != null) commonWriter = new FileWriter(outputFileName, outputEncodingIndex, bomOutput);
      else commonWriter = new StreamWriter(stdout, outputEncodingIndex, bomOutput);
      if (htmlEscaping) escapedWriter = new HtmlEscapesWriter(commonWriter);
      else escapedWriter = commonWriter;
    }catch(Exception &e){
      fprintf(stderr, "can't open file '%s' for writing:\n", outputFileName->getChars());
      fprintf(stderr, e.getMessage()->getChars());
      return;
    }

    if (htmlWrapping && useTokens){
      commonWriter->write(DString("<html>\n<head>\n<style></style>\n</head>\n<body><pre>\n"));
    }else if (htmlWrapping && rd != null){
      if (useMarkup){
        commonWriter->write(TextRegion::cast(rd)->stext);
      }else{
        commonWriter->write(DString("<html><body style='"));
        ParsedLineWriter::writeStyle(commonWriter, StyledRegion::cast(rd));
        commonWriter->write(DString("'><pre>\n"));
      }
    }

    if (copyrightHeader){
      commonWriter->write(DString("Created with colorer-take5 library. Type '"));
      commonWriter->write(type->getName());
      commonWriter->write(DString("'\n\n"));
    }

    int lni = 0;
    int lwidth = 1;
    int lncount = textLinesStore.getLineCount();
    for(lni = lncount/10; lni > 0; lni = lni/10, lwidth++);

    for(int i = 0; i < lncount; i++){
      if (lineNumbers){
        int iwidth = 1;
        for(lni = i/10; lni > 0; lni = lni/10, iwidth++);
        for(lni = iwidth; lni < lwidth; lni++) commonWriter->write(0x0020);
        commonWriter->write(SString(i));
        commonWriter->write(DString(": "));
      }
      if (useTokens){
        ParsedLineWriter::tokenWrite(commonWriter, escapedWriter, docLinkHash, textLinesStore.getLine(i), baseEditor.getLineRegions(i));
      }else if (useMarkup){
        ParsedLineWriter::markupWrite(commonWriter, escapedWriter, docLinkHash, textLinesStore.getLine(i), baseEditor.getLineRegions(i));
      }else{
        ParsedLineWriter::htmlRGBWrite(commonWriter, escapedWriter, docLinkHash, textLinesStore.getLine(i), baseEditor.getLineRegions(i));
      }
      commonWriter->write(DString("\n"));
    }

    if (htmlWrapping && useTokens){
      commonWriter->write(DString("</pre></body></html>\n"));
    }else if (htmlWrapping && rd != null){
      if (useMarkup){
        commonWriter->write(TextRegion::cast(rd)->etext);
      }else{
        commonWriter->write(DString("</pre></body></html>\n"));
      }
    }

    if (htmlEscaping) delete commonWriter;
    delete escapedWriter;

    delete mapper;
  }catch(Exception &e){
    fprintf(stderr, "%s\n", e.getMessage()->getChars());
  }catch(...){
    fprintf(stderr, "unknown exception ...\n");
  }
}
Example #20
0
void
SessionImpl::RegisterFileType (/*[in]*/ FileType fileType)
{
    if (fileType.Get() >= fileTypes.size())
    {
        fileTypes.resize (FileType::E_N_D);
    }


    if (fileTypes[fileType.Get()].fileType == fileType.Get())
    {
        // already registered
        return;
    }

    switch (fileType.Get())
    {

    case FileType::AFM:
        RegisterFileType (
            FileType::AFM,
            "afm",
            0,
            ".afm",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_AFM_DIR)),
            P2_("AFMFONTS", "TEXFONTS"));
        break;

    case FileType::BASE:
        RegisterFileType (
            FileType::BASE,
            "base",
            "METAFONT",
            ".base",
            P2_(CURRENT_DIRECTORY, s_(MIKTEX_PATH_BASE_DIR)),
            "");
        break;

    case FileType::BIB:
        RegisterFileType (
            FileType::BIB,
            "bib",
            "BibTeX",
            ".bib",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/bib")),
            P2_("BIBINPUTS", "TEXBIB"));
        break;

    case FileType::BST:
        RegisterFileType (
            FileType::BST,
            "bst",
            "BibTeX",
            ".bst",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/{bst,csf}")),
            "BSTINPUTS");
        break;

    case FileType::CID:
        RegisterFileType (
            FileType::CID,
            "cid maps",
            0,
            P2_(".cid", ".cidmap"),
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_CIDMAP_DIR)),
            "FONTCIDMAPS");
        break;

    case FileType::CLUA:
        RegisterFileType (
            FileType::CLUA,
            "clua",
            0,
            P2_(".dll", ".so"),
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_SCRIPT_DIR "/{$progname,$engine,}/lua")),
            "CLUAINPUTS");
        break;

    case FileType::CNF:
        RegisterFileType (
            FileType::CNF,
            "cnf",
            0,
            ".cnf",
            S_(MIKTEX_PATH_WEB2C_DIR),
            "TEXMFCNF");
        break;

    case FileType::CMAP:
        RegisterFileType (
            FileType::CMAP,
            "cmap files",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_CMAP_DIR)),
            P2_("CMAPFONTS", "TEXFONTS"));
        break;

    case FileType::CWEB:
        RegisterFileType (
            FileType::CWEB,
            "cweb",
            "CWeb",
            ".w",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_CWEB_DIR)),
            "CWEBINPUTS");
        break;

    case FileType::DB:
        RegisterFileType (
            FileType::DB,
            "ls-R",
            0,
            "",
            "",
            "TEXMFDBS");
        break;

    case FileType::DVI:
        RegisterFileType (
            FileType::DVI,
            "dvi",
            0,
            ".dvi",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_DOC_DIR)),
            "");
        break;

    case FileType::DVIPSCONFIG:
        RegisterFileType (
            FileType::DVIPSCONFIG,
            "dvips config",
            "Dvips",
            "",
            R_(MIKTEX_PATH_DVIPS_DIR),
            "TEXCONFIG");
        break;

    case FileType::ENC:
        RegisterFileType (
            FileType::ENC,
            "enc",
            0,
            ".enc",
            P6_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_ENC_DIR),
                R_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                R_(MIKTEX_PATH_DVIPS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_DVIPDFM_DIR)),
            P2_("ENCFONTS", "TEXFONTS"));
        break;

    case FileType::EXE:
#if defined(MIKTEX_WINDOWS)
    case FileType::WindowsCommandScriptFile:
#endif
    {
        string extensions;
#if defined(MIKTEX_WINDOWS)
        if (! Utils::GetEnvironmentString("PATHEXT", extensions)
                || extensions.empty())
        {
            extensions = P3_(".com",".exe", ".bat");
        }
#elif defined(MIKTEX_EXE_FILE_SUFFIX)
        extensions = MIKTEX_EXE_FILE_SUFFIX;
#endif
        string exePath;
        PathName userBinDir = GetSpecialPath(SpecialPath::UserInstallRoot);
        userBinDir += MIKTEX_PATH_BIN_DIR;
        userBinDir.Canonicalize ();
        if (! IsAdminMode()
                && ! Utils::Contains(exePath.c_str(),
                                     userBinDir.Get(),
                                     PATH_DELIMITER_STRING))
        {
            if (! exePath.empty())
            {
                exePath += PATH_DELIMITER;
            }
            exePath += userBinDir.Get();
        }
        PathName commonBinDir = GetSpecialPath(SpecialPath::CommonInstallRoot);
        commonBinDir += MIKTEX_PATH_BIN_DIR;
        commonBinDir.Canonicalize ();
        if (! Utils::Contains(exePath.c_str(),
                              commonBinDir.Get(),
                              PATH_DELIMITER_STRING))
        {
            if (! exePath.empty())
            {
                exePath += PATH_DELIMITER;
            }
            exePath += commonBinDir.Get();
        }
        string str;
        if (Utils::GetEnvironmentString(MIKTEX_ENV_BIN_DIR, str))
        {
            PathName binDir = str;
            binDir.Canonicalize ();
            if (! Utils::Contains(exePath.c_str(),
                                  binDir.Get(),
                                  PATH_DELIMITER_STRING))
            {
                if (! exePath.empty())
                {
                    exePath += PATH_DELIMITER;
                }
                exePath += binDir.Get();
            }
        }
        PathName myLocation = GetMyLocation(true);
        if (! Utils::Contains(exePath.c_str(),
                              myLocation.Get(),
                              PATH_DELIMITER_STRING))
        {
            if (! exePath.empty())
            {
                exePath += PATH_DELIMITER;
            }
            exePath += myLocation.Get();
        }
        if (fileType.Get() == FileType::EXE)
        {
            RegisterFileType (
                FileType::EXE,
                "exe",
                0,
                extensions.c_str(),
                exePath.c_str(),
                "");
        }
#if defined(MIKTEX_WINDOWS)
        else if (fileType.Get() == FileType::WindowsCommandScriptFile)
        {
            RegisterFileType (
                FileType::WindowsCommandScriptFile,
                "Windows command script file",
                0,
                P2_(".bat", ".cmd"),
                P_(R_(MIKTEX_PATH_SCRIPT_DIR), exePath.c_str()),
                "");
        }
#endif
        break;
    }

    case FileType::FEA:
        RegisterFileType (
            FileType::FEA,
            "font feature files",
            0,
            ".fea",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_FEATURE_DIR)),
            "FONTFEATURES");
        break;

    case FileType::FMT:
        RegisterFileType (
            FileType::FMT,
            "fmt",
            "TeX",
            ".fmt",
            P2_(CURRENT_DIRECTORY, s_(MIKTEX_PATH_FMT_DIR "/{$engine,}")),
            "");
        break;

    case FileType::GF:
        RegisterFileType (
            FileType::GF,
            "gf",
            0,
            ".gf",
            // <todo>
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_DIR)),
            // <todo/>
            P3_("GFFONTS", "GLYPHFONTS", "TEXFONTS"));
        break;

    case FileType::GLYPHFONT:
        RegisterFileType (
            FileType::GLYPHFONT,
            "bitmap font",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_DIR)),
            P2_("GLYPHFONTS", "TEXFONTS"));
        break;

    case FileType::GRAPHICS:
        RegisterFileType (
            FileType::GRAPHICS,
            "graphic/figure",
            0,
            P3_(".eps", ".epsi",".png"),
            P4_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_DVIPS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_TEX_DIR)),
            P2_("TEXPICTS", "TEXINPUTS"));
        break;

    case FileType::HBF:
        RegisterFileType (
            FileType::HBF,
            "hbf",
            0,
            ".hbf",
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_HBF_DIR),
                R_(MIKTEX_PATH_TYPE1_DIR)),
            "");
        break;

    case FileType::IST:
        RegisterFileType (
            FileType::IST,
            "ist",
            "MakeIndex",
            ".ist",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MAKEINDEX_DIR)),
            P2_("TEXINDEXSTYLE", "INDEXSTYLE"));
        break;

    case FileType::LIG:
        RegisterFileType (
            FileType::LIG,
            "lig files",
            0,
            ".lig",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_LIG_DIR)),
            "TEXFONTS");
        break;

    case FileType::LUA:
        RegisterFileType (
            FileType::LUA,
            "lua",
            0,
            P7_(".lua", ".luatex", ".luc", ".luctex", ".texlua", ".texluc", ".tlu"),
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_SCRIPT_DIR "/{$progname,$engine,}/{lua,}"),
               GetFileTypeInfo(FileType::TEX).searchPath.c_str()),
            "LUAINPUTS");
        break;

    case FileType::MAP:
        RegisterFileType (
            FileType::MAP,
            "map",
            0,
            ".map",
            P6_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_MAP_DIR "/{$progname,pdftex,dvips,}"),
                R_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                R_(MIKTEX_PATH_DVIPS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_DVIPDFM_DIR)),
            P2_("TEXFONTMAPS", "TEXFONTS"));
        break;

    case FileType::MEM:
        RegisterFileType (
            FileType::MEM,
            "mem",
            "MetaPost",
            ".mem",
            CURRENT_DIRECTORY,
            "");
        break;

    case FileType::MF:
        RegisterFileType (
            FileType::MF,
            "mf",
            "METAFONT",
            ".mf",
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_METAFONT_DIR),
                R_(MIKTEX_PATH_FONT_SOURCE_DIR)),
            "MFINPUTS");
        break;

    case FileType::MFPOOL:
        RegisterFileType (
            FileType::MFPOOL,
            "mfpool",
            0,
            ".pool",
            CURRENT_DIRECTORY,
            P2_("MFPOOL", "TEXMFINI"));
        break;

    case FileType::MFT:
        RegisterFileType (
            FileType::MFT,
            "mft",
            0,
            ".mft",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MFT_DIR)),
            "MFTINPUTS");
        break;

    case FileType::MISCFONT:
        RegisterFileType (
            FileType::MISCFONT,
            "misc fonts",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MISCFONTS_DIR)),
            P2_("MISCFONTS","TEXFONTS"));
        break;

    case FileType::MLBIB:
        RegisterFileType (
            FileType::MLBIB,
            "mlbib",
            0,
            P2_(".mlbib", ".bib"),
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/bib/{mlbib,}")),
            P3_("MLBIBINPUTS", "BIBINPUTS", "TEXBIB"));
        break;

    case FileType::MLBST:
        RegisterFileType (
            FileType::MLBST,
            "mlbst",
            0,
            ".bst",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_BIBTEX_DIR "/{mlbst,bst}")),
            P2_( "MLBSTINPUTS", "BSTINPUTS"));
        break;

    case FileType::MP:
        RegisterFileType (
            FileType::MP,
            "mp",
            "MetaPost",
            ".mp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_METAPOST_DIR)),
            "MPINPUTS");
        break;

    case FileType::MPPOOL:
        RegisterFileType (
            FileType::MPPOOL,
            "mppool",
            0,
            ".pool",
            CURRENT_DIRECTORY,
            P2_("MPPOOL", "TEXMFINI"));
        break;

    case FileType::MPSUPPORT:
        RegisterFileType (
            FileType::MPSUPPORT,
            "MetaPost support",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_MPSUPPORT_DIR)),
            "MPSUPPORT");
        break;

    case FileType::OCP:
        RegisterFileType (
            FileType::OCP,
            "ocp",
            "Omega",
            ".ocp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OCP_DIR)),
            "OCPINPUTS");
        break;

    case FileType::OFM:
        RegisterFileType (
            FileType::OFM,
            "ofm",
            "Omega",
            P2_(".ofm", ".tfm"),
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_OFM_DIR),
                R_(MIKTEX_PATH_TFM_DIR)),
            P2_("OFMFONTS", "TEXFONTS"));
        break;

    case FileType::OPL:
        RegisterFileType (
            FileType::OPL,
            "opl",
            0,
            ".opl",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OPL_DIR)),
            P2_("OPLFONTS", "TEXFONTS"));
        break;

    case FileType::OTP:
        RegisterFileType (
            FileType::OTP,
            "otp",
            "otp2ocp",
            ".otp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OTP_DIR)),
            "OTPINPUTS");
        break;

    case FileType::OTF:
        RegisterFileType (
            FileType::OTF,
            "opentype fonts",
            0,
            ".otf",
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_OPENTYPE_DIR),
               GetLocalFontDirectories().c_str()),
            P2_("OPENTYPEFONTS", "TEXFONTS"));
        break;

    case FileType::OVF:
        RegisterFileType (
            FileType::OVF,
            "ovf",
            0,
            ".ovf",
            P3_(CURRENT_DIRECTORY,
                R_(MIKTEX_PATH_OVF_DIR),
                R_(MIKTEX_PATH_VF_DIR)),
            P2_("OVFFONTS", "TEXFONTS"));
        break;

    case FileType::OVP:
        RegisterFileType (
            FileType::OVP,
            "ovp",
            0,
            ".ovp",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_OVP_DIR)),
            P2_("OVPFONTS", "TEXFONTS"));
        break;

    case FileType::PDFTEXCONFIG:
        RegisterFileType (
            FileType::PDFTEXCONFIG,
            "pdftex config",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_PDFTEX_DIR "/{$progname,}")),
            "PDFTEXCONFIG");
        break;

    case FileType::PERLSCRIPT:
        RegisterFileType (
            FileType::PERLSCRIPT,
            "perlscript",
            0,
            ".pl",
            P8_(R_(MIKTEX_PATH_SCRIPT_DIR),
                R_(MIKTEX_PATH_CONTEXT_DIR),
                R_(MIKTEX_PATH_MIKTEX_DIR),
                R_(MIKTEX_PATH_NTS_DIR),
                R_(MIKTEX_PATH_PDFTEX_DIR),
                R_(MIKTEX_PATH_PSUTILS_DIR),
                R_(MIKTEX_PATH_SOURCE_DIR),
                R_(MIKTEX_PATH_TEX_DIR)),
            "");
        break;

    case FileType::PK:
        RegisterFileType (
            FileType::PK,
            "pk",
            0,
            ".pk",
            // <todo>
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_FONT_DIR)),
            // </todo>
            "");
        break;

    case FileType::PROGRAMBINFILE:
        RegisterFileType (
            FileType::PROGRAMBINFILE,
            "other binary files",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_("/$progname")),
            "");
        break;

    case FileType::PROGRAMTEXTFILE:
        RegisterFileType (
            FileType::PROGRAMTEXTFILE,
            "other text files",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_("/$progname")),
            "");
        break;

    case FileType::PSHEADER:
        RegisterFileType (
            FileType::PSHEADER,
            "PostScript header",
            0,
            P2_(".pro", ".enc"),
            P10_(CURRENT_DIRECTORY,
                 R_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                 R_(MIKTEX_PATH_DVIPS_DIR),
                 R_(MIKTEX_PATH_PDFTEX_DIR),
                 R_(MIKTEX_PATH_DVIPDFM_DIR),
                 R_(MIKTEX_PATH_ENC_DIR),
                 R_(MIKTEX_PATH_TYPE1_DIR),
                 R_(MIKTEX_PATH_TYPE42_DIR),
                 R_(MIKTEX_PATH_TYPE3_DIR),
                 "$psfontdirs"),
            P2_("TEXPSHEADERS", "PSHEADERS"));
        break;

    case FileType::SCRIPT:
        RegisterFileType (
            FileType::SCRIPT,
            "texmfscripts",
            0,
            "",
            R_(MIKTEX_PATH_SCRIPT_DIR "/{$progname,$engine,}"),
            "TEXMFSCRIPTS");
        break;

    case FileType::SFD:
        RegisterFileType (
            FileType::SFD,
            "subfont definition files",
            0,
            ".sfd",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_SFD_DIR)),
            P2_("SFDFONTS", "TEXFONTS"));
        break;

    case FileType::TCX:
        RegisterFileType (
            FileType::TCX,
            "tcx",
            0,
            ".tcx",
            P3_(CURRENT_DIRECTORY,
                S_(MIKTEX_PATH_MIKTEX_CONFIG_DIR),
                S_(MIKTEX_PATH_WEB2C_DIR)),
            "");
        break;

    case FileType::TEX:
        RegisterFileType (
            FileType::TEX,
            "tex",
            "TeX",
            ".tex",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_TEX_DIR "/{$progname,generic,}")),
            "TEXINPUTS");
        break;

    case FileType::TEXPOOL:
        RegisterFileType (
            FileType::TEXPOOL,
            "texpool",
            0,
            ".pool",
            CURRENT_DIRECTORY,
            P2_("TEXPOOL", "TEXMFINI"));
        break;

    case FileType::TEXSOURCE:
        RegisterFileType (
            FileType::TEXSOURCE,
            "TeX system sources",
            0,
            "",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_SOURCE_DIR)),
            "TEXSOURCES");
        break;

    case FileType::TEXSYSDOC:
        RegisterFileType (
            FileType::TEXSYSDOC,
            "TeX system documentation",
            0,
#if defined(MIKTEX_WINDOWS)
            P6_(".chm", ".dvi", ".html", ".txt", ".pdf", ".ps"),
#else
            P5_(".dvi", ".html", ".txt", ".pdf", ".ps"),
#endif
            P2_(R_(MIKTEX_PATH_MIKTEX_DOC_DIR),
                R_(MIKTEX_PATH_DOC_DIR)),
            "TEXDOCS");
        break;

    case FileType::TFM:
        RegisterFileType (
            FileType::TFM,
            "tfm",
            0,
            ".tfm",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_TFM_DIR)),
            P2_("TFMFONTS", "TEXFONTS"));
        break;

    case FileType::TROFF:
        RegisterFileType (
            FileType::TROFF,
            "troff fonts",
            0,
            "",
            "",
            "TRFONTS");
        break;

    case FileType::TTF:
        RegisterFileType (
            FileType::TTF,
            "truetype fonts",
            0,
            P2_(".ttf", ".ttc"),
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_TRUETYPE_DIR),
               GetLocalFontDirectories().c_str()),
            P2_("TTFONTS", "TEXFONTS"));
        break;

    case FileType::TYPE1:
        RegisterFileType (
            FileType::TYPE1,
            "type1 fonts",
            0,
            P2_(".pfb", ".pfa"),
            P_(CURRENT_DIRECTORY,
               R_(MIKTEX_PATH_TYPE1_DIR),
               GetLocalFontDirectories().c_str()),
            P5_("T1FONTS", "T1INPUTS", "TEXFONTS", "TEXPSHEADERS", "PSHEADERS"));
        break;

    case FileType::TYPE42:
        RegisterFileType (
            FileType::TYPE42,
            "type42 fonts",
            0,
#if defined(MIKTEX_WINDOWS)
            ".t42",
#else
            P2_(".t42", ".T42"),
#endif
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_TYPE42_DIR)),
            P2_("T42FONTS", "TEXFONTS"));
        break;

    case FileType::VF:
        RegisterFileType (
            FileType::VF,
            "vf",
            0,
            ".vf",
            P2_(CURRENT_DIRECTORY, R_(MIKTEX_PATH_VF_DIR)),
            P2_("VFFONTS", "TEXFONTS"));
        break;

    case FileType::WEB:
        RegisterFileType (
            FileType::WEB,
            "web",
            0,
            ".web",
            R_(MIKTEX_PATH_WEB_DIR),
            "WEBINPUTS");
        break;

    case FileType::WEB2C:
        RegisterFileType (
            FileType::WEB2C,
            "web2c files",
            0,
            "",
            R_(MIKTEX_PATH_WEB2C_DIR),
            "");
        break;

    default:
        UNEXPECTED_CONDITION ("SessionImpl::RegisterFileType");
    }
}
Example #21
0
void FarEditor::reloadTypeSettings()
{
  FileType *ftype = baseEditor->getFileType();
  HRCParser *hrcParser = parserFactory->getHRCParser();
  DString ds("default") ;
  FileType *def = hrcParser->getFileType(&ds);

  if (def == nullptr){
    throw Exception(DString("No 'default' file type found"));
  }

  int backparse = def->getParamValueInt(DBackparse, 2000);
  maxLineLength = def->getParamValueInt(DMaxLen, 0);
  newfore = def->getParamValueInt(DDefFore, -1);
  newback = def->getParamValueInt(DDefBack, -1);
  const String *value;
  value = def->getParamValue(DFullback);

  if (value != nullptr && value->equals(&DNo)){
    fullBackground = false;
  }

  value = def->getParamValue(DShowCross);
  if (drawCross==2 && value != nullptr){
    if (value->equals(&DNone)){
      showHorizontalCross = false;
      showVerticalCross   = false;
    };

    if (value->equals(&DVertical)){
      showHorizontalCross = false;
      showVerticalCross   = true;
    };

    if (value->equals(&DHorizontal)){
      showHorizontalCross = true;
      showVerticalCross   = false;
    };

    if (value->equals(&DBoth)){
      showHorizontalCross = true;
      showVerticalCross   = true;
    };
  }

  value = def->getParamValue(DCrossZorder);

  if (value != nullptr && value->equals(&DTop)){
    crossZOrder = 1;
  }

  // installs custom file properties
  backparse = ftype->getParamValueInt(DBackparse, backparse);
  maxLineLength = ftype->getParamValueInt(DMaxLen, maxLineLength);
  newfore = ftype->getParamValueInt(DDefFore, newfore);
  newback = ftype->getParamValueInt(DDefBack, newback);
  value = ftype->getParamValue(DFullback);

  if (value != nullptr && value->equals(&DNo)){
    fullBackground = false;
  }

  value = ftype->getParamValue(DShowCross);

  if (drawCross==2 && value != nullptr){
    if (value->equals(&DNone)){
      showHorizontalCross = false;
      showVerticalCross   = false;
    };

    if (value->equals(&DVertical)){
      showHorizontalCross = false;
      showVerticalCross   = true;
    };

    if (value->equals(&DHorizontal)){
      showHorizontalCross = true;
      showVerticalCross   = false;
    };

    if (value->equals(&DBoth)){
      showHorizontalCross = true;
      showVerticalCross   = true;
    };
  }

  value = ftype->getParamValue(DCrossZorder);

  if (value != nullptr && value->equals(&DTop)){
    crossZOrder = 1;
  }

  baseEditor->setBackParse(backparse);
}
int InteractiveApplication::run(int argc, char** argv)
{
   // Generate the XML files
   if (generateXml() == false)
   {
      return -1;
   }

   // Set the application to run in interactive mode
   ApplicationServicesImp* pApp = ApplicationServicesImp::instance();
   if (pApp != NULL)
   {
      pApp->setInteractive();
   }

   // Initialize the Qt application
   QApplication& qApplication = dynamic_cast<QApplication&>(getQApp());
#if !defined(LINUX)
   qApplication.setFont(QFont("Tahoma", 8));
#endif

   bool configSettingsValid = false;
   string configSettingsErrorMsg = "";

   ConfigurationSettingsImp* pConfigSettings = ConfigurationSettingsImp::instance();
   if (pConfigSettings != NULL)
   {
      configSettingsValid = pConfigSettings->isInitialized();
      if (pConfigSettings->getInitializationErrorMsg() != NULL)
      {
         configSettingsErrorMsg = pConfigSettings->getInitializationErrorMsg();
      }
      if (configSettingsValid)
      {
         pConfigSettings->validateInitialization();
         configSettingsValid = pConfigSettings->isInitialized();
         if (pConfigSettings->getInitializationErrorMsg() != NULL)
         {
            configSettingsErrorMsg = pConfigSettings->getInitializationErrorMsg();
         }
      }
   }

   if (!configSettingsValid)
   {
      if (configSettingsErrorMsg.empty())
      {
         configSettingsErrorMsg = "Unable to locate configuration settings";
      }

      reportError(configSettingsErrorMsg);
      return -1;
   }
   else
   {
      if (!configSettingsErrorMsg.empty())
      {
         reportWarning(configSettingsErrorMsg);
      }
   }

   { // scope the lifetime of the lock
      SessionSaveLock lock;

      // Create a progress object
      mpProgress = new ProgressAdapter();

      // Splash screen
      Q_INIT_RESOURCE(Application);
      SplashScreen* pSplash = new SplashScreen(mpProgress);
      vector<string> splashPaths = Service<InstallerServices>()->getSplashScreenPaths();
      pSplash->setSplashImages(list<string>(splashPaths.begin(), splashPaths.end()));
      pSplash->show();

      qApplication.processEvents();

      // process pending extension uninstalls
      InstallerServicesImp::instance()->processPending(mpProgress);
      string errMsg;
      if(!ConfigurationSettingsImp::instance()->loadSettings(errMsg))
      {
         if (QMessageBox::warning(pSplash, "Error loading configuration settings",
            QString("Warning: unable to reload application settings.\n%1\nContinue loading Opticks?").arg(QString::fromStdString(errMsg)),
            QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::No)
         {
            pSplash->close();
            delete pSplash;
            return -1;
         }
      }

      // Initialization
      int iReturn = Application::run(argc, argv);
      if (iReturn == -1)
      {
         pSplash->close();
         delete pSplash;
         return -1;
      }

      qApplication.processEvents();

      // process auto-installs
      QDirIterator autos(QString::fromStdString(ConfigurationSettingsImp::instance()->getSettingExtensionFilesPath()->getFullPathAndName())
         + "/AutoInstall", QStringList() << "*.aeb", QDir::Files);
      vector<string> pendingInstall;
      while (autos.hasNext())
      {
         pendingInstall.push_back(autos.next().toStdString());
      }
      bool autoInstallOccurred = false;
      InstallerServicesImp::instance()->setPendingInstall(pendingInstall);
      for (vector<string>::iterator autoIter = pendingInstall.begin();
           autoIter != pendingInstall.end();
           ++autoIter)
      {
         bool success = InstallerServicesImp::instance()->installExtension(*autoIter, mpProgress);
         if(!success)
         {
            QFileInfo autoInfo(QString::fromStdString(*autoIter));
            // Attempt to parse the AEB so we can get a better name
            string extName = autoInfo.fileName().toStdString();
            { // scope the AebIo so we don't hold a handle to the aeb file and can delete it below
               Aeb extension;
               AebIo io(extension);
               string errMsg; // ignored
               if (io.fromFile(autoInfo.filePath().toStdString(), errMsg))
               {
                  extName = extension.getName();
               }
            }
            if(DesktopServicesImp::instance()->showMessageBox("Installation error", "Unable to install " + extName
               + "\nWould you like to delete the file?", "Yes", "No") == 0)
            {
               QFile::remove(QString::fromStdString(*autoIter));
            }
         }
         else
         {
            autoInstallOccurred = true;
            QFile::remove(QString::fromStdString(*autoIter));
         }
      }
      InstallerServicesImp::instance()->setPendingInstall();
      if (autoInstallOccurred)
      {
         // rescan the plug-ins
         PlugInManagerServicesImp::instance()->buildPlugInList(Service<ConfigurationSettings>()->getPlugInPath());
      }


      // Create the main GUI window
      mpProgress->updateProgress("Creating the main application window...", 0, NORMAL);

      ApplicationWindow* pAppWindow = new ApplicationWindow(pSplash);
      qApplication.processEvents();

      // Execute startup plug-ins
      PlugInManagerServicesImp* pManager = PlugInManagerServicesImp::instance();
      if (pManager != NULL)
      {
         pManager->executeStartupPlugIns(mpProgress);
         qApplication.processEvents();
      }

      // Restore the previous position and visibility state of the toolbars and dock windows
      pAppWindow->restoreConfiguration();

      // Keep the splash screen up until all images have been shown to the user.
      while (!pSplash->canClose()) {}

      // Display the main application window
      pAppWindow->show();

      // Destroy the splash screen
      pSplash->close();
      delete pSplash;

      // Create a progress dialog
      ProgressDlg* pProgressDlg = new ProgressDlg(APP_NAME, pAppWindow);
      mpProgress->attach(SIGNAL_NAME(Subject, Modified), Slot(pProgressDlg, &ProgressDlg::progressUpdated));
      mpProgress->attach(SIGNAL_NAME(Subject, Deleted), Slot(pProgressDlg, &ProgressDlg::progressDeleted));

      // Load files specified on the command line
      ArgumentList* pArgList(ArgumentList::instance());
      if (pArgList != NULL)
      {
         FileType fileType;

         vector<string> filenames(pArgList->getOptions(""));
         for (vector<string>::size_type i = 0; i < filenames.size(); ++i)
         {
            FilenameImp filename(filenames[i]);

            QString strFilename = QString::fromStdString(filename.getFullPathAndName());
            if (strFilename.isEmpty() == false)
            {
               QFileInfo info(strFilename);
               if ((info.suffix() == "wiz") || (info.suffix() == "batchwiz"))
               {
                  if ((fileType.isValid() == true) && (fileType != WIZARD_FILES))
                  {
                     fileType = EnumWrapper<FileTypeEnum>();
                     break;
                  }

                  fileType = WIZARD_FILES;
               }
               else if (info.suffix() == "session")
               {
                  if (fileType.isValid() == true)
                  {
                     fileType = EnumWrapper<FileTypeEnum>();
                     break;
                  }

                  fileType = SESSION_FILE;
               }
               else
               {
                  if ((fileType.isValid() == true) && (fileType != DATASET_FILES))
                  {
                     fileType = EnumWrapper<FileTypeEnum>();
                     break;
                  }

                  fileType = DATASET_FILES;
               }
            }
         }

         if (fileType.isValid() == true)
         {
            // Check for valid filenames
            vector<string> validFilenames;
            for (vector<string>::size_type i = 0; i < filenames.size(); ++i)
            {
               FilenameImp filename(filenames[i]);

               string normalizedFilename = filename.getFullPathAndName();
               if (normalizedFilename.empty() == false)
               {
                  QString strFilename = QString::fromStdString(normalizedFilename);

                  QFileInfo info(strFilename);
                  if ((info.isFile() == true) && (info.exists() == true))
                  {
                     validFilenames.push_back(normalizedFilename);
                  }
                  else
                  {
                     reportWarning("The specified file '" + normalizedFilename +
                        "' does not exist and cannot be loaded.");
                  }
               }
            }

            // Load the files
            switch (fileType)
            {
               case WIZARD_FILES:
               {
                  for (vector<string>::size_type i = 0; i < validFilenames.size(); ++i)
                  {
                     string filename = validFilenames[i];
                     QString strFilename = QString::fromStdString(filename);

                     QFileInfo info(strFilename);
                     if (info.suffix() == "wiz")
                     {
                        pAppWindow->runWizard(strFilename);
                     }
                     else if (info.suffix() == "batchwiz")
                     {
                        vector<string> batchFiles;
                        batchFiles.push_back(filename);
                        WizardUtilities::runBatchFiles(batchFiles, mpProgress);
                     }
                  }

                  break;
               }

               case SESSION_FILE:
               {
                  if (validFilenames.empty() == false)
                  {
                     VERIFYRV(validFilenames.size() == 1, -1);
                     string filename = validFilenames.front();

                     string saveKey = SessionManager::getSettingQueryForSaveKey();
                     SessionSaveType saveType = SESSION_DONT_AUTO_SAVE;
                     DataVariant dvSaveType(saveType);

                     pConfigSettings->adoptTemporarySetting(saveKey, dvSaveType);
                     pAppWindow->openSession(QString::fromStdString(filename));
                     pConfigSettings->deleteTemporarySetting(saveKey);
                  }

                  break;
               }

               case DATASET_FILES:
               {
                  if (validFilenames.empty() == false)
                  {
                     ImporterResource importer("Auto Importer", validFilenames, mpProgress, false);
                     importer->execute();
                  }

                  break;
               }

               default:
                  break;
            }
         }
         else if (filenames.empty() == false)
         {
            string msg = "Unable to import the files specified on the command line.  " + string(APP_NAME) +
               " supports loading one session file, one or more wizard files, or one or more data set files.";
            mpProgress->updateProgress(msg, 0, ERRORS);
         }
      }

      // If there are any wizards, run them
      executeStartupBatchWizards();

      // Destroy the progress object and progress dialog
      delete dynamic_cast<ProgressAdapter*>(mpProgress);

      vector<string> autoExitOptions = pArgList->getOptions("autoExit");
      if (autoExitOptions.empty() == false)
      {
         SessionSaveType tempSettingQueryForSave = SESSION_DONT_AUTO_SAVE;
         const string sessionFilename = autoExitOptions.front();
         if (sessionFilename.empty() == false)
         {
            tempSettingQueryForSave = SESSION_AUTO_SAVE;
            pAppWindow->setSessionFilename(FilenameImp(sessionFilename).getFullPathAndName());
         }
         DataVariant dvTempSettingQueryForSave(tempSettingQueryForSave);

         pConfigSettings->adoptTemporarySetting(SessionManager::getSettingQueryForSaveKey(), dvTempSettingQueryForSave);
         pAppWindow->close();
         return iReturn;
      }

      // Set the application window to auto-generate textures
      QTimer textureGenerationTimer;
      bool generation = RasterLayer::getSettingBackgroundTileGeneration();
      if (generation == true)
      {
         textureGenerationTimer.setInterval(100);
         pAppWindow->connect(&textureGenerationTimer, SIGNAL(timeout()), SLOT(pregenerateTexture()));
      }

   }
   // Initiate the GUI event loop, which returns when the user exits the application
   return qApplication.exec();
}
Example #23
0
FileID_t GenerateID(const FileType &AFile)
{
	return(AFile.GiveFileName());
}