Ejemplo n.º 1
0
bool MarkdownProcess::HasInput()
{
    bool hasInput = false;

    if ( IsInputAvailable() )
    {
        wxTextInputStream tis(*GetInputStream());

        // this assumes that the output is always line buffered
		m_file << tis.ReadLine() << wxT("\n");

//        m_parent->GetLogListBox()->Append(msg);

        hasInput = true;
    }

    if ( IsErrorAvailable() )
    {
        wxTextInputStream tis(*GetErrorStream());

        // this assumes that the output is always line buffered
		wxMessageBox(tis.ReadLine());
        hasInput = true;
    }

    return hasInput;
}
Ejemplo n.º 2
0
void processManager::LogOutput(bool &hasOutput, const wxString &label,float *outputProgression)
{
    hasOutput = false;

    if ( IsInputAvailable() )
    {
        wxTextInputStream tis(*GetInputStream());

        // this assumes that the output is always line buffered
        wxString msg;
        wxString output= tis.ReadLine();
        if(!this->outlogs.empty())
        {
            for(std::vector<smart_ptr<InterfLogger> >::iterator itlogs=this->outlogs.begin(); itlogs!=this->outlogs.end(); itlogs++)
            {
                (*(*itlogs)).LogMessage(output);
            }
        }
        if(outputProgression==NULL || output.Left(1)!="#")
        {
            msg << label << output;
            msg.Replace("%","%%"); //si il y a un seul % alors un bug apparait wxString attend un format du type %s ou %i par exemple
            if(output.Left(1)=="!")
            {
                wxLogWarning(msg);
            } else {
                wxLogMessage(msg);
            }
        } else {
            wxString prog=output.Right(output.Len()-1).Strip();
            *outputProgression=Convertor::ToFloat(prog);
        }

        hasOutput = true;
    }

    while ( IsErrorAvailable() )
    {
        wxTextInputStream tis(*GetErrorStream());
        const wxString& errMsg(tis.ReadLine());
        if(!this->outlogs.empty())
        {
            for(std::vector<smart_ptr<InterfLogger> >::iterator itlogs=this->outlogs.begin(); itlogs!=this->outlogs.end(); itlogs++)
            {
                (*(*itlogs)).LogError(errMsg);
            }
        }
        // this assumes that the output is always line buffered
        wxString msg;
        msg << _("Erreur exécutable :") << errMsg;
        msg.Replace("%","%%"); //si il y a un seul % alors un bug apparait wxString attend un format du type %s ou %i par exemple
        wxLogError(msg);

        hasOutput = true;
    }
}
Ejemplo n.º 3
0
static bool ReadAll(wxInputStream *is, wxArrayString& output)
{
    wxCHECK_MSG( is, false, _T("NULL stream in wxExecute()?") );

    // the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
    is->Reset();

    wxTextInputStream tis(*is);

    for ( ;; )
    {
        wxString line = tis.ReadLine();

        // check for EOF before other errors as it's not really an error
        if ( is->Eof() )
        {
            // add the last, possibly incomplete, line
            if ( !line.empty() )
                output.Add(line);
            break;
        }

        // any other error is fatal
        if ( !*is )
            return false;

        output.Add(line);
    }

    return true;
}
Ejemplo n.º 4
0
bool PipedProcess::ReadAll(wxString &input)
{
	bool hasInput = false;
	bool cont1(true), cont2(true);

	wxTextInputStream tis(*GetInputStream());
	wxTextInputStream tie(*GetErrorStream());
	while(cont1 || cont2){
		cont1 = false;
		cont2 = false;
		while( IsInputAvailable() )
		{
			// this assumes that the output is always line buffered
			wxChar ch = tis.GetChar();
			input << ch;
			hasInput = true;
			cont1 = true;
		}

		while( IsErrorAvailable() )
		{
			// this assumes that the output is always line buffered
			wxChar ch = tie.GetChar();
			input << ch;
			hasInput = true;
			cont2 = true;
		}
	}
	return hasInput;
}
Ejemplo n.º 5
0
wxString	CallGraph::LocateApp(const wxString &app_name)
{
    // myLog("LocateApp(\"%s\")", app_name);

    wxProcess	*proc = new wxProcess(wxPROCESS_REDIRECT);

    wxString	cmd = "which " + app_name;

    // Q: HOW BIG IS INTERNAL BUFFER ???
    int	err = wxExecute(cmd, wxEXEC_SYNC, proc);
    // ignore -1 error due to CL signal handler overload

    /*int	pid = proc->GetPid();

    myLog("  wxExecute(\"%s\") returned err %d, had pid %d", cmd, err, pid);
    */

    // get process output
    wxInputStream	*pis = proc->GetInputStream();
    if (!pis || !pis->CanRead()) {
        delete proc;
        return "<ERROR>";
    }

    // read from it
    wxTextInputStream	tis(*pis);

    wxString	out_str = tis.ReadLine();

    delete proc;

    // myLog("  returned \"%s\"", out_str);

    return out_str;
}
Ejemplo n.º 6
0
bool cbNetwork::ReadFileContents(const wxString& remote, wxString& buffer)
{
    if (!Connect(remote))
        return false;
    m_Busy = true;
    wxString name = wxFileName(remote).GetFullName();
    FileInfo* info = PrivateGetFileInfo(remote);
    Notify(cbEVT_CBNET_START_DOWNLOAD, name, info ? info->size : 0);

    buffer.Clear();
    wxTextInputStream tis(*m_pStream);
    while (!m_Abort && !m_pStream->Eof())
    {
        buffer += tis.ReadLine() + _T('\n');
        Notify(cbEVT_CBNET_PROGRESS, name, buffer.Length());
    }

    if (m_Abort)
    {
        Notify(cbEVT_CBNET_ABORTED, _("Aborted"));
        buffer.Clear();
    }
    Notify(cbEVT_CBNET_END_DOWNLOAD, name, m_Abort ? -1 : 0);

    m_Busy = false;
    Disconnect();
    return true;
}
Ejemplo n.º 7
0
void
ExecTestCase::DoTestAsyncRedirect(const wxString& command,
                                  CheckStream check,
                                  const char* expectedContaining)
{
    AsyncInEventLoop asyncInEventLoop;
    TestAsyncProcess proc;

    proc.Redirect();

    CPPUNIT_ASSERT( asyncInEventLoop.DoExecute(
                       AsyncExec_DontExitLoop,  // proc is expected (inside of its OnTerminate())
                               // to trigger the exit of the event loop.
                       command, wxEXEC_ASYNC, &proc) != 0 );

    wxInputStream *streamToCheck = NULL;
    switch ( check )
    {
        case Check_Stdout:
            streamToCheck = proc.GetInputStream();
            break;

        case Check_Stderr:
            streamToCheck = proc.GetErrorStream();
            break;
    }

    wxTextInputStream tis(*streamToCheck);

    // Check that the first line of output contains what we expect.
    CPPUNIT_ASSERT( tis.ReadLine().Contains(expectedContaining) );
}
Ejemplo n.º 8
0
    bool unpackNow() {
        wxFFileInputStream fis(version + ".tgz");
        wxZlibInputStream zlis(fis);
        wxTarInputStream tis(zlis);

        if (!tis.CanRead()) {
            return false;
        }

        std::auto_ptr<wxTarEntry> entry;
        while (entry.reset(tis.GetNextEntry()), entry.get() != NULL) {
            // access meta-data
            wxString name = entry->GetName();
            printf("%s\n", name.c_str());
            if (name == "Tibia/Tibia.pic" || name == "Tibia\\Tibia.pic") {
                castEvent(10);
                unpackEntry(tis, "Tibia.pic");
            } else if (name == "Tibia/Tibia.dat" || name == "Tibia\\Tibia.dat") {
                castEvent(11);
                unpackEntry(tis, "Tibia.dat");
            } else if (name == "Tibia/Tibia.spr" || name == "Tibia\\Tibia.spr") {
                castEvent(12);
                unpackEntry(tis, "Tibia.spr");
            } else {
                printf("Name unrecognized\n");
                castEvent(9);
            }
        }
        return true;
    }
Ejemplo n.º 9
0
void SigUIFrame::OnTerminateInstall(wxProcessEvent &event)
{
    wxEndBusyCursor();
    wxWakeUpIdle();
    if (event.GetExitCode() == 0) {
	m_sig_candidates->Clear();
	wxLogMessage(_("Successfully installed new virus signatures\n"));
	reload();
    } else {
	bool had_errors = false;
	wxInputStream *err = m_siginst_process->GetErrorStream();
	wxTextInputStream tis(*err);

	while (!err->Eof()) {
	    wxString line = tis.ReadLine();
	    line.Trim();
	    if (!line.IsEmpty()) {
		wxLogWarning("%s", line);
		had_errors = true;
	    }
	}
	if (had_errors) {
	    wxLogError(_("Errors encountered during virus signature install"));
	}
    }
    delete m_siginst_process;

    m_panel_sigman->Enable();
}
Ejemplo n.º 10
0
void PluginFilterProcess::ProcessStdErr()
{
//	TRACEUSER("Gerry", _T("PluginFilterProcess::ProcessStdErr"));

	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
//		while (!GetErrorStream()->Eof())
		while (IsErrorAvailable())
		{
			wxString line;
			line << tis.ReadLine();
//			TRACEUSER("Gerry", _T("(stderr):%s"), line.c_str());

			if (!line.IsEmpty())
			{
				// If line begins "MESSAGE:" then it is a debug message and can be discarded
				wxString rest;
				if (line.StartsWith(_T("MESSAGE:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFDebug:%s"), rest.c_str());
				}
				else if (line.StartsWith(_T("PROGRESS:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFProgress:%s"), rest.c_str());
					if (m_pFilter)
					{
						unsigned long /*TYPENOTE: Correct*/ Val = wxStrtoul(rest.c_str(), NULL, 10);
						if (Val > 0)
						{
//							TRACEUSER("Gerry", _T("Setting progress to %d"), Val);
							m_pFilter->SetProgressBarCount((UINT32)Val);
						}
					}
				}
				else if (line.StartsWith(_T("WARNING:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFWarning:%s"), rest.c_str());
					m_Warnings.Add(rest);
				}
				else if (line.StartsWith(_T("ERROR:"), &rest))
				{
//					TRACEUSER("Gerry", _T("XPFError:%s"), rest.c_str());
					m_Errors.Add(rest);
				}
				else
				{
//					TRACEUSER("Gerry", _T("Skipping stderr:%s"), line.c_str());
//					m_Errors.Add(line);
				}
			}
		}
	}
}
Ejemplo n.º 11
0
        bool HasInput()
        {
            bool hasInput = false;

            wxInputStream* is = GetInputStream();
            if (is && is->CanRead() && !is->Eof()) 
            {
                wxTextInputStream tis(*is);
                m_data->Stdout.Add(tis.ReadLine());
                hasInput = true;
            }

            wxInputStream* es = GetErrorStream();
            if (es && es->CanRead() && !es->Eof()) 
            {
                wxTextInputStream tis(*es);
                m_data->Stderr.Add(tis.ReadLine());
                hasInput = true;
            }

            return hasInput;
        }
Ejemplo n.º 12
0
void radeon_profile::loadTopbarItemsSchemas(const QXmlStreamReader &xml) {
    TopbarItemDefinitionSchema tis(static_cast<ValueID>(xml.attributes().value("primaryValueId").toInt()),
                                   static_cast<TopbarItemType>(xml.attributes().value("type").toInt()),
                                   QColor(xml.attributes().value("primaryColor").toString()));

    tis.setPieMaxValue(xml.attributes().value("pieMaxValue").toInt());

    if (xml.attributes().value("secondaryValueIdEnabled").toInt() == 1) {
        tis.setSecondaryColor(QColor(xml.attributes().value("secondaryColor").toString()));
        tis.setSecondaryValueId(static_cast<ValueID>(xml.attributes().value("secondaryValueId").toInt()));
    }

    topbarManager.addSchema(tis);
}
Ejemplo n.º 13
0
bool MyProcessOutput::processInput()
{
    if (!m_process)
        return false;
    bool hasInput = false;
    m_logoutput->Freeze();
    while (m_process->IsInputAvailable()) {
        wxInputStream *in = m_process->GetInputStream();
        wxString msg;
	int c;
	static bool clear = false;

	do {
	    c = in->GetC();
	    if (in->Eof())
		break;
	    if (c >= 128)
		c = '?';
	    msg << (char)c;
	} while (c != '\r' && c != '\n');

	msg.Trim();
	msg.Trim(false);
	if (!msg.empty()) {
	    bool scroll = false;
	    if (clear && m_logoutput->GetCount() > 0)
		m_logoutput->Delete(m_logoutput->GetCount()-1);
	    else
		scroll = true;
	    m_logoutput->Append(msg);
	    m_logoutput->ScrollLines(1);
	}
	clear = c == '\r';
        hasInput = true;
    }
    while (m_process->IsErrorAvailable()) {
        wxTextInputStream tis(*m_process->GetErrorStream());
        wxString msg;
        msg << tis.ReadLine();
	msg.Trim();
	if (!msg.empty()) {
	    m_logoutput->Append(msg);
	    m_logoutput->ScrollLines(1);
	}
        hasInput = true;
    }
    m_logoutput->Thaw();
    return hasInput;
}
Ejemplo n.º 14
0
void CamProcess::ProcessStdErr()
{
	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
		while (IsErrorAvailable())
		{
			wxString line;
			line << tis.ReadLine();
//			TRACEUSER("Gerry", _T("(stderr):%s"), line.c_str());
		}
	}
}
Ejemplo n.º 15
0
static bool ReadAll(wxInputStream *is, wxArrayString& output)
{
    if ( !is )
        return true;

    // the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
    is->Reset();

    // Notice that wxTextInputStream doesn't work correctly with wxConvAuto
    // currently, see #14720, so use the current locale conversion explicitly
    // under assumption that any external program should be using it too.
    wxTextInputStream tis(*is, " \t"
#if wxUSE_UNICODE
                                    , wxConvLibc
#endif
                                                );

#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
#   pragma ivdep
#   pragma swp
#   pragma unroll
#   pragma prefetch
#   if 0
#       pragma simd noassert
#   endif
#endif /* VDM auto patch */
    for ( ;; )
    {
        wxString line = tis.ReadLine();

        // check for EOF before other errors as it's not really an error
        if ( is->Eof() )
        {
            // add the last, possibly incomplete, line
            if ( !line.empty() )
                output.Add(line);
            break;
        }

        // any other error is fatal
        if ( !*is )
            return false;

        output.Add(line);
    }

    return true;
}
Ejemplo n.º 16
0
/********************************************************************************************

>	void CamLaunchProcess::ProcessStdErr()

	Author:		Phil_Martin (Xara Group Ltd) <*****@*****.**>
				Gerry_Iles (Xara Group Ltd) <*****@*****.**>
	Created:	19/May/2006
	Inputs:		-
	Outputs:	-
	Returns:	-
	Purpose:	Process anything the process writes to the error stream

********************************************************************************************/
void CamLaunchProcess::ProcessStdErr()
{
	if (IsErrorAvailable())
	{
		wxTextInputStream tis(*GetErrorStream());

		// This assumes that the output is always line buffered
		while (!GetErrorStream()->Eof())
		{
			wxString line;
			line << tis.ReadLine();
			TRACEUSER("Phil", _T("(stderr):%s\n"), line.c_str());
		}

		m_ReturnCode = 42;		// Signal failure
	}
}
Ejemplo n.º 17
0
void TextStreamTestCase::MiscTests()
{
    wxString filename = wxT("testdata.fc");
    wxFileInputStream fsIn(filename);
    if ( !fsIn.IsOk() )
    {
        return;
    }

    wxTextInputStream tis(fsIn);
    CPPUNIT_ASSERT_EQUAL("# this is the test data file for wxFileConfig tests", tis.ReadLine());
    CPPUNIT_ASSERT_EQUAL("value1=one", tis.ReadLine());
    CPPUNIT_ASSERT_EQUAL("# a comment here", tis.ReadLine());
    CPPUNIT_ASSERT_EQUAL("value2=two", tis.ReadLine());
    CPPUNIT_ASSERT_EQUAL("value\\ with\\ spaces\\ inside\\ it=nothing special", tis.ReadLine());
    CPPUNIT_ASSERT_EQUAL("path=$PATH", tis.ReadLine());
}
Ejemplo n.º 18
0
void FileExplorerUpdater::ReadStream(bool all)
{
    m_exec_timer->Stop();
    m_exec_stream=m_exec_proc->GetInputStream();
    wxTextInputStream tis(*m_exec_stream);
    wxStopWatch sw;
    while(m_exec_proc->IsInputAvailable())
    {
        m_exec_output.Add(tis.ReadLine());
        if(!all && sw.Time()>30)
            break;
    }
    if(!all)
    {
        m_exec_timer->Start(150,true);
    }
}
Ejemplo n.º 19
0
bool MainWindow::ReadOutput(wxInputStream& s)
{
    // the stream could be already at EOF or in wxSTREAM_BROKEN_PIPE state
    s.Reset();
    wxTextInputStream tis(s, " ", wxConvUTF8);

    while (true) {
        wxString line = tis.ReadLine();
        if ( !line.empty() ) {
            this->text->AppendText(line);
        }
        this->text->AppendText(wxTextFile::GetEOL());
        if (s.Eof()) {
            break;
        }
    }

    return true;
}
Ejemplo n.º 20
0
bool AxProcess::HasEnded( )
{
	wxString msg;

	// redirect in now disabled (see constructor)
	// nothing will happen
	wxTextInputStream tis(*GetInputStream());
	wxTextInputStream tes(*GetErrorStream());
	
	// we don't know where Error is going to be output
    while ( IsInputAvailable() )
	{
		msg = tis.ReadLine();
		if ( msg.StartsWith("$ Success!") )
		{
			return true;
		}
		else if ( msg.StartsWith("$ Error: ") )
		{
			m_status = 255;
			return true;
		}
		if ( !msg.IsEmpty() && m_log )
			m_log->WriteString( msg + "\n" );
	}
    while ( IsErrorAvailable() )
	{
		msg = tes.ReadLine();
		if ( msg.StartsWith("$ Error: ") )
		{
			m_status = 255;
			return true;
		}
		if ( !msg.IsEmpty() && m_log )
			m_log->WriteString( msg + "\n" );
    }


    return false;
}
Ejemplo n.º 21
0
void Octree<MetricType, StatisticType, MatType>::DualTreeTraverser<RuleType>::
    Traverse(Octree& queryNode, Octree& referenceNode)
{
  // Increment the visit counter.
  ++numVisited;

  // Store the current traversal info.
  traversalInfo = rule.TraversalInfo();

  if (queryNode.IsLeaf() && referenceNode.IsLeaf())
  {
    const size_t begin = queryNode.Point(0);
    const size_t end = begin + queryNode.NumPoints();
    for (size_t q = begin; q < end; ++q)
    {
      // First, see if we can prune the reference node for this query point.
      rule.TraversalInfo() = traversalInfo;
      const double score = rule.Score(q, referenceNode);
      if (score == DBL_MAX)
      {
        ++numPrunes;
        continue;
      }

      const size_t rBegin = referenceNode.Point(0);
      const size_t rEnd = rBegin + referenceNode.NumPoints();
      for (size_t r = rBegin; r < rEnd; ++r)
        rule.BaseCase(q, r);

      numBaseCases += referenceNode.NumPoints();
    }
  }
  else if (!queryNode.IsLeaf() && referenceNode.IsLeaf())
  {
    // We have to recurse down the query node.  Order does not matter.
    for (size_t i = 0; i < queryNode.NumChildren(); ++i)
    {
      rule.TraversalInfo() = traversalInfo;
      const double score = rule.Score(queryNode.Child(i), referenceNode);
      if (score == DBL_MAX)
      {
        ++numPrunes;
        continue;
      }

      Traverse(queryNode.Child(i), referenceNode);
    }
  }
  else if (queryNode.IsLeaf() && !referenceNode.IsLeaf())
  {
    // We have to recurse down the reference node, so we need to do it in an
    // ordered manner.
    arma::vec scores(referenceNode.NumChildren());
    std::vector<typename RuleType::TraversalInfoType>
        tis(referenceNode.NumChildren());
    for (size_t i = 0; i < referenceNode.NumChildren(); ++i)
    {
      rule.TraversalInfo() = traversalInfo;
      scores[i] = rule.Score(queryNode, referenceNode.Child(i));
      tis[i] = rule.TraversalInfo();
    }

    // Sort the scores.
    arma::uvec scoreOrder = arma::sort_index(scores);
    for (size_t i = 0; i < scoreOrder.n_elem; ++i)
    {
      if (scores[scoreOrder[i]] == DBL_MAX)
      {
        // We don't need to check any more---all children past here are pruned.
        numPrunes += scoreOrder.n_elem - i;
        break;
      }

      rule.TraversalInfo() = tis[scoreOrder[i]];
      Traverse(queryNode, referenceNode.Child(scoreOrder[i]));
    }
  }
  else
  {
    // We have to recurse down both the query and reference nodes.  Query order
    // does not matter, so we will do that in sequence.  However we will
    // allocate the arrays for recursion at this level.
    arma::vec scores(referenceNode.NumChildren());
    std::vector<typename RuleType::TraversalInfoType>
        tis(referenceNode.NumChildren());
    for (size_t j = 0; j < queryNode.NumChildren(); ++j)
    {
      // Now we have to recurse down the reference node, which we will do in a
      // prioritized manner.
      for (size_t i = 0; i < referenceNode.NumChildren(); ++i)
      {
        rule.TraversalInfo() = traversalInfo;
        scores[i] = rule.Score(queryNode.Child(j), referenceNode.Child(i));
        tis[i] = rule.TraversalInfo();
      }

      // Sort the scores.
      arma::uvec scoreOrder = arma::sort_index(scores);
      for (size_t i = 0; i < scoreOrder.n_elem; ++i)
      {
        if (scores[scoreOrder[i]] == DBL_MAX)
        {
          // We don't need to check any more
          // All children past here are pruned.
          numPrunes += scoreOrder.n_elem - i;
          break;
        }

        rule.TraversalInfo() = tis[scoreOrder[i]];
        Traverse(queryNode.Child(j), referenceNode.Child(scoreOrder[i]));
      }
    }
  }
}
Ejemplo n.º 22
0
void defaults::read_config(void)
{
	int ival,i,i2,iar[4];
	float fval;
	bool ok;

	borderfont.setPixelSize(windowbuttonsize-5);

	static const char *par[] = {
	"ToolbarHeight",          // 0
	"WindowButtonSize",       // 1
	"LowerBorderHeight",      // 2
	"LowerBorderWidth",       // 3
	"PagerHeight",            // 4
	"WindowFontName",         // 5
	"WindowFontHeight",       // 6
	"IconFontName",           // 7
	"IconFontHeight",         // 8
	"ToolbarOnTop",           // 9
	"VirtualDesktops",        // 10 
	"ShowMenue",              // 11
	"AutoRaiseTime",          // 12
	"InactiveWindowColor",    // 13
	"UrgentWindowColor",      // 14
	"StartClientsUrgent",     // 15
	"RootBackgroundColor",    // 16 
	"RootBackgroundPicture",  // 17
	"PagerActiveColor",       // 18
	"PagerVisibleColor",      // 19
	"PagerInvisibleColor",    // 20
	"ShowClientMachines",     // 21
	"Exec",                   // 22
	"ShowWinlist",            // 23
	"Style",                  // 24
	"Maximize1",              // 25
	"Maximize2",              // 26
	"TileSplit",              // 27
	"TileMaxWithTab",         // 28
	"TileStart",              // 29
	"TileMinframe",           // 30
	NULL };
	
	QString fname;
	QString p1,p2;
	QFileInfo acc;
	QStyle *qs;
	
	fname = WindowManager::get_cfile("defaults");
	QFile istr(fname);

	if(fname.isNull() || ! istr.open(QIODevice::ReadOnly))
	{
		if(! fname.isNull())
			perror("cannot open defaults file");
	}	
	else
	{
		while(! istr.atEnd())
		{
			QTextStream tis(istr.readLine(1024));
			tis >> p1;
			if(p1.isEmpty() || p1[0] == '#')
				continue;

			tis >> p2;
			if(p2.isEmpty())
				continue;

			i = 0;
			do
			{
				if(p1 == par[i])
					break;
			}
			while(par[++i] != NULL);
			
			switch(i)
			{
				case 0:
					ival = p2.toInt();
	
					if(ival < 10 || ival > 500)
						logmsg << "ToolbarHeight: Value out of range\n";
					else
						tb_height = ival;
						
					break;
	
				case 1:
					ival = p2.toInt();
		
					if(ival < 6 || ival > 500)
						logmsg << "WindowButtonSize: Value out of range\n";
					else
						windowbuttonsize = ival;
		
					break;
	
				case 2:
					ival = p2.toInt();
	
					if(ival < 1 || ival > 500)
						logmsg << "LowerBorderHeight: Value out of range\n";
					else
							lowerborderheight = ival;
	
					break;
	
				case 3:
					ival = p2.toInt();
	
					if(ival < 1 || ival > 500)
						logmsg << "LowerBorderWidth: Value out of range\n";
					else
						lowerborderwidth = ival;
	
					break;
	
				case 4:
					ival = p2.toInt();
	
					if(ival < 4 && ival > 500)
						logmsg << "PagerHeight: Value out of range\n";
					else
						pager_height = ival;
	
					break;
	
				case 5:
					if(p2.toLower() == "fixed")
						break;
						
					borderfont.setFamily(p2);
					break;
	
				case 6:
					ival = p2.toInt();
	
					if(ival < 4 || ival > 500)
						logmsg << "WindowFontHeight: Value out of range\n";
					else
						borderfont.setPixelSize(ival);
	
					break;
	
				case 7:
					if(p2.toLower() == "fixed")
						break;
						
					toolbarfont.setFamily(p2);
					break;
	
				case 8:
					ival = p2.toInt();
	
					if(ival < 4 || ival > 500)
						logmsg << "IconFontHeight: Value out of range\n";
					else
						toolbarfont.setPixelSize(ival);
	
					break;
	
				case 9:
					if(p2.toUpper() == "TRUE")
						toolbar_top = TRUE;
		
					break;
	
				case 10:
					ival = p2.toInt();
	
					if(ival < 1 || ival > MAXDESKS)
					{
						logmsg << "VirtualDesktops: Value out of range\n";
						vdesks = 3;
					}
					else
						vdesks = ival;
	
					break;	
	
				case 11:
					if(p2.toUpper() == "FALSE")
						show_menu = FALSE;
	
					break;
	
				case 12:
					ival = p2.toInt();
	
					if(ival < 0 || ival > 100000)
						logmsg << "AutoRaiseTime: Value out of range\n";
					else
						autofocustime = ival;
	
					break;
					
				case 13:
					inactive_bg = new QColor();
					inactive_bg->setNamedColor(p2);
					break;
	
				case 14:
					urgent_bg.setNamedColor(p2);
					break;
	
				case 15:
					if(p2.toUpper() == "FALSE")
						starturgent = FALSE;
	
					break;
	
				case 16:
					root_bg.setNamedColor(p2);
					break;
	
				case 17:
					acc.setFile(p2);
					if(! acc.isReadable())
						break;
						
					root_pix = p2;
					break;
	
				case 18:
					pager_active.setNamedColor(p2);
					break;
	
				case 19:
					pager_visible.setNamedColor(p2);
					break;
	
				case 20:
					pager_window.setNamedColor(p2);
					break;
	
				case 21:
					if(p2.toUpper() == "TRUE")
						showclientmachines = TRUE;

					break;

				case 22:
					if(start_restart == FALSE)
					{
						QString cml = p2+tis.readLine();
						initexec.push(new QByteArray(cml.toAscii()));
					}	
					break;
				
				case 23:
					if(p2.toUpper() == "FALSE")
						show_winlist = FALSE;
	
					break;

				case 24:
					if((qs = QStyleFactory::create(p2)) == NULL)
					{
						logmsg << "Unknown style: " << p2 << '\n';
						if(p2 == "Platinum")
							p2 = "Plastique";
							
						if((qs = QStyleFactory::create(p2)) == NULL)
							break;
					}
					QApplication::setStyle(qs);
					break;

				case 25:
				case 26:
					i2 = 0;
					while(1)
					{
						iar[i2] = p2.toInt(&ok);

						if(ok == FALSE || i2 > 2)
							break;

						tis >> p2;

						if(p2.isEmpty())
							break;

						i2++;
					}
					if(i2 < 3)
					{
						logmsg << "invalid parameter for maximize\n";
						break;
					}
					
					if(i == 25)
					{
						tmx1 = iar[0]; tmy1 = iar[1]; tmx2 = iar[2]; tmy2 = iar[3];
					}	
					else	
					{
						smx1 = iar[0]; smy1 = iar[1]; smx2 = iar[2]; smy2 = iar[3];
					}	

					break;	

				case 27:
					fval = p2.toFloat();

					if(fval < 1 || fval > 99)
						logmsg << "TileSplit: Value out of range\n";
					else
						tleftspace = fval/100;

					break;

				case 28: 
					ival = p2.toInt();

					if(ival < 0 || ival > 10000)
						logmsg << "TileMaxOnTab: Value out of range\n";
					else
						maxontab = ival;

					break;

				case 29:
					for(i2=0; i2 < 10; i2++)
					{
						ival = p2.toInt(&ok);

						if(ok == FALSE)
							break;

						if(ival < 1 || ival > 10)
						{
							logmsg << "TileStart: value out of range\n";
							continue;
						}

						sttiled[ival-1] = TRUE;

						tis >> p2;

						if(p2.isEmpty())
							break;
					}
					
				case 30:
					ival = p2.toInt();

					if(ival < 0 || ival > 10000)
						logmsg << "TileMinframe: Value out of range\n";
					else
						wminframe = ival;

					break;

				default:
					logmsg << "WM: unknown parameter: " << p1 << '\n';
			}
		}
		istr.close();
	}	
	
	QFontInfo info(borderfont);
	if(info.family() != borderfont.family())
		logmsg << "WM: no match for font " << borderfont.family() << ", using " << info.family() << " instead\n";

	QFontInfo tinfo(toolbarfont);
	if(tinfo.family() != toolbarfont.family())
		logmsg << "WM: no match for font " << toolbarfont.family() << ", using " << tinfo.family() << " instead\n";
	
	tc_height = tb_height-4;

	if(pager_height > tb_height)
		pager_height = tb_height;
	
	if(borderfont.pixelSize() > windowbuttonsize-3)
	{
		windowbuttonsize = borderfont.pixelSize()+3;
		logmsg << "WM: windowborder too small for font, set to " << windowbuttonsize << '\n';
	}

	if(toolbarfont.pixelSize() > tc_height-4)
	{
		tc_height = toolbarfont.pixelSize()+4;
		tb_height = tc_height+4;
		logmsg << "WM: toolbar contents too small for font, set to " << tc_height << '\n';
	}
}
Ejemplo n.º 23
0
wxGzipInputStream::wxGzipInputStream(wxInputStream& stream,
                                     wxMBConv& conv /*=wxConvFile*/)
  : wxFilterInputStream(stream)
{
    m_decomp = NULL;
    m_crc = crc32(0, Z_NULL, 0);

    // Try to read the Gzip magic numbers 0x1f, 0x8b. If not found then the
    // underlying stream isn't gzipped after all, so unread the bytes taken
    // so that the underlying stream can be read directly instead.
    wxUint8 magic[2];
    size_t n = m_parent_i_stream->Read(magic, sizeof(magic)).LastRead();

    if (n < sizeof(magic) || ((magic[1] << 8) | magic[0]) != GZ_MAGIC) {
        if (n)
            m_parent_i_stream->Ungetch(magic, n);
        // Set EOF rather than error to indicate no gzip data
        m_lasterror = wxSTREAM_EOF;
        return;
    }

    wxDataInputStream ds(*m_parent_i_stream);

    // read method, flags, timestamp, extra flags and OS-code
    int method = ds.Read8();
    int flags = ds.Read8();
#if wxUSE_DATETIME
    wxUint32 datetime = ds.Read32();
    if (datetime)   // zero means not set (not -1 as usual for time_t)
        m_datetime = wxLongLong(0, datetime) * 1000L;
#else
    ds.Read32();
#endif
    ds.Read8();
    ds.Read8();

    if (flags & GZ_HEAD_CRC)
        ds.Read16();

    if (flags & GZ_EXTRA_FIELD)
        for (int i = ds.Read16(); i > 0 && m_parent_i_stream->IsOk(); i--)
            m_parent_i_stream->GetC();

    // RFC-1952 specifies ISO-8859-1 for these fields
    if (flags & GZ_ORIG_NAME) {
#if wxUSE_UNICODE
        wxTextInputStream tis(*m_parent_i_stream, wxT(" \t"), conv);
#else
        wxTextInputStream tis(*m_parent_i_stream);
        (void)conv;
#endif
        wxChar c;
        while ((c = tis.GetChar()) != 0 && m_parent_i_stream->IsOk())
            m_name += c;
    }

    if (flags & GZ_COMMENT)
        while (m_parent_i_stream->GetC() != 0 && m_parent_i_stream->IsOk())
            ;   // empty loop

    m_lasterror = wxSTREAM_READ_ERROR;
    if (!*m_parent_i_stream) {
        wxLogDebug(wxT("Error reading Gzip header"));
        return;
    }

    if (flags & GZ_RESERVED)
        wxLogWarning(_("Unsupported flag in Gzip header"));

    switch (method) {
        case Z_DEFLATED:
            m_decomp = new wxZlibInputStream(*m_parent_i_stream, wxZLIB_NO_HEADER);
            break;

        default:
            wxLogError(_("unsupported compression method in Gzip stream"));
            return; 
    }

    if (m_decomp)
        m_lasterror = m_decomp->GetLastError();
}
Ejemplo n.º 24
0
DatabaseDlg::DatabaseDlg(wxWindow* frame, wxWindow* parent)
: wxPanel(parent, wxID_ANY,
wxPoint(500, 150), wxSize(440, 700),
0, "DatabaseDlg"),
m_frame(parent),
m_view(0)
{
	SetEvtHandlerEnabled(false);
	Freeze();

	wxBoxSizer *group1 = new wxBoxSizer(wxHORIZONTAL);
	m_url_text = new DBSearcher(parent, this, ID_SearchTextCtrl, wxT("Search"),
		wxDefaultPosition, wxSize(300, 23), wxTE_PROCESS_ENTER);
	m_download_btn = new wxButton(this, ID_DownloadBtn, wxT("Search"),
		wxDefaultPosition, wxSize(70, 23));
	group1->Add(5, 5);
	group1->Add(m_url_text, 1, wxEXPAND);
	group1->Add(5, 5);
	group1->Add(m_download_btn, 0, wxALIGN_CENTER);

	wxBoxSizer *group_g = new wxBoxSizer(wxHORIZONTAL);
	m_sch_gauge = new wxGauge(this, wxID_ANY, 100, wxDefaultPosition, wxSize(300, 10));
	group_g->Add(5, 10);
	group_g->Add(m_sch_gauge, 1, wxEXPAND);
	group_g->Add(5, 10);
	
	//list
	m_dbtree = new DBTreeCtrl(frame, this, wxID_ANY);
	m_searchResult = new DBTreeCtrl(frame, this, wxID_ANY);

    wxString expath = wxStandardPaths::Get().GetExecutablePath();
    expath = expath.BeforeLast(GETSLASH(),NULL);
#ifdef _WIN32
    wxString dft = expath + "\\catalog_list.set";
	if (!wxFileExists(dft))
		dft = wxStandardPaths::Get().GetUserConfigDir() + "\\catalog_list.set";
#else
    wxString dft = expath + "/../Resources/" + "catalog_list.set";
#endif
    wxFileInputStream is(dft);
	if (is.IsOk())
	{
		wxTextInputStream tis(is);
		wxString str;

		while (!is.Eof())
		{
			wxString sline = tis.ReadLine();
			m_dbtree->LoadDatabase(sline);
		}
	}

	wxBoxSizer *group2 = new wxBoxSizer(wxHORIZONTAL);
	m_db_text = new DBSearcher(parent, this, ID_DBTextCtrl, wxT("URL or Path"),
		wxDefaultPosition, wxSize(330, 23), wxTE_PROCESS_ENTER);
	m_browse_btn = new wxButton(this, ID_BrowseBtn, wxT("Browse..."),
		wxDefaultPosition, wxSize(90, 23));
	group2->Add(5, 5);
	group2->Add(m_db_text, 1, wxEXPAND);
	group2->Add(5, 5);
	group2->Add(m_browse_btn, 0, wxALIGN_CENTER);
	group2->Add(5, 5);

	wxBoxSizer *group3 = new wxBoxSizer(wxHORIZONTAL);
	m_add_btn = new wxButton(this, ID_AddDBBtn, wxT("Add"),
		wxDefaultPosition, wxSize(90, 28));
	group3->AddStretchSpacer(1);
	group3->Add(5, 5);
	group3->Add(m_add_btn, 0, wxALIGN_CENTER);
	group3->Add(5, 5);

	//all controls
	wxBoxSizer *sizerV = new wxBoxSizer(wxVERTICAL);
	sizerV->Add(10, 10);
	sizerV->Add(group1, 0, wxEXPAND);
	sizerV->Add(10, 5);
	sizerV->Add(group_g, 0, wxEXPAND);
	sizerV->Add(10, 10);
	sizerV->Add(m_dbtree, 1, wxEXPAND);
	sizerV->Add(m_searchResult, 1, wxEXPAND);
	sizerV->Add(10, 20);
	sizerV->Add(group2, 0, wxEXPAND);
	sizerV->Add(10, 5);
	sizerV->Add(group3, 0, wxEXPAND);
	m_searchResult->Hide();
	m_sch_gauge->Hide();
	
	SetSizer(sizerV);
	Layout();

	m_thread = NULL;
	m_th_del = NULL;

	Thaw();
	SetEvtHandlerEnabled(true);
}