Exemplo n.º 1
0
/**
 * @brief SOLVER: Main functionality to save the changes of the configuration file with a different name
 *
 */
void MainWindow::on_actionSave_Configuration_File_As_triggered()
{
    QString filename = QFileDialog::getSaveFileName(
                this,
                tr("Save Solver Configuration File As"),
                     QDir(_projectData.getProjectPath()).filePath(TOOL4),
                tr("Configuration File name (*.cfg)") );

    QString _fileName = QFileInfo(filename).fileName();
    QString _fileExt = QFileInfo(filename).suffix();
    if (_fileExt.isEmpty())
        _fileName = _fileName +".cfg";
    QString _newFileConfigPath = QDir (QDir(_projectData.getProjectPath()).filePath(TOOL4)).filePath(_fileName);

    SolverVO _solver = _projectData.getSolverDataInformation();
    _solver.setSolverConfigFilePath(_newFileConfigPath);
    _projectData.setSolverDataInformation(_solver);

    if (_isMultizoneProject)
        _mManager.updateOpenEditConfigFile(_newFileConfigPath, &_multizoneProjectData,&_projectData, _isNewConfigFile);

   // Saving the Configuration File
   bool _savedFile = saveConfigFile();

   if (_savedFile)
   {       
        removeDefaultValuesReadFromConfigFile();
        setEnableSaveProjectIcons(_status_NeedToBeSaved);
        setEnabledSaveConfigIcons(_status_NeedToBeSaved);
        ui->savePhysicsButton->setEnabled(_status_NeedToBeSaved);
        enableSolverRunAction();
        if (!_isMultizoneProject)
            _inputDataTabHelper.fillFileNamesInTab(_projectData, &_userConfigValuesSolver);
   }
}
Exemplo n.º 2
0
void MainWindow::saveNewWorkspace()
{
    QDomDocument* config = generateWorkspaceXML();
    QStringList fileNames; //stores the entire path of the file that it attempts to open

    QStringList filters; //setting file filters
    filters << "ReViz configuration files (*.revizconfig)"
            << "Any files (*)";

    //initializing the File dialog box
    //the static QFileDialog does not seem to be working correctly in Ubuntu 12.04 with unity.
    //as per the documentation it may work correctly with gnome
    //the method used below should work correctly on all desktops and is supposedly more powerful
    QFileDialog dialog(this);
    dialog.setNameFilters(filters);
    dialog.setAcceptMode(QFileDialog::AcceptSave);
    dialog.setFileMode(QFileDialog::AnyFile);
    if (dialog.exec())
        fileNames = dialog.selectedFiles();

    if (!fileNames.isEmpty())
        saveConfigFile(config, &fileNames.front());
    else
        std::cerr << "No file was selected" << std::endl;
}
Exemplo n.º 3
0
// -----------------------------------------------------------------------------
// Application exit, shuts down and cleans everything up.
// If [save_config] is true, saves all configuration related files
// -----------------------------------------------------------------------------
void App::exit(bool save_config)
{
	exiting = true;

	if (save_config)
	{
		// Save configuration
		saveConfigFile();

		// Save text style configuration
		StyleSet::saveCurrent();

		// Save colour configuration
		MemChunk ccfg;
		ColourConfiguration::writeConfiguration(ccfg);
		ccfg.exportFile(App::path("colours.cfg", App::Dir::User));

		// Save game exes
		wxFile f;
		f.Open(App::path("executables.cfg", App::Dir::User), wxFile::write);
		f.Write(Executables::writeExecutables());
		f.Close();

		// Save custom special presets
		Game::saveCustomSpecialPresets();

		// Save custom scripts
		ScriptManager::saveUserScripts();
	}

	// Close all open archives
	archive_manager.closeAll();

	// Clean up
	EntryType::cleanupEntryTypes();
	Drawing::cleanupFonts();
	OpenGL::Texture::clearAll();

	// Clear temp folder
	std::error_code error;
	for (auto& item : std::filesystem::directory_iterator{ App::path("", App::Dir::Temp) })
	{
		if (!item.is_regular_file())
			continue;

		if (!std::filesystem::remove(item, error))
			Log::warning("Could not clean up temporary file \"{}\": {}", item.path().string(), error.message());
	}

	// Close lua
	Lua::close();

	// Close DUMB
	dumb_exit();

	// Exit wx Application
	wxGetApp().Exit();
}
Exemplo n.º 4
0
void MainWindow::saveWorkspace()
{
    if (!configFilePath->isNull()) {
        QDomDocument* config = generateWorkspaceXML();
        saveConfigFile(config, configFilePath);
    } else {
        saveNewWorkspace();
    }
}
Exemplo n.º 5
0
/**
 * @brief SOLVER: Main functionality to save the changes of the configuration file
 *
 */
void MainWindow::on_actionSave_Configuration_File_triggered()
{
    bool _savedFile = saveConfigFile();
    if (_savedFile)
    {
        enableSolverRunAction();
        setEnableSaveProjectIcons(_status_NeedToBeSaved);
        setEnabledSaveConfigIcons(_status_NeedToBeSaved);
        ui->savePhysicsButton->setEnabled(_status_NeedToBeSaved);
    }

}
Exemplo n.º 6
0
/* MainApp::OnExit
 * Application shutdown, run when program is closed
 *******************************************************************/
int MainApp::OnExit()
{
	exiting = true;

	// Save configuration
	saveConfigFile();

	// Save text style configuration
	StyleSet::saveCurrent();

	// Save colour configuration
	MemChunk ccfg;
	ColourConfiguration::writeConfiguration(ccfg);
	ccfg.exportFile(appPath("colours.cfg", DIR_USER));

	// Save game exes
	wxFile f;
	f.Open(appPath("executables.cfg", DIR_USER), wxFile::write);
	f.Write(Executables::writeExecutables());
	f.Close();

	// Close the map editor if it's open
	MapEditorWindow::deleteInstance();

	// Close all open archives
	theArchiveManager->closeAll();

	// Clean up
	EntryType::cleanupEntryTypes();
	ArchiveManager::deleteInstance();
	Console::deleteInstance();
	SplashWindow::deleteInstance();

	// Clear temp folder
	wxDir temp;
	temp.Open(appPath("", DIR_TEMP));
	string filename = wxEmptyString;
	bool files = temp.GetFirst(&filename, wxEmptyString, wxDIR_FILES);
	while (files)
	{
		if (!wxRemoveFile(appPath(filename, DIR_TEMP)))
			wxLogMessage("Warning: Could not clean up temporary file \"%s\"", filename);
		files = temp.GetNext(&filename);
	}

	// Close lua
	Lua::close();

	return 0;
}
Exemplo n.º 7
0
/* main start for Arnold CPC emulator for linux */
int main(int argc, char *argv[])
{
	configInit();	//FIXME: disabled for debug

	/* print welcome message */
	printf("Arnold Emulator (c) Kevin Thacker\n");
	printf("Linux Port maintained by Andreas Micklei\n");
	roms_init();
	//printrom();

	if (!CPCEmulation_CheckEndianness())
	{
		printf("%s", Messages[72]);
		exit(1);
	}

//	/* check display */
//	if (!XWindows_CheckDisplay())
//	{
//		printf("Failed to open display. Or display depth is  8-bit\n");
//		exit(-1);
//	}

	 /* initialise cpc hardware */
	CPC_Initialise();

	Multiface_Install();

	/* done before parsing command line args. Command line args
	will take priority */
	loadConfigFile(); //FIXME: disabled for debug

	init_main(argc, argv);

	CPC_Finish();

	Multiface_DeInstall();

	//printf("heello");

	saveConfigFile(); //FIXME: disabled for debug

	configFree(); //FIXME: disabled for debug

	exit(0);

	return 0;	/* Never reached */
}
Exemplo n.º 8
0
/*----------------------------------------------------------------------------------------
 * Purpose: This command will create a file with the current configuration of BGPmon.
 * Input: commandArgument - A linked list that provides all the parameters the users typed 
 * 		in. This list is in the same order as they were typed.
 * 	clientThreadArguments - A struct providing the basic address information for the 
 * 		current connection.
 * 	commandNode - A pointer to the current node in the command tree structure.
 * Output:  0 for success or 1 for failure
 * Kevin Burnett @ September 2, 2008   
 * -------------------------------------------------------------------------------------*/
int copyRunningConfig(commandArgument * ca, clientThreadArguments * client, commandNode * cn) {
	int results = 0;
	char * destination = NULL;
	char * backup = NULL;
    

	if(ca==NULL) {
                backup = LoginSettings.scratchDir;
		destination = LoginSettings.configFile;
		backupConfigFile(destination, backup);
	}
	else {
		destination = ca->commandArgument;
	}

	results = saveConfigFile(destination);
	if(results!=0) {
		sendMessage(client->socket, "failed to copy running config to [%s]\n", destination);
	}
	return results;
}
Exemplo n.º 9
0
configManager::~configManager()
{
	saveConfigFile();
}
Exemplo n.º 10
0
MainWindow::~MainWindow()
{
    saveConfigFile();

    delete uiMainWindow;
}
Exemplo n.º 11
0
QLayout *ZDLInterface::getButtonPane(){
	QHBoxLayout *box = new QHBoxLayout();

	QPushButton *btnExit = new QPushButton("Exit", this);
	btnZDL = new QPushButton("ZDL", this);
	QPushButton *btnMSet = new QPushButton("Multi Settings", this);
	btnEpr = new QPushButton(this);
	QPushButton *btnLaunch = new QPushButton("Launch", this);

	QMenu *context = new QMenu(btnZDL);
	QMenu *actions = new QMenu("Actions",context);

	QAction *showCommandline = actions->addAction("Show Command Line");
	QAction *clearAllPWadsAction = actions->addAction("Clear PWAD list");
	QAction *clearAllFieldsAction = actions->addAction("Clear all fields");
	clearAllFieldsAction->setShortcut(QKeySequence::New);
	QAction *clearEverythingAction = actions->addAction("Clear everything");
	actions->addSeparator();
#if !defined(NO_IMPORT)
	QAction *actImportCurrentConfig = actions->addAction("Import current config");
#endif
	QAction *clearCurrentGlobalConfig = actions->addAction("Clear current global config");
	clearCurrentGlobalConfig->setEnabled(false);	

	//QAction *newDMFlagger = actions->addAction("New DMFlag picker");

	context->addMenu(actions);
	context->addSeparator();
	QAction *loadZdlFileAction = context->addAction("Load .zdl");
	loadZdlFileAction->setShortcut(QKeySequence::Open);
	QAction *saveZdlFileAction = context->addAction("Save .zdl");
	saveZdlFileAction->setShortcut(QKeySequence::Save);
	context->addSeparator();
	QAction *loadAction = context->addAction("Load .ini");
	QAction *saveAction = context->addAction("Save .ini");
	context->addSeparator();
	QAction *aboutAction = context->addAction("About");
	aboutAction->setShortcut(QKeySequence::HelpContents);

	connect(loadAction, SIGNAL(triggered()), this, SLOT(loadConfigFile()));
	connect(saveAction, SIGNAL(triggered()), this, SLOT(saveConfigFile()));
	connect(loadZdlFileAction, SIGNAL(triggered()), this, SLOT(loadZdlFile()));
	connect(saveZdlFileAction, SIGNAL(triggered()), this, SLOT(saveZdlFile()));
	connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClick()));
#if !defined(NO_IMPORT)
	connect(actImportCurrentConfig, SIGNAL(triggered()), this, SLOT(importCurrentConfig()));
#endif

	connect(clearAllPWadsAction, SIGNAL(triggered()), this, SLOT(clearAllPWads()));
	connect(clearAllFieldsAction, SIGNAL(triggered()), this, SLOT(clearAllFields()));
	connect(clearEverythingAction, SIGNAL(triggered()), this, SLOT(clearEverything()));

	connect(showCommandline, SIGNAL(triggered()),this,SLOT(showCommandline()));
	//connect(newDMFlagger, SIGNAL(triggered()),this,SLOT(showNewDMFlagger()));
	connect(btnExit, SIGNAL(clicked()), this, SLOT(exitzdl()));

	btnZDL->setMenu(context);

	int minBtnWidth = 50;

	btnExit->setMinimumWidth(minBtnWidth-15);
	btnZDL->setMinimumWidth(minBtnWidth-15);
	btnMSet->setMinimumWidth(minBtnWidth+30);
	btnEpr->setMinimumWidth(20);
	btnLaunch->setMinimumWidth(minBtnWidth);

	connect(btnLaunch, SIGNAL( clicked() ), this, SLOT(launch()));

	setContentsMargins(0,0,0,0);
	layout()->setContentsMargins(0,0,0,0);
	box->setSpacing(2);
	box->addWidget(btnExit);
	box->addWidget(btnZDL);
	box->addWidget(btnMSet);
	box->addWidget(btnEpr);
	box->addWidget(btnLaunch);
	box->setSpacing(1);
	connect(btnEpr, SIGNAL(clicked()), this, SLOT(mclick()));

	connect(btnMSet, SIGNAL(clicked()), this, SLOT(ampclick()));
	return box;
}
Exemplo n.º 12
0
int 
main(int argc, char **argv)
{
	char	program_name[FILENAME_MAX_CHARS];
	char	config_file[FILENAME_MAX_CHARS];

	int	syslog;
	int	loglevel;
	int	logfacility;

	char	c;

 	int	recoveryport;
	int	error;
        int daemon_mode = 0;

 	// init program_name and default config file
	strncpy(program_name, argv[0], FILENAME_MAX_CHARS);
	strncpy(config_file, DEFAULT_CONFIGFILE, FILENAME_MAX_CHARS);

	// init default log settings
	syslog = DEFAULT_USE_SYSLOG;
	loglevel = DEFAULT_LOG_LEVEL;
 	logfacility = DEFAULT_LOG_FACILITY;

	// allow the user to set a special port for login recovery
 	recoveryport = 0;

	//save start time for uptime calculation in status messages
	bgpmon_start_time = time(NULL);

 	// parse command line
	while ((c = getopt (argc, argv, "dl:c:f:hsr:")) != -1) {
		switch (c) {
			case 'c':
				strncpy(config_file, optarg, FILENAME_MAX_CHARS);
				break;
        	 	case 'l':
        	 		loglevel = atoi(optarg);
        	 	   	break;
        	 	case 'f':
        	 		logfacility = atoi(optarg);
        	 	   	break;
        	 	case 's':
        	 	   	syslog = 1;
        	 	   	break;
        	 	case 'r':
        	 		recoveryport = atoi(optarg);
        	 	   	break;
 			case 'd':
				daemon_mode = 1;
                                break;
        	 	case 'h':
        	 	case '?':
        	 	default :
        	 		usage( argv[0] );
        	 	   	break;
 		}
	}

	
	// if optind is less than the number of arguments from the command line (argc), then there
	// is something in the argument string that isn't preceded by valid switch (-c, -l, etc)
	if(optind<argc) {
		usage(argv[0]);
	}

	// initilaze log module
	if (init_log (program_name, syslog, loglevel, logfacility) ) {
		fprintf (stderr, "Failed to initialize log functions!\n");
		exit(1);
	}
#ifdef DEBUG
   	debug (__FUNCTION__, "Successfully initialized log module.");
#endif
	log_msg("BGPmon starting up\n");
        /* Turn into daemon if daemon_mode is set. */
        if (daemon_mode){
          godaemon(RUN_DIR,PID_FILE);
        }
	

        char scratchdir[FILENAME_MAX_CHARS];
        sprintf(scratchdir,"%s/%s",RUN_DIR,"bgpmon");
	// initialize login interface
  	if (initLoginControlSettings(config_file, scratchdir, recoveryport) ) {
           	log_fatal("Unable to initialize login interface");
	};
#ifdef DEBUG
   	debug (__FUNCTION__, "Successfully initialized login module.");
#endif

	// initialize acl
	if(initACLSettings()) {
           	log_fatal("Unable to initialize ACL settings");
	};
#ifdef DEBUG
   	debug (__FUNCTION__, "Successfully initialized acl module.");
#endif

	// initialize the queue information
  	if (initQueueSettings() ) {
           	log_fatal("Unable to initialize queue settings");
	};
#ifdef DEBUG
   	debug (__FUNCTION__, "Successfully initialized queue settings.");
#endif

	// initialize clients control settings
  	if (initClientsControlSettings() ) {
		log_fatal("Unable to initialize client settings");
	};
#ifdef DEBUG
   	debug (__FUNCTION__, "Successfully initialized client settings.");
#endif

	// initialize clients control settings
	if (initMrtControlSettings() ) {
			log_fatal("Unable to initialize mrt settings");
		};
#ifdef DEBUG
	debug (__FUNCTION__, "Successfully initialized mrt settings.");
#endif

	//  initialize chains settings
  	if (initChainsSettings() ) {
		log_fatal("Unable to initialize chain settings");
	};

	// initialize the periodic settings
	if (initPeriodicSettings() ) {
			log_fatal("Unable to initialize periodic settings");
	};
#ifdef DEBUG
	debug (__FUNCTION__, "Successfully initialized periodic settings.");
#endif

	// read in the configuration file and change
	// all relevant settings based on config file
	if (readConfigFile(config_file) ) {
		// if the configuration file is not readable, remove the
		// configuration file and backup a copy
		backupConfigFile(LoginSettings.configFile, LoginSettings.scratchDir);
		saveConfigFile(LoginSettings.configFile);
		log_err("Corrupt Configuration File Moved to %s.  New configuration file written.", LoginSettings.scratchDir);  
	}


	/*
	 * Block signals in initial thread. New threads will
	 * inherit this signal mask. All the signals will be handled
	 * in a dedicated thread
	 */
	sigfillset ( &signalSet );
	pthread_sigmask ( SIG_BLOCK, &signalSet, NULL );

	// launch the signal handling thread
#ifdef DEBUG
	debug(__FUNCTION__, "Creating signal thread...");
#endif
	pthread_t sighandlerThreadID;
	if ((error = pthread_create(&sighandlerThreadID, NULL, sigHandler, config_file)) > 0 )
		log_fatal("Failed to create signal handler thread: %s\n", strerror(error));
#ifdef DEBUG
	debug(__FUNCTION__, "Created signal thread!");
#endif

	// create the system queues
#ifdef DEBUG
	debug(__FUNCTION__, "Creating queues...");
#endif
	/*create the peer queue*/
	peerQueue = createQueue(copyBMF, sizeOfBMF, PEER_QUEUE_NAME, strlen(PEER_QUEUE_NAME), FALSE);

	/*create the label queue*/		  
	labeledQueue = createQueue(copyBMF, sizeOfBMF, LABEL_QUEUE_NAME, strlen(LABEL_QUEUE_NAME), FALSE);

	/*create the xml queue*/
	xmlUQueue = createQueue(copyXML, sizeOfXML, XML_U_QUEUE_NAME, strlen(XML_U_QUEUE_NAME), TRUE);
	xmlRQueue = createQueue(copyXML, sizeOfXML, XML_R_QUEUE_NAME, strlen(XML_R_QUEUE_NAME), TRUE);	
#ifdef DEBUG
        debug(__FUNCTION__, "Created queues!");
#endif

	// launch the peering thread
#ifdef DEBUG
	debug(__FUNCTION__, "Creating peering thread...");
#endif	   
	launchAllPeers();
#ifdef DEBUG
	debug(__FUNCTION__, "Created peering thread!");
#endif

	// launch the labeling thread
#ifdef DEBUG
	debug(__FUNCTION__, "Creating labeling thread...");
#endif	   
	launchLabelingThread();
#ifdef DEBUG
	debug(__FUNCTION__, "Created labeling thread!");
#endif

	// launch the xml thread
#ifdef DEBUG
	debug(__FUNCTION__, "Creating xml thread...");
#endif	   
	launchXMLThread();
#ifdef DEBUG
	debug(__FUNCTION__, "Created xml thread!");
#endif


	// launch the clients control thread
#ifdef DEBUG
        debug(__FUNCTION__, "Creating clients control thread...");
#endif
	launchClientsControlThread();
#ifdef DEBUG
        debug(__FUNCTION__, "Created clients control thread!");
#endif

	// launch the mrt control thread
#ifdef DEBUG
	debug(__FUNCTION__, "Creating mrt control thread...");
#endif
	launchMrtControlThread();
#ifdef DEBUG
	debug(__FUNCTION__, "Created mrt control thread!");
#endif

        // launch the configured chains thread
#ifdef DEBUG
        debug(__FUNCTION__, "Creating threads for each configured chain...");
#endif	
	launchAllChainsThreads();
#ifdef DEBUG
        debug(__FUNCTION__, "Created threads for each configured chain!");
#endif

        // launch the login thread
#ifdef DEBUG
        debug(__FUNCTION__, "Creating login thread...");
#endif
	launchLoginControlThread();
#ifdef DEBUG
        debug(__FUNCTION__, "Created login thread!");
#endif

	// launch the periodic thread
#ifdef DEBUG
	debug(__FUNCTION__, "Creating periodic thread...");
#endif
	LaunchPeriodicThreads();
#ifdef DEBUG
	debug(__FUNCTION__, "Created periodic thread!");
#endif

	// write BGPMON_START message into the Peer Queue
	BMF bmf = createBMF(0, BMF_TYPE_BGPMON_START);
	QueueWriter qw = createQueueWriter(peerQueue);
	writeQueue(qw, bmf);
	destroyQueueWriter(qw);

	// periodically check on the state of each thread
	time_t threadtime;
	time_t currenttime;
	char currenttime_extended[64];
	memset(currenttime_extended, 0, 64);
	char threadtime_extended[64];
	memset(threadtime_extended, 0, 64);
	struct tm * current_tm = NULL;
	struct tm * thread_tm = NULL;
	int *chainIDs;
	long *clientIDs;
	long *mrtIDs;
	int clientcount, chaincount, mrtcount, i;
	while ( TRUE ) 
	{
		// get the current running time to compare the threads
		// last exection time to
		currenttime = time(NULL);
		sleep(THREAD_CHECK_INTERVAL);
		current_tm = localtime(&currenttime);
		strftime(currenttime_extended, sizeof(currenttime_extended), "%Y-%m-%dT%H:%M:%SZ", current_tm);

		// CLI MODULE
			// check the cli listener
			threadtime = getLoginControlLastAction();
			if (difftime(currenttime, threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("CLI Module is idle: current time = %s, last thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}

			// check the individual cli threads for updates
			int clicount = 0;
			long * cliIDs = NULL;
			clicount = getActiveCliIds(&cliIDs);
			if(clicount != -1)
			{
				for ( i=0; i<clicount; i++) 
				{
					threadtime = getCliLastAction(cliIDs[i]);
					if ( difftime(currenttime, threadtime) > THREAD_DEAD_INTERVAL) 
					{
						thread_tm = localtime(&threadtime);
						strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
						log_warning("Cli %d is idle: current time = %s, last cli %d thread time = %s", cliIDs[i], currenttime_extended, cliIDs[i], threadtime_extended);
					}
				}
				free(cliIDs);
			}

		// CLIENTS MODULE
			// Clients Module
			threadtime = getClientsControlLastAction();
			thread_tm = localtime(&threadtime);
			strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
			if (difftime(currenttime, threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("Clients Module is idle: current time = %s, last control thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}

			// UPDATE clients
			clientcount = getActiveClientsIDs(&clientIDs, CLIENT_LISTENER_UPDATA);
			if(clientcount != -1)
			{
				for (i = 0; i < clientcount; i++) 
				{
					threadtime = getClientLastAction(clientIDs[i], CLIENT_LISTENER_UPDATA);
					if (difftime(currenttime, threadtime) > THREAD_DEAD_INTERVAL) 
					{
						thread_tm = localtime(&threadtime);
						strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
						log_warning("Updates Client %d is idle: current time = %s, last client %d thread time = %s", clientIDs[i], currenttime_extended, clientIDs[i], threadtime_extended);
					}
				}
				free(clientIDs);
			}

			// RIB clients
			clientcount = getActiveClientsIDs(&clientIDs, CLIENT_LISTENER_RIB);
			if(clientcount != -1)
			{
				for (i = 0; i < clientcount; i++) 
				{
					threadtime = getClientLastAction(clientIDs[i], CLIENT_LISTENER_RIB);
					if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL) 
					{
						thread_tm = localtime(&threadtime);
						strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
						log_warning("RIB Client %d is idle: current time = %s, last client %d thread time = %s", clientIDs[i], currenttime_extended, clientIDs[i], threadtime_extended);
					}
				}
				free(clientIDs);
			}

		// PEER MODULE
			for (i=0; i < MAX_SESSION_IDS; i++)
			{
				if( Sessions[i] != NULL && getSessionState(Sessions[i]->sessionID) == stateEstablished)
				{
					threadtime = getSessionLastActionTime(i);
					if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL) 
					{
						thread_tm = localtime(&threadtime);
						strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
						log_warning("Peering session %d is idle: current time = %s, last client %d thread time = %s",Sessions[i]->sessionID,  currenttime_extended, Sessions[i]->sessionID, threadtime_extended);
						//closeBgpmon(config_file);
					}
					
				}
			}

		// LABELING MODULE
			threadtime = getLabelThreadLastActionTime();
			if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("Labeling module is idle: current time = %s, last control thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}		

		// XML MODULE
			threadtime = getXMLThreadLastAction();
			if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("XML module is idle: current time = %s, last control thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}				


		// QUAGGA MODULE
			// mrt listener
			threadtime = getMrtControlLastAction();
			if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("MRT module is idle: current time = %s, last control thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}

			// mrt connections
			mrtcount = getActiveMrtsIDs(&mrtIDs);
			if(mrtcount != -1)
			{
				for (i = 0; i < mrtcount; i++) 
				{
					threadtime = getMrtLastAction(mrtIDs[i]);
					if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL) 
					{
						thread_tm = localtime(&threadtime);
						strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
						log_warning("MRT client %d is idle: current time = %s, last client %d thread time = %s",mrtIDs[i], currenttime_extended, mrtIDs[i], threadtime_extended);
					}
				}
				free(mrtIDs);
			}

		// CHAIN MODULE
			chaincount = getActiveChainsIDs(&chainIDs);
			if(chaincount != -1)
			{
				for (i = 0; i < chaincount; i++) 
				{
					threadtime = getChainLastAction(chainIDs[i]);
					if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL) 
					{
						thread_tm = localtime(&threadtime);
						strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
						log_warning("BGPmon chain %ld is idle: current time = %s, last client %ld thread time = %s", chainIDs[i], currenttime_extended, chainIDs[i], threadtime_extended);
					}
				}
				free(chainIDs);
			}			

		// PERIODIC MODULE
			// route refresh 
			threadtime = getPeriodicRouteRefreshThreadLastActionTime();
			if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("Route Refresh module is idle: current time = %s, last control thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}		

			// status message
			threadtime = getPeriodicStatusMessageThreadLastActionTime();	
			if (difftime(currenttime,threadtime) > THREAD_DEAD_INTERVAL)
			{
				thread_tm = localtime(&threadtime);
				strftime(threadtime_extended, sizeof(threadtime_extended), "%Y-%m-%dT%H:%M:%SZ", thread_tm);
				log_warning("Status Messages module is idle: current time = %s, last control thread time = %s", currenttime_extended, threadtime_extended);
				//closeBgpmon(config_file);
			}

	}
	
	// should never get here
	log_err( "main: unexpectedly finished");

	return(0);
} 
Exemplo n.º 13
0
void SetUpStatus::saveConfig() {
    emit saveConfigFile();
    this->destroy();
}