#include "ovasCAcquisitionServerGUI.h" #include #include #include #include #if defined(TARGET_OS_Windows) #include #include #endif using namespace OpenViBE; using namespace OpenViBE::Kernel; using namespace std; typedef struct _SConfiguration { _SConfiguration(void) { } // std::map < std::string, std::string > m_oFlag; std::map < std::string, std::string > m_oTokenMap; } SConfiguration; boolean parse_arguments(int argc, char** argv, SConfiguration& rConfiguration) { SConfiguration l_oConfiguration; int i; std::vector < std::string > l_vArgValue; std::vector < std::string >::const_iterator it; for(i=1; icreateKernel("acquisition-server", l_sConfigFile); if(!l_pKernelContext) { cout<<"[ FAILED ] No kernel created by kernel descriptor"<initialize(); IConfigurationManager& l_rConfigurationManager=l_pKernelContext->getConfigurationManager(); // @FIXME CERT silent fail if missing file is provided l_rConfigurationManager.addConfigurationFromFile(l_rConfigurationManager.expand("${Path_Data}/applications/acquisition-server/acquisition-server-defaults.conf")); // User configuration mods l_rConfigurationManager.addConfigurationFromFile(l_rConfigurationManager.expand("${Path_UserData}/openvibe-acquisition-server.conf")); l_pKernelContext->getPluginManager().addPluginsFromFiles(l_rConfigurationManager.expand("${AcquisitionServer_Plugins}")); std::map::const_iterator itr; for(itr=l_oConfiguration.m_oTokenMap.begin(); itr!=l_oConfiguration.m_oTokenMap.end(); itr++) { l_pKernelContext->getLogManager() << LogLevel_Trace << "Adding command line configuration token [" << (*itr).first.c_str() << " = " << (*itr).second.c_str() << "]\n"; l_rConfigurationManager.addOrReplaceConfigurationToken((*itr).first.c_str(), (*itr).second.c_str()); } if(!gtk_init_check(&argc, &argv)) { l_pKernelContext->getLogManager() << LogLevel_Error << "Unable to initialize GTK. Possibly the display could not be opened. Exiting.\n"; OpenViBEToolkit::uninitialize(*l_pKernelContext); l_pKernelDesc->releaseKernel(l_pKernelContext); l_oKernelLoader.uninitialize(); l_oKernelLoader.unload(); #if defined(TARGET_OS_Windows) timeEndPeriod(1); #endif return -2; } // gtk_rc_parse(OpenViBE::Directories::getDataDir() + "/applications/designer/interface.gtkrc"); #ifdef TARGET_OS_Linux // Replace the gtk signal handlers with the default ones. As a result, // the following exits on terminating signals won't be graceful, // but its better than not exiting at all (gtk default on Linux apparently) signal(SIGHUP, SIG_DFL); signal(SIGINT, SIG_DFL); signal(SIGQUIT, SIG_DFL); #endif #if 0 // This is not needed in the acquisition server if(l_rConfigurationManager.expandAsBoolean("${Kernel_3DVisualisationEnabled}")) { l_pKernelContext->getVisualisationManager().initialize3DContext(); } #endif { // If this is encapsulated by gdk_threads_enter() and gdk_threads_exit(), m_pThread->join() can hang when gtk_main() returns before destructor of app has been called. OpenViBEAcquisitionServer::CAcquisitionServerGUI app(*l_pKernelContext); try { gtk_main(); } catch(...) { l_pKernelContext->getLogManager() << LogLevel_Fatal << "Catched top level exception\n"; } } cout<<"[ INF ] Application terminated, releasing allocated objects"<releaseKernel(l_pKernelContext); } } l_oKernelLoader.uninitialize(); l_oKernelLoader.unload(); } #if defined(TARGET_OS_Windows) timeEndPeriod(1); #endif return 0; }