Пример #1
0
QXNConfig::QXNConfig(QObject* parent)
  : QObject(parent)
{
  // Initialize an object
  xnconfig = xneur_config_init();
  if (!xnconfig)
    qFatal("%s", qPrintable(tr("Error initializing xnconfig.")));

  // and load data
  load();

  // FIXME: temporary console logging
  /*
  for (int i=0; i<xnconfig->total_languages; i++)
  {
    qDebug("%s", qPrintable(QString("Group: %1, Name: %2")
                            .arg(xnconfig->get_lang_group(xnconfig, i))
                            .arg(xnconfig->get_lang_name(xnconfig, i))));
  }
  qDebug("%s", qPrintable(QString("Default group: %1 (%2 total)")
                          .arg(xnconfig->default_group)
                          .arg(xnconfig->total_languages)));
  */
}
Пример #2
0
int main(int argc, char *argv[])
{
	xneur_reklama();

	// Parse command line options
	xneur_get_options(argc, argv); 

	// Init configuration
	xconfig = xneur_config_init();
	if (xconfig == NULL)
	{
		log_message(ERROR, "Can't init libxnconfig");
		return EXIT_FAILURE;
	}

	// Set lock pid
	xneur_set_lock();

	log_message(LOG, "Loading configuration");

	// Load configuration
	enum _error error_code = xconfig->load(xconfig);
	if (error_code != ERROR_SUCCESS)
	{
		log_message(ERROR, format_error_message(error_code));
		xconfig->uninit(xconfig);
		exit(EXIT_FAILURE);
	}

	log_set_level(xconfig->log_level);
	log_message(LOG, "Log level is set to %d", xconfig->log_level);

	log_message(LOG, "Total detected %d languages", xconfig->total_languages);

	int lang;
	for (lang = 0; lang < xconfig->total_languages; lang++)
	{
		char *lang_name = xconfig->get_lang_name(xconfig, lang);

		log_message(DEBUG, "%s dictionary has %d records", lang_name, xconfig->languages[lang].dicts->data_count);
		log_message(DEBUG, "%s proto has %d records", lang_name, xconfig->languages[lang].protos->data_count);
		log_message(DEBUG, "%s big proto has %d records", lang_name, xconfig->languages[lang].big_protos->data_count);
	}

	log_message(DEBUG, "Configuration load complete");

	// Init program structures
	struct _xprogram *xprogram = xprogram_init();
	if (xprogram == NULL)
	{
		log_message(ERROR, "Failed to init program structure");
		xconfig->uninit(xconfig);
		exit(EXIT_FAILURE);
	}

	log_message(DEBUG, "Init program structure complete");

	char *current_mode = "auto";
	if (xconfig->get_current_mode(xconfig) == MANUAL_MODE)
		current_mode = "manual";
	log_message(LOG, "Current mode set to %s", current_mode);
	
	current_mode = "Yes";
	if (xconfig->mouse_processing_mode == MOUSE_GRAB_DISABLE)
		current_mode = "No";
	log_message(LOG, "Mouse processing mode set to %s", current_mode);
	
	current_mode = "Yes";
	if (xconfig->education_mode == EDUCATION_MODE_DISABLE)
		current_mode = "No";
	log_message(LOG, "Education mode set to %s", current_mode);

	xntrap(SIGTERM, xneur_signal);
	xntrap(SIGINT, xneur_signal);

	xprogram->process_input(xprogram);

	xprogram->uninit(xprogram);
	log_message(DEBUG, "Current program info is freed");

	xconfig->uninit(xconfig);
	log_message(DEBUG, "Current configuration data is freed");

	return EXIT_SUCCESS;
}