Exemplo n.º 1
0
GosmoreRunner::GosmoreRunner( QObject *parent ) :
        RoutingRunner( parent ),
        d( new GosmoreRunnerPrivate )
{
    // Check installation
    QDir mapDir(MarbleDirs::localPath() + QLatin1String("/maps/earth/gosmore/"));
    d->m_gosmoreMapFile = QFileInfo ( mapDir, "gosmore.pak" );
}
Exemplo n.º 2
0
int main (int argc, char *argv[])
{
  // CGI Convenience class
  CGI cgiconv;

  // state variables
  // assume the user didn't pass any map name
  bool drawMap = false;

  // name of the map to display if any
  QString mapName;

  // process any CGI data
  cgiconv.processCGIData();

  /* Check if we were passed a map to read */	
  if (argc == 2)
  {
    drawMap = true;
    mapName = argv[1];
  }
  else if (cgiconv.getParamCount() != 0)
  {
    mapName = cgiconv.getParamValue("map");
    drawMap = (cgiconv.getParamValue("draw") == "y");
  }

  // if in drawmap mode, then that's all that's done
  if (drawMap)
  {	
    QRegExp slashExp("/");
    mapName.replace(slashExp, "_");

    mapName.prepend(MAPDIR "/");
    loadFileMap ((const char*)mapName);
    paintMap();
  }
  else
  {
    // open the output data stream
    QTextStream out(stdout, IO_WriteOnly);
    out.setEncoding(QTextStream::Latin1);
    out.flags(QTextStream::showbase | QTextStream::dec);
    
    const char* header =
      "Content-type: text/html; charset=iso-8859-1\n\n"
      "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\">\n"
      "<HTML>\n"
      "  <HEAD>\n"
      "    <TITLE>ShowEQ Map Display</TITLE>\n"
      "    <style type=\"text/css\">\n"
      "      <!--\n"
      "          table { border: black 2px solid }\n"
      "          td { border: black 1px solid }\n"
      "          th { border: black 1px solid }\n"
      "      -->\n"
      "    </style>\n" 
      "  </HEAD>\n"
      "  <BODY>\n";

    /* Print HTML header */
    out << header;

    const char* footer = 
      "  </BODY>\n"
      "</HTML>\n";

    // otherwise display an HTML form to allow the user to choose a map
    QDir  mapDir(MAPDIR, "*.map", (QDir::Name | QDir::IgnoreCase), 
		 (QDir::Files | QDir::Readable));

    if (!mapDir.exists())
    {
      out << "<H1>The map directory '" MAPDIR "' doesn't exist!</H1>\n";
      out << footer;
      return 0;
    }

    QString userAgent = cgiconv.getHTTPUserAgent();

    out << "<FORM method=\"POST\" action=\"" << cgiconv.getScriptName() 
	<< "\">\n";

    // beware Netscape 4.x style sheet brain death
    if ((userAgent.contains("Mozilla/4.") == 1) && 
	(userAgent.contains("MSIE") == 0))
      out << "<TABLE border=2 cellspacing=0 cellpadding=2>\n";
    else
      out << "<TABLE cellspacing=0 cellpadding=2>\n";
    
    out << "<TR>";
    out << "  <TH>Map Name</TH>";
    out << "  <TD><INPUT type=\"reset\" value=\"Reset\"/></TD>\n";
    out << "</TR>";
    out << "<TR>";
    out << "<TD><SELECT name=\"map\" size=\"1\">\n";

    // create a file info list
    const QFileInfoList *list = mapDir.entryInfoList();

    // create an iterator over the list
    QFileInfoListIterator it( *list );
    
    // pointer to the file info for the current file
    QFileInfo *fi;

    while ( (fi=it.current()) ) 
    {
      out << "<OPTION value=\"" << fi->fileName() << "\"";
      if (mapName == fi->fileName())
	out << " selected";
      out << ">" << fi->baseName() << "</OPTION>\n";
      
      // goto next element from list
      ++it;
    }

    out << "</SELECT></TD>\n";
  
    // Submission button
    out << "<TD><INPUT type=\"submit\" value=\"Display\"/></TD>\n";

    out << 
      "</TR>"
      "</TABLE>"
      "</FORM>";


    if (!mapName.isEmpty())
    {
      out << "<H1>Map: " << mapName << "</H1>\n";
      out << "<DIV><IMG src=\"" << cgiconv.getScriptName()
	  << "?map=" << mapName << ";draw=y\" alt=\"Map: "
	  << mapName << "\"/></DIV>\n";
    }

    out << footer;
  }

  return 0;
}
Exemplo n.º 3
0
bool GosmorePlugin::canWork() const
{
    QDir mapDir( MarbleDirs::localPath() + "/maps/earth/gosmore/" );
    QFileInfo mapFile = QFileInfo ( mapDir, "gosmore.pak" );
    return mapFile.exists();
}