int main(int argc, char ** argv)
{
    std::cout << "Starting K7Server..." << std::endl;

    // Create a QCoreApplication.
    QCoreApplication app(argc, argv);

    try {

        // Parse command line arguments to create the configuration object.
        pelican::Config config = createConfig(argc, argv);
        // Create a Pelican server.
        pelican::PelicanServer server(&config);

        // Attach the chunker to server.
        server.addStreamChunker("K7Chunker");

        // Create a communication protocol object and attach it to the server on port 2000.
        pelican::AbstractProtocol* protocol =  new pelican::PelicanProtocol;
        server.addProtocol(protocol, 2000);

        // Start the server.
        server.start();

        // When the server is ready enter the QCoreApplication event loop.
        while (!server.isReady()) {}
        return app.exec();
    }
    // Catch any error messages from Pelican.
    catch (const QString& err)
    {
        std::cerr << "Error: " << err.toStdString() << std::endl;
    }
}
EGLConfig EGLConfigSelector::pixmapContextConfig()
{
    if (!m_pixmapFBConfig)
        m_pixmapFBConfig = createConfig(EGL_PIXMAP_BIT);

    return m_pixmapFBConfig;
}
EGLConfig EGLConfigSelector::surfaceContextConfig()
{
    if (!m_surfaceContextFBConfig)
        m_surfaceContextFBConfig = createConfig(EGL_WINDOW_BIT);

    return m_surfaceContextFBConfig;
}
Пример #4
0
MasterApplication::MasterApplication( int& argc_, char** argv_,
                                      MPIChannelPtr worldChannel )
    : QApplication( argc_, argv_ )
    , masterToWallChannel_( new MasterToWallChannel( worldChannel ))
    , masterFromWallChannel_( new MasterFromWallChannel( worldChannel ))
    , markers_( new Markers )
{
    // don't create touch points for mouse events and vice versa
    setAttribute( Qt::AA_SynthesizeTouchForUnhandledMouseEvents, false );
    setAttribute( Qt::AA_SynthesizeMouseForUnhandledTouchEvents, false );

    CommandLineParameters options( argc_, argv_ );
    if( options.getHelp( ))
        options.showSyntax();

    if( !createConfig( options.getConfigFilename( )))
        throw std::runtime_error( "MasterApplication: initialization failed." );

    displayGroup_.reset( new DisplayGroup( config_->getTotalSize( )));

    init();

    const QString& session = options.getSessionFilename();
    if( !session.isEmpty( ))
        StateSerializationHelper( displayGroup_ ).load( session );
}
Пример #5
0
/*! Zmena stylu na plain*/
void MainWindow::on_actionPlain_activated()
{
    scene->readStyles("Plain");
    createConfig("Plain");
    readConfig();
    readStyle(lastUsedStyle);   //nacteni fontu pro hlavni okno
    changeFont();
}
Пример #6
0
EGLConfig EGLConfigSelector::surfaceContextConfig()
{
    if (!m_surfaceContextFBConfig) {
        configAttributeList[13] = EGL_WINDOW_BIT;
        m_surfaceContextFBConfig = createConfig(configAttributeList);
    }

    return m_surfaceContextFBConfig;
}
Пример #7
0
EGLConfig EGLConfigSelector::pBufferContextConfig()
{
    if (!m_pbufferFBConfig) {
        configAttributeList[13] = EGL_PIXMAP_BIT;
        m_pbufferFBConfig = createConfig(configAttributeList);
    }

    return m_pbufferFBConfig;
}
void KisPropertiesConfigurationTest::testSerialization()
{
    KisPropertiesConfigurationSP config = createConfig();
    QString xml = config->toXML();
    KisPropertiesConfigurationSP decodedConfig = new KisPropertiesConfiguration();
    decodedConfig->fromXML(xml);
    testConfig(decodedConfig);

}
EGLConfig EGLConfigSelector::surfaceClientConfig(NativeVisualId id)
{
    EGLConfig config = findMatchingConfigWithVisualId(id);

    if (!config)
        config = createConfig(EGL_PIXMAP_BIT);

    return config;
}
Пример #10
0
std::string Widget::configStruct()
{
  std::stringstream config;

  config << "{a:0";
  createConfig(config);
  config << "}";

  return config.str();
}
Пример #11
0
void SWIApp::optimizerTick()
{
	std::vector<float> params (optimizer->ndims);

	// best of this generation
	SqcConfig *last_best = 0;
	SqcConfig *config = createConfig();

	// Calculate fitness values for each element
	for (int i=0;i<optimizer->nelems;i++) {
		optimizer->getElem(i, &params[0]);

		config->initFromParams(params);
		config->calcSquarePositions();
		config->calcFitness();
		optimizer->setFitness(i, config->fitness);

		if (!last_best || config->fitness >= last_best->fitness) {
			if(last_best) delete last_best;
			last_best = config;
			config = createConfig();
		}
	}

	if (last_best) {
		if (!best || last_best->fitness > best->fitness) {
			best = last_best;
			d_trace("New best radius: %f. Overlap: %f. Fitness: %f\n", best->radius, best->overlap, best->fitness);
			for (int i=0;i<best->nsquares();i++)
				d_trace(" (%f,%f);", best->getSquare(i).x, best->getSquare(i).y);
			d_trace("\n");
			sigma = 1.0f;
		} else {
			sigma *= 1.005f;
		}

		graph.addTick(last_best->collectParams());
		best_list.push_back(last_best);
	} 
	delete config;
	optimizer->tick(sigma*(sinf(sigma)+1.0f));
}
Пример #12
0
bool INIConfig::setValue(const Common::String &file, const Common::String &section,
		const Common::String &key, const Common::String &value) {

	Config config;
	if (!getConfig(file, config))
		if (!createConfig(file, config))
			return false;

	config.config->setKey(key, section, value);
	return true;
}
Пример #13
0
int main(int argc, char* argv[]) 
{
    tsClient client;
    client.numNodes = 5;
    createConfig(client.nodes,client.indexMap,NUM_NODES,client.nodeController);
    readConfig(client.nodes,client.numNodes);
    client.clientSetup();
    client.startConnection();
    writeConfig(client.nodes,client.numNodes,client.indexMap);
    destroyNodes(client.nodes);
    return 0;
}
Пример #14
0
void MessageBox::setHidden(bool hidden, const WAnimation& animation)
{
  if (hidden != hidden_) {
    hidden_ = hidden;

    WApplication *app = WApplication::instance();

    if (!hidden)
      setExposeMask(app);
    else
      restoreExposeMask(app);
 
    if (hidden)
      app->doJavaScript(elRef() + ".hide();");
    else {
      std::stringstream config;
      config << "{a:0";
      createConfig(config);
      config << "}";

      std::string var;
      if (firstDisplay_) {
	var = elRef() + "=Ext.Msg";

	/* fix cursor problem in FF 1.5, 2 */
	if (!app->environment().agentIsIE())
	  app->doJavaScript
	  ("Ext.Msg.getDialog().on('show', function(d) {"
	   "var div = Ext.get(d.el);"
	   "div.setStyle('overflow', 'auto');"
	   "var text = div.select('.ext-mb-textarea', true);"
	   "if (!text.item(0))"
	   "text = div.select('.ext-mb-text', true);"
	   "if (text.item(0))"
	   "text.item(0).dom.select();});");
      } else
	var = elRef();

      WApplication::instance()
	->doJavaScript(var + ".show(" + config.str() + ");");

      if (progress_) {
	WApplication::instance()
	  ->doJavaScript(elRef() + ".updateProgress("
			 + boost::lexical_cast<std::string>(progressValue_)
			 + ");");
      }

      firstDisplay_ = false;
    }
  }
}
void KisPropertiesConfigurationTest::testNotSavedValues()
{
    KisPropertiesConfiguration* config = createConfig();
    config->setPropertyNotSaved("v3");
    testConfig(config);
    QString s = config->toXML();
    delete config;
    config = new KisPropertiesConfiguration();
    config->fromXML(s);
    QVERIFY(config->getInt("v1", 0) == v1);
    QVERIFY(config->getString("v2", "") == v2);
    QVERIFY(config->hasProperty("v3") == false);
    QVERIFY(config->getBool("v4", !v4) == v4);
    QVERIFY(config->getCubicCurve("v5") == v5);
    delete config;   
}
Пример #16
0
int main(int argc, char **argv)
{
    createConfig();
  //ros::init(argc, argv, "ice_engine_test");
//  try
//  {
    ::testing::InitGoogleTest(&argc, argv);

    return RUN_ALL_TESTS();
//  }
//  catch (std::exception &e)
//  {
//    std::cerr << "Unhandled Exception: " << e.what() << std::endl;
//  }
//  return 1;
}
Пример #17
0
static void
OpenOrCreate(HWND hwnd)
{
	static bool openAlreadyOpened = false;

	if (openAlreadyOpened)
		return;

	class Unique {
	public:
		Unique() { openAlreadyOpened = true; }
		~Unique() { openAlreadyOpened = false; }
	} unique;

	std::tstring dir = GetExistingDirectory(hwnd,
		_T("Select a folder which contains or will contain encrypted data."), _T("Select Crypt Folder"));
	if (dir.empty())
		return;

	// if directory is already configured add and try to mount
	boost::shared_ptr<EncFSConfig> config(new EncFSConfig);
	if (readConfig(slashTerminate(wchar_to_utf8_cstr(dir.c_str())), config) != Config_None) {
		char drive = SelectFreeDrive(hwnd);
		if (drive) {
			Drives::drive_t dr(Drives::Add(dir, drive));
			if (dr)
				dr->Mount(hwnd);
		}
		return;
	}

	// TODO check directory is empty, warning if continue
	// "You are initializing a crypted directory with a no-empty directory. Is this expected?"
	OptionsData data;
	data.rootDir = dir;
	if (DialogBoxParam(hInst, (LPCTSTR) IDD_OPTIONS, hwnd, (DLGPROC) OptionsDlgProc, (LPARAM) &data) != IDOK)
		return;

	// add configuration and add new drive
	createConfig(slashTerminate(wchar_to_utf8_cstr(dir.c_str())), data.paranoia, false, wchar_to_utf8_cstr(data.password).c_str(), true);

	Drives::drive_t dr(Drives::Add(dir, data.drive));
	if (dr)
		dr->Mount(hwnd);
}
Пример #18
0
Startup::Startup( QObject * parent )
    :QObject(parent)
{
    db = DbNote::getInstance();

    config_t config_state = config.checkConfig();

    if( config_state == no_conf )
    {
        reportErrorMesg("Your config-file is damaged or\n the permissions are wrong !");
    }
    else if ( config_state == load_conf )
    {
        start();
    }
    else if( config_state == empty_conf )
    {
        createConfig();
    }

}
Пример #19
0
std::string AbstractButton::createJSHelper(const std::string& extClassName,
					   bool intoElement)
{
  std::stringstream result;
  std::string menuvar;

  std::stringstream buf;

  buf << "{a:0";

  if (checkable_ != false) {
    if (extClassName != "Ext.menu.CheckItem")
      buf << ",enableToggle:true";

    if (checked_ != false) {
      buf << "," << checkInitialState() << ":true";
    }
  }

  if (menu_) {
    menuvar = menu_->createExtElement(result, 0);
    buf << ",menu:" << menuvar;
  }

  createConfig(buf);
  buf << "}";

  result <<
    elVar() << "=new " << extClassName << "(" << buf.str() << ");";

  if (intoElement)
    result << elVar() << ".render('" << id() << "');";

  bindEventHandler(checkEventJS(), "toggleH", result);

  return result.str();
}
Пример #20
0
SWIApp::SWIApp() : graph(600, -10, 10)
{
	int nsquares = 2;

	sigma = 1.0f;
	best=0;
	
	//initRandomOptimizer(nsquares);
	std::vector<float> ranges = std::vector<float>(nsquares * 4);
	for (int i=0;i<(nsquares-1)*2;i++) {
		ranges[i*2]=-10.0f;
		ranges[i*2+1]=10.0f;
	}

	SwarmConfig sc;
	sc.graphType = ST_MULTISTAR;
//	sc.phi1 = sc.phi2 = 0.4f;
	sc.omega = 0.7f;
	sc.phi1 = 1.4f;
	sc.phi2 = 1.4f;

	SqcConfig* cfg = createConfig();
	optimizer = new ESOptimizer(ranges);
//	optimizer = new SwarmOptimizer(sc);
	cfg->randomConfig(nsquares);
	optimizer->initialize(cfg->collectParams().size(), 100);

	std::vector<float> params;

	for (int j=0;j<optimizer->nelems;j++) {
		cfg->randomConfig(nsquares);
		params=cfg->collectParams();
		optimizer->setElem(j, &params[0]);
	}

}
void KisPropertiesConfigurationTest::testSetGet()
{
    KisPropertiesConfiguration* config = createConfig();
    testConfig(config);
    delete config;
}
Пример #22
0
bool readConfig() // чтение и загрузка конфигурации
{	
	FILE *file_Fp;
	if ((file_Fp = _wfopen(config_file_name_ca, L"r")) != NULL)
	{
		wchar_t sym;
		//Считывание имени!!!
		CurrentGame.lastLevelName.clear();
		fwscanf(file_Fp, L"%c", &sym);
		while (sym != L'\n') {
			CurrentGame.lastLevelName.push_back(sym);
			fwscanf(file_Fp, L"%c", &sym);
		}
		fwscanf(file_Fp, L"%i", &CurrentGame.saveStatus);
		if (!CurrentGame.saveStatus){
			fclose(file_Fp);
			return false;
		}
		fwscanf(file_Fp, L"%i", &CurrentGame.lifes);
		fwscanf(file_Fp, L"%i", &CurrentGame.points);
		fwscanf(file_Fp, L"%i", &CurrentBall.speed);
		fwscanf(file_Fp, L"%i", &CurrentBall.timer);
		fwscanf(file_Fp, L"%i", &CurrentBall.stepNum);
		fwscanf(file_Fp, L"%i %i", &CurrentBall.position.X, &CurrentBall.position.Y);
		fwscanf(file_Fp, L"%i %i", &CurrentBall.course.X, &CurrentBall.course.Y);
		fwscanf(file_Fp, L"%i %i", &CurrentPlatform.position.X, &CurrentPlatform.position.Y);
		fseek(file_Fp, 3, SEEK_CUR);
		CurrentLevel.Size_Strings = CurrentGame.Levels[CurrentGame.CurrentLevelNumber]->Size_Strings;
		if (CurrentGame.saveStatus == 1) {
			for (int i = 0; i < CurrentLevel.Size_Strings; i++) {
				for (int j = 0; j < CurrentLevel.Size_Columns; j++) {
					fwscanf(file_Fp, L"%c", &(CurrentLevel.Map[i][j].element));
				}
				fseek(file_Fp, 2, SEEK_CUR);
			}

		} else if (CurrentGame.saveStatus == 0) {
			CurrentGame.loadCurrentLevelByNumber(); // новая игра
		}
		fclose(file_Fp);
		return true;
	} else {
		if (createConfig()) {
			if ((file_Fp = _wfopen(config_file_name_ca, L"r")) != NULL)
			{
				wchar_t sym;
				//Считывание!!!
				CurrentGame.CurrentLevelName.clear();
				fwscanf(file_Fp, L"%c", &sym);
				while (sym != L'\n') {
					CurrentGame.lastLevelName.push_back(sym);
					fwscanf(file_Fp, L"%c", &sym);
				}
				fwscanf(file_Fp, L"%i", &CurrentGame.saveStatus);
				if (!CurrentGame.saveStatus){
					return false;
				}
				fwscanf(file_Fp, L"%i", &CurrentGame.lifes);
				fwscanf(file_Fp, L"%i", &CurrentGame.points);
				fwscanf(file_Fp, L"%i", &CurrentBall.speed);
				fwscanf(file_Fp, L"%i", &CurrentBall.timer);
				fwscanf(file_Fp, L"%i", &CurrentBall.stepNum);
				fwscanf(file_Fp, L"%i %i", &CurrentBall.position.X, &CurrentBall.position.Y);
				fwscanf(file_Fp, L"%i %i", &CurrentBall.course.X, &CurrentBall.course.Y);
				fwscanf(file_Fp, L"%i %i", &CurrentPlatform.position.X, &CurrentPlatform.position.Y);
				fseek(file_Fp, 3, SEEK_CUR);
				CurrentLevel.Size_Strings = CurrentGame.Levels[CurrentGame.CurrentLevelNumber]->Size_Strings;
				if (CurrentGame.saveStatus == 1) {
					for (int i = 0; i < CurrentLevel.Size_Strings; i++) {
						for (int j = 0; j < CurrentLevel.Size_Columns; j++) {
							fwscanf(file_Fp, L"%c", &(CurrentLevel.Map[i][j].element));
						}
						fseek(file_Fp, 2, SEEK_CUR);
					}
				} else if (CurrentGame.saveStatus == 0) {
					CurrentGame.CurrentLevelNumber = 0;
					CurrentGame.loadCurrentLevelByNumber();
					MessageBox(hWnd, L"Новая игра!", 
					L"Игра", MB_OK | MB_ICONINFORMATION
					);	
					SetTimer(hWnd, GamePlayTimer, CurrentGame.FPS, NULL);

				}
				fclose(file_Fp);
				return true;
			} else {
		  	    MessageBox(hWnd, L"Конфигурационный файл существует, но из него невозможно считать данные!", 
					L"Конфигурационный файл", MB_OK | MB_ICONINFORMATION
				);	
				fclose(file_Fp);
				return false;
			}
		} else {
	 	    MessageBox(hWnd, L"Не удается записать и прочитать данные!", 
			L"Данные", MB_OK | MB_ICONINFORMATION
			);	
			return false;
		}
	}
}
void KisPropertiesConfigurationTest::testSetGet()
{
    KisPropertiesConfigurationSP config = createConfig();
    testConfig(config);
}
Пример #24
0
bool HTMLSearch::generateIndex(QString _lang, QWidget *parent)
{
    if (_lang == "C")
        _lang = "en";

    if (!createConfig(_lang))
        return false;

    // create progress dialog
    progress = new ProgressDialog(parent);
    progress->show();
    kapp->processEvents();

    // create files list ----------------------------------------------
    if (!saveFilesList(_lang))
        return false;

    progress->setState(1);

    // run htdig ------------------------------------------------------
    KConfig *config = new KConfig("khelpcenterrc", true);
    KConfigGroupSaver saver(config, "htdig");
    QString exe = config->readPathEntry("htdig", kapp->dirs()->findExe("htdig"));

    if (exe.isEmpty())
    {
        delete config;
        return false;
    }
    bool initial = true;
    bool done = false;
    int  count = 0;

    _filesToDig = _files.count();
    progress->setFilesToDig(_filesToDig);
    _filesDigged = 0;

    QDir d; d.mkdir(dataPath(_lang));

    while (!done)
    {
        // kill old process
        delete _proc;

        // prepare new process
        _proc = new KProcess();
        *_proc << exe  << "-v" << "-c" << dataPath(_lang)+"/htdig.conf";
        if (initial)
	{
            *_proc << "-i";
            initial = false;
	}

        kdDebug() << "Running htdig" << endl;

        connect(_proc, SIGNAL(receivedStdout(KProcess *,char*,int)),
                this, SLOT(htdigStdout(KProcess *,char*,int)));

        connect(_proc, SIGNAL(processExited(KProcess *)),
                this, SLOT(htdigExited(KProcess *)));

        _htdigRunning = true;

        // write out file
        QFile f(dataPath(_lang)+"/files");
        if (f.open(IO_WriteOnly))
	{
            QTextStream ts(&f);

            for (int i=0; i<CHUNK_SIZE; ++i, ++count)
                if (count < _filesToDig) {
                    ts << "file://" + _files[count] << endl;
                } else {
                    done = true;
                    break;
                }
            f.close();
	}
        else
	{
            kdDebug() << "Could not open `files` for writing" << endl;
            delete config;
            return false;
	}


        // execute htdig
        _proc->start(KProcess::NotifyOnExit, KProcess::Stdout );

        kapp->enter_loop();

        if (!_proc->normalExit() || _proc->exitStatus() != 0)
	{
            delete _proc;
            delete progress;
            delete config;
            return false;
	}

        // _filesDigged += CHUNK_SIZE;
        progress->setFilesDigged(_filesDigged);
        kapp->processEvents();
    }

    progress->setState(2);

    // run htmerge -----------------------------------------------------
    exe = config->readPathEntry("htmerge", kapp->dirs()->findExe("htmerge"));
    if (exe.isEmpty())
    {
        delete config;
        return false;
    }
    delete _proc;
    _proc = new KProcess();
    *_proc << exe << "-c" << dataPath(_lang)+"/htdig.conf";

    kdDebug() << "Running htmerge" << endl;

    connect(_proc, SIGNAL(processExited(KProcess *)),
            this, SLOT(htmergeExited(KProcess *)));

    _htmergeRunning = true;

    _proc->start(KProcess::NotifyOnExit, KProcess::Stdout);

    kapp->enter_loop();

    if (!_proc->normalExit() || _proc->exitStatus() != 0)
    {
        delete _proc;
        delete progress;
        delete config;
        return false;
    }

    delete _proc;

    progress->setState(3);
    kapp->processEvents();

    delete progress;
    delete config;

    return true;
}
Пример #25
0
NcBatWriter::NcBatWriter(MemgenConfigStorage* mcs) {
	QString tmp = (QString)"nc_config";
	this->cad_config_string = mcs->ReturnConfigByKey(tmp);
    createConfig();

}
Пример #26
0
Файл: lr0.c Проект: imuli/anic
#include "y.h"


static void propagateOriginatorChange(State * s);


void addSuccessorConfigToState_LR0(State * s, int ruleID) {
  Configuration * c;

  if (s->config_count >= s->config_max_count - 1) {
    s->config_max_count *= 2;
    HYY_EXPAND(s->config, Configuration *, s->config_max_count);
  }

  // marker = 0, isCoreConfig = 0.
  c = createConfig(ruleID, 0, 0);
  c->owner = s;

  s->config[s->config_count] = c;
  s->config_count ++;  
}


/*
 * Assumption: public variable config_queue contains 
 * the configurations to be processed.
 */
void getConfigSuccessors_LR0(State * s) {
  RuleIDNode * r;
  SymbolTblNode * scanned_symbol = NULL;
  Configuration * config;
Пример #27
0
void sudabot::loadConfig(){

	ifstream file("sudabot.conf");
	if(file.is_open()){
		char line[100];
		while(!file.eof()){
			file.getline(line,100);
//			cout<<line<<endl;
//process line
		string ln=string(line);//convert line to a string 
		//because i feel it is ezer that way so f**k it, i do what i want lol
		//need more tea, beer time soon...
//		cout<<ln<<endl;
		if(ln.substr(0,2)!="//"){
			if(ln.substr(0,7)=="server="){
				server=config_getValue(ln.substr(7));
				cout<<"SERVER:"<<server<<endl;
			}
				if(ln.substr(0,5)=="port="){
				port=config_getValue(ln.substr(5));
				cout<<"PORT:"<<port<<endl;
			}
				if(ln.substr(0,8)=="channel="){
				channel=config_getValue(ln.substr(8));
				cout<<"Channel:"<<channel<<endl;
			}

				if(ln.substr(0,6)=="nicks="){
				nick=config_getValue(ln.substr(6));
				cout<<"Nick:"<<nick<<endl;
			}

				if(ln.substr(0,11)=="use_passwd="){
						char *upw=config_getValue(ln.substr(11));
						if(string(upw)=="false"){
							
							use_password=false;
						}else{
							use_password=true;
						}
				cout<<"use_password:"******"passwd="){
				passwd=config_getValue(ln.substr(7));
				cout<<"passwd:*****"<<endl;
				}

				if(ln.substr(0,6)=="alias="){
				alias=config_getValue(ln.substr(6));
				cout<<"alias:!"<<alias<<endl;
				}
					if(ln.substr(0,6)=="owner="){
				owner=config_getValue(ln.substr(6));
				cout<<"owner:"<<owner<<endl;
				}

					if(ln.substr(0,16)=="Welcome_enabled="){
				Welcome_enabled=config_getValue(ln.substr(16));
				cout<<"Welcome_enabled:"<<Welcome_enabled<<endl;
				}

				if(ln.substr(0,12)=="Welcome_msg="){
		    	string msg;
				
				for(unsigned int i=13;i<ln.length()  && ln.substr(i,1)!="\"" && ln.substr(i,1)!="\n" ;i++){
						msg+=ln.substr(i,1);
					}
				Welcome_msg=(char*)malloc(100);
					strcpy(Welcome_msg,msg.c_str());

				cout<<"Welcome_msg:"<<Welcome_msg<<endl;
				}

		}

		//next line
		}
	
		file.close();

	}else{
		createConfig();
	}
		


}
EncounterBatWriter::EncounterBatWriter(MemgenConfigStorage* mcs, QString arguments) {
	QString tmp = (QString)"encounter_config";
	this->cad_config_string = mcs->ReturnConfigByKey(tmp);
    createConfig(arguments);

}
EGLConfig EGLConfigSelector::createConfig(EGLint expectedSurfaceType)
{
    if (m_sharedDisplay == EGL_NO_DISPLAY)
        return 0;

    EGLint numConfigs;

    eglGetConfigs(m_sharedDisplay, 0, 0, &numConfigs);

    if (!numConfigs) {
        LOG_ERROR("Failed to retrieve number of EGL configs.");
        return 0;
    }

    EGLConfig configs[numConfigs];
    eglGetConfigs(m_sharedDisplay, configs, numConfigs, &numConfigs);

    if (!numConfigs) {
        LOG_ERROR("Failed to retrieve any EGL configs.");
        return 0;
    }

    EGLConfig config = 0;
    EGLint alpha, surface, red, green, blue, renderType;
    EGLint expectedAlpha = m_attributes & GLPlatformSurface::SupportAlpha ? 8 : 0;
    EGLint expectedRed = 8;
    EGLint expectedBlue = 8;
    EGLint expectedGreen = 8;
#if USE(OPENGL_ES_2)
    EGLint expectedRenderType = EGL_OPENGL_ES2_BIT;
#else
    EGLint expectedRenderType = EGL_OPENGL_BIT,
#endif

    for (int i = 0; i < numConfigs; i++) {
        EGLConfig tempConfig = configs[i];
        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RENDERABLE_TYPE, &renderType);

        if (!(renderType & expectedRenderType))
            continue;

        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_ALPHA_SIZE, &alpha);

        if (alpha != expectedAlpha)
            continue;

        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_RED_SIZE, &red);

        if (red != expectedRed)
            continue;

        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_GREEN_SIZE, &green);

        if (green != expectedGreen)
            continue;

        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_BLUE_SIZE, &blue);

        if (blue != expectedBlue)
            continue;

        eglGetConfigAttrib(m_sharedDisplay, tempConfig, EGL_SURFACE_TYPE, &surface);

        if (surface & expectedSurfaceType) {
            config = configs[i];
            break;
        }
    }

    if ((m_attributes & GLPlatformSurface::SupportAlpha) && !config) {
        LOG_ERROR("Failed to retrieve EGL Configuration with alpha. Trying to find one without alpha support.");
        m_attributes &= ~GLPlatformSurface::SupportAlpha;
        config = createConfig(expectedSurfaceType);
    }

    if (!config)
        LOG_ERROR("Failed to find a valid EGL Configuration.");

    return config;
}
Пример #30
0
QString HTMLSearch::search(QString _lang, QString words, QString method, int matches,
			   QString format, QString sort)
{
  if (_lang == "C")
    _lang = "en";

  createConfig(_lang);

  QString result = dataPath(_lang)+"/result.html";

  // run htsearch ----------------------------------------------------
  KConfig *config = new KConfig("khelpcenterrc", true);
  KConfigGroupSaver saver(config, "htdig");
  QString exe = config->readPathEntry("htsearch", kapp->dirs()->findExe("htsearch"));
  if (exe.isEmpty())
  {
      delete config;
    return QString::null;
  }
  _proc = new KProcess();
  *_proc << exe << "-c" << dataPath(_lang)+"/htdig.conf" <<
    QString("words=%1;method=%2;matchesperpage=%3;format=%4;sort=%5").arg(words).arg(method).arg(matches).arg(format).arg(sort);

  kdDebug() << "Running htsearch" << endl;

  connect(_proc, SIGNAL(receivedStdout(KProcess *,char*,int)),
	  this, SLOT(htsearchStdout(KProcess *,char*,int)));
  connect(_proc, SIGNAL(processExited(KProcess *)),
	  this, SLOT(htsearchExited(KProcess *)));

  _htsearchRunning = true;
  _searchResult = "";

  _proc->start(KProcess::NotifyOnExit, KProcess::Stdout);

  kapp->enter_loop();

  if (!_proc->normalExit() || _proc->exitStatus() != 0)
    {
      kdDebug() << "Error running htsearch... returning now" << endl;
      delete _proc;
      delete config;
      return QString::null;
    }

  delete _proc;

  // modify the search result
  _searchResult = _searchResult.replace("http://localhost/", "file:/");
  _searchResult = _searchResult.replace("Content-type: text/html", QString::null);

  // dump the search result
  QFile f(result);
  if (f.open(IO_WriteOnly))
    {
      QTextStream ts(&f);

      ts << _searchResult << endl;

      f.close();
      delete config;
      return result;
    }
  delete config;
  return QString::null;
}