Exemple #1
0
static int iocBuild_1(void)
{
    if (iocState != iocVirgin && iocState != iocStopped) {
        errlogPrintf("iocBuild: IOC can only be initialized from uninitialized or stopped state\n");
        return -1;
    }
    errlogInit(0);
    initHookAnnounce(initHookAtIocBuild);

    if (!epicsThreadIsOkToBlock()) {
        epicsThreadSetOkToBlock(1);
    }

    errlogPrintf("Starting iocInit\n");
    if (checkDatabase(pdbbase)) {
        errlogPrintf("iocBuild: Aborting, bad database definition (DBD)!\n");
        return -1;
    }
    epicsSignalInstallSigHupIgnore();
    initHookAnnounce(initHookAtBeginning);

    coreRelease();
    iocState = iocBuilding;

    taskwdInit();
    callbackInit();
    initHookAnnounce(initHookAfterCallbackInit);

    return 0;
}
Exemple #2
0
 ListEm::ListEm(QWidget *parent) : QMainWindow(parent)
 {
     m_listEmWrapper = new ListEmWrapper(this);
     m_storage = createListStorage();
     m_logger = createLogger();
     setupUI(m_storage,
             m_logger);
     QTimer::singleShot(100, this, SLOT(checkDatabase()));
 }
DBImage::DBImage (QString database, typeLoading load, Mixer mix): loadPath(database), load(load), mix(mix)
{
	nbrImgPerFace	= -1;
	nbrFaces		= -1;
	personTmp		= NULL;
	idLoaded		= -1;

	if(checkDatabase()) loadDatabase();

}
Exemple #4
0
void TestGui::testSave()
{
    m_db->metadata()->setName("Save");
    // wait for modified timer
    QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*"));

    triggerAction("actionDatabaseSave");
    QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save"));

    checkDatabase();
}
Exemple #5
0
bool ASQLiteDatabase::transaction ()
{
	if (m_transaction == true || checkDatabase() == false)
		return false;

	if (ADatabase::transaction() == false)
	{
		setLastError();
		return false;
	}

	m_transaction = true;

	return true;
}
Exemple #6
0
void TestGui::testDatabaseSettings()
{
    triggerAction("actionChangeDatabaseSettings");
    QWidget* dbSettingsWidget = m_dbWidget->findChild<QWidget*>("databaseSettingsWidget");
    QSpinBox* transformRoundsSpinBox = dbSettingsWidget->findChild<QSpinBox*>("transformRoundsSpinBox");
    transformRoundsSpinBox->setValue(100);
    QTest::keyClick(transformRoundsSpinBox, Qt::Key_Enter);
    // wait for modified timer
    QTRY_COMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save*"));
    QCOMPARE(m_db->transformRounds(), Q_UINT64_C(100));

    triggerAction("actionDatabaseSave");
    QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("Save"));

    checkDatabase();
}
Exemple #7
0
AQuery* ASQLiteDatabase::createQuery (const QString& sql, bool prepared)
{
	if (checkDatabase() == false)
		return false;

	AQuery* query = 0;

	if (prepared == true)
		query = ADatabase::createPreparedQuery(sql);
	else
		query = ADatabase::createQuery(sql);

	if (query == NULL)
	{
		if (m_transaction == true)
			rollback();
	}

	return query;
}
void CoverThread::run()
{
  qDebug() << "INFO: CoverManager -> Running";
  if(m_bFullDBSearch)
  {
    qDebug() << "INFO: CoverManager -> Full database check";
    checkDatabase();
  }

  m_iMax = m_workList.size();

  processSearch();

  //! Start thread event loop --> makes signals and slots work
  exec();
  qDebug() <<"CoverManager -> Exited";

  m_bFullDBSearch      = true;
  m_workList.clear();
}
Exemple #9
0
void TestGui::testSaveAs()
{
    QFileInfo fileInfo(m_orgDbFile.fileName());
    QDateTime lastModified = fileInfo.lastModified();

    m_db->metadata()->setName("SaveAs");

    QTemporaryFile* tmpFile = new QTemporaryFile();
    // open temporary file so it creates a filename
    QVERIFY(tmpFile->open());
    m_tmpFileName = tmpFile->fileName();
    delete tmpFile;
    fileDialog()->setNextFileName(m_tmpFileName);

    triggerAction("actionDatabaseSaveAs");

    QCOMPARE(m_tabWidget->tabText(m_tabWidget->currentIndex()), QString("SaveAs"));

    checkDatabase();

    fileInfo.refresh();
    QCOMPARE(fileInfo.lastModified(), lastModified);
}
Exemple #10
0
void Rcon::checkWhitelistedPlayer(std::string &player_number, std::string &player_name, std::string &player_guid, bool &kicked)
{
	bool whitelisted_player = false;
	{
		// Checking vector for Whitelisted GUID
		if (std::find(whitelist_settings.whitelisted_guids.begin(), whitelist_settings.whitelisted_guids.end(), player_guid) != whitelist_settings.whitelisted_guids.end())
		{
			// Whitelisted Player - Unordered_map
			whitelisted_player = true;
			whitelist_settings.players_whitelisted[std::move(player_guid)] = std::move(player_name);
		}
		// Checking database for Whitelisted GUID
		else if (!whitelisted_player && whitelist_settings.connected_database)
		{
			bool status = false;
			bool error = false;

			whitelist_statement->bindClear();
			*whitelist_statement.get(), Poco::Data::Keywords::use(player_guid);
			whitelist_statement->bindFixup();
			checkDatabase(status, error);

			if (error)
			{
				// Whitelisted Player - DB, error occured during Database Check
				if (whitelist_settings.kick_on_failed_sql_query)
				{
					logger->info("RCon: Database Player Check error occurred, kicking player");
					sendCommand("kick " + player_number + " " + whitelist_settings.kick_message);
					kicked = true;
				}
				else
				{
					logger->info("RCon: Database Player Check error occurred, will assume player is whitelisted");
					whitelisted_player = true;
					whitelist_settings.players_whitelisted[std::move(player_guid)] = std::move(player_name);
				}
			}
			else if (status)
			{
				// Whitelisted Player - DB
				whitelisted_player = true;
				whitelist_settings.players_whitelisted[std::move(player_guid)] = std::move(player_name);
			}
		}

		if (!whitelisted_player)
		{
			// NON-WHITELISTED PLAYER
			if ((whitelist_settings.players_non_whitelisted.size() + whitelist_settings.players_whitelisted.size()) <= whitelist_settings.open_slots)
			{
				whitelist_settings.players_non_whitelisted[std::move(player_guid)] = std::move(player_name);
			}
			else
			{
				logger->info("RCon: Kicked Playername: {0} GUID: {1}  Not Whitelisted", player_name, player_guid);
				sendCommand("kick " + player_number + " " + whitelist_settings.kick_message);
				kicked = true;
			}
		}
	}
}
Exemple #11
0
int main() {
    //DWORD* wohoo[0xFFFF];

    /*
    std::string str;
    std::ifstream configFile("config.ini");
    while (!configFile.eof()) {
        str.clear();
        configFile>>str;
        if (str.size() > 0) {
            std::cout << "--> " << str << std::endl;
        }
    }
    configFile.close();
    */

    //TODO (NitriX#): read config from config.ini
    //TODO (NitriX#): Implement a Timer so it d/c servers when they are ping timed out

    //signal(SIGINT,leaving); signal(SIGTERM,leaving);
    //signal(SIGILL,leaving); signal(SIGABRT,leaving);

    //TODO (NitriX#): I added too much DWORD everywhere... somes could be 'unsigned int' as well, sorry :/

    //TODO (NitriX#): We needs a function that reloads the worldserver list from DB

    //TODO (NitriX#1#): Omg log system! :<

    //TODO (NitriX#0#): What with packets hash? CRC32 please...
    //CCRC32 ccrc32;
    //std::string test = "Omfg we rules :D";
    //unsigned long hash = ccrc32.FullCRCString(test);
    //std::cout << "Hash CRC32: " << hash << std::endl;

	//HEADER MESSAGE
    std::cout <<
    "/===============================================\\" << std::endl <<
    "|         ~ NNYv3 Realm Server ~" << "\t\t|" << std::endl <<
    "|\t\t\t\t\t\t|" << std::endl <<
    "| Database supported: v" << CONFIG_DATABASE_SUPPORTED << "\t\t\t|" << std::endl <<
    //"|===============================================|" << std::endl <<
    //"| Recent modifications: \t\t\t|" << std::endl <<
    //"| + Realm Server is now fully working\t\t|" << std::endl <<
    //"| + capsuleHdl_sync is now done\t\t\t|" << std::endl <<
    //"| + capsuleHdl_updater is now done\t\t|" << std::endl <<
    //"| + A much cleaner capsuleHandler\t\t|" << std::endl <<
    //"| + updater:: has been removed from sources\t|" << std::endl <<
    //"| + Optimization; BYTE, WORD & DWORD added\t|" << std::endl <<
    //"| + Fixed threadHandler(); has been re-coded\t|" << std::endl <<
    //"| + Fixed threadData; memory protection added\t|" << std::endl <<
    //"| + TODOs added a bit everywhere in sources\t|" << std::endl <<
    //"| + Web panel performance issue; disabled\t|" << std::endl <<
    //"| + Web administration panel implemented\t|" << std::endl <<
    //"| + Worldservers dispatcher implemented\t\t|" << std::endl <<
    //"| + Fixed pthread_create(); s_thread_data added\t|" << std::endl <<
    //"| + Added MySQL library support \t\t|" << std::endl <<
    //"| + Added autoversioning support \t\t|" << std::endl <<
    //"| + Added byte arrays support \t\t\t|" << std::endl <<
    //"| + Added multi-threading support \t\t|" << std::endl <<
    //"| + Added ZSocket library \t\t\t|" << std::endl <<
    "\\===============================================/" << std::endl;
    //--------- Initiate database ------------
    Database database;
	database.connect();
	checkDatabase(database);

    //--------- Initiate dispatcher ------------
    Dispatcher dispatcher(database);
    //dispatcher.printServers();

    //--------- Starting HTTP Panel ------------
    //TODO (NitriX#): A HTTP Panel would be nice, dont you think ^^
    //Disabled for now, slow without a threadpool implementation
    /*
    std::cout << "Starting Administration Panel...";
    pthread_t pthread_httpHandler;
    int rcx;
    rcx = pthread_create(&pthread_httpHandler, NULL, httpHandler, NULL);
    rcx = pthread_detach(pthread_httpHandler);
    if (rcx) {
        std::cout << "@ERROR: pthread: pthread_create() failed!" << std::endl;
    }
    std::cout << "OK!" << std::endl;
    */

    //--------- Listening server ------------
    std::cout << "[main] Listening on port 6131... ";
    ZSocket socket; //Creating main server socket
    if (socket.socket_bind(CONFIG_SERVER_PORT)) {
        std::cout << "OK!" << std::endl << std::endl;
    } else {
        std::cout << "Failed!" << std::endl << "@ERROR: Unable to bind socket on port 6131" << std::endl;
        exit(EXIT_FAILURE);
    }

    //--------- STARTING SERVER ------------
    std::cout << "Realm Server started!" << std::endl;
    std::cout << "Waiting for connections..." << std::endl;
    //TODO (NitriX#): What about a ThreadPool?
    while (true) {
        pthread_t pthread; //New thread
        //======== THREAD DATA ==========
        //Waiting for clients, accept client from main socket and copy socket id into threadData.
        s_thread_data threadData; //Create a data structure that will be sent to the thread when its created
        threadData.socketID                 =  socket.socket_acceptClient(); //Oh yeah, the thread will need the client's socket
        threadData.database                 = &database;
        threadData.dispatcher               = &dispatcher;
	pthread_mutex_init(&threadData.memory_protect_mutex, NULL);
        //threadData.memory_protect_mutex     =  PTHREAD_MUTEX_INITIALIZER;    //Also a memory protection...
        pthread_cond_init(&threadData.memory_protect_signal, NULL);
	//threadData.memory_protect_signal    =  PTHREAD_COND_INITIALIZER;     //Another memory protection...
        threadData.memory_flag_done_copying =  false;                        //And one more memory protection...
        //===============================
        //Launching thread and send the threadData structure memory address as parameters
        int rc;
        rc = pthread_create(&pthread, NULL, threadHandler, &threadData); //here we send the s_thread_data address to the thread
        rc = pthread_detach(pthread); //Detach thread so it works on its own
            //Now we waits for the thread to copy threadData to some local vars...
            //else if we continue processing and threadHandler isnt done copying,
            //we are gonna get REALLY mean errors! Lets just avoid that and wait a bit =]

            //-- Waiting for focus; usually acquire immediatly
            //just some sort of security I guess (recommended from pthread documentation)
            pthread_mutex_lock(&threadData.memory_protect_mutex);

            //-- Check if the condition flag is still false
            //I mean, are we done copying? If so, dont waste our time anymore and jump...
            while(!threadData.memory_flag_done_copying)
                //-- Nah we arnt done copying, pause the thread and wait for a signal
                pthread_cond_wait(&threadData.memory_protect_signal, &threadData.memory_protect_mutex);
                //-- We got THE signal and we are back to life; what now?
                //-- Oh is the flag changed :D !? Loop and test the flag one more time.
                //-- (Normally, the flag has been sucessfully changed at this point... but we never know)

            //-- ... jump to here. Good. Release focus; normal processing from now :)
            pthread_mutex_unlock(&threadData.memory_protect_mutex);
        if (rc) {
            std::cout << "[main] @ERROR: pthread: pthread_create() failed!" << std::endl;
        }
    }

    return 0;
}