static void processOption( int index, char * pOption )
{
    switch(index)
    {
        case 0: // Data path
            memset( spDataDir, 0, sizeof(spDataDir) );
            setDataDir( pOption );
            break;
        case 1: // Netflix path
            setValue( pOption, spNetflix );
            break;
        case 2: // Friendly name
            setValue( pOption, spFriendlyName );
            break;
        case 3: // Model Name
            setValue( pOption, spModelName );
            break;
        case 4: // UUID
            setValue( pOption, spUuid );
            break;
        default:
            // Should not get here
            fprintf( stderr, "Option %d not valid\n", index);
            exit(1);
    }
}
Exemple #2
0
bool
CSimplifiedChinesePolicy::onConfigChanged (const COptionEvent& event)
{
    if (event.name == SYSTEM_DATA_DIR) {
        setDataDir(event.get_string());
    } else if (event.name == USER_DATA_DIR) {
        setUserDataDir(event.get_string());
    } else if (event.name == CONFIG_GENERAL_CHARSET_LEVEL) {
        m_csLevel = event.get_int() & 3;
    }

    return false;
}
Exemple #3
0
int main(int argc, char* argv[])
{
    struct sigaction action;
    action.sa_handler = signalHandler;
    sigemptyset(&action.sa_mask);
    action.sa_flags = 0;
    sigaction(SIGTERM, &action, NULL);

    srand(time(NULL));
    int i;
    i = isAppRunning(spAppNetflix, NULL );
    printf("Netflix is %s\n", i ? "Running":"Not Running");
    i = isAppRunning( spAppYouTube, spAppYouTubeMatch );
    printf("YouTube is %s\n", i ? "Running":"Not Running");

    // set all defaults
    setValue(spDefaultFriendlyName, spFriendlyName );
    setValue(spDefaultModelName, spModelName );
    setValue(spDefaultUuid, spUuid );
    setValue(spDefaultNetflix, spNetflix );
    setDataDir(spDefaultData);

    // Process command line options
    // Loop through pairs of command line options.
    for( i = 1; i < argc; i+=2 )
    {
        int numberOfOptions = sizeof(gDialOptions) / sizeof(dial_options_t);
        while( --numberOfOptions >= 0 )
        {
            int shortLen, longLen;
            shortLen = strlen(gDialOptions[numberOfOptions].pOption);
            longLen = strlen(gDialOptions[numberOfOptions].pLongOption);
            if( ( ( strncmp( argv[i], gDialOptions[numberOfOptions].pOption, shortLen ) == 0 ) ||
                ( strncmp( argv[i], gDialOptions[numberOfOptions].pLongOption, longLen ) == 0 ) ) &&
                ( (i+1) < argc ) )
            {
                processOption( numberOfOptions, argv[i+1] );
                break;
            }
        }
        // if we don't find an option in our list, bail out.
        if( numberOfOptions < 0 )
        {
            printUsage();
            exit(1);
        }
    }
    runDial();

    return 0;
}
Exemple #4
0
void busy_blink(int nsec, int blinkHz, int pin)
{
	KIORegs io = getIORegs(pin);
	setDataDir(&io, OUTPUT);
	int value = 1;
	nsec *= 2;
	int msec = 500 * blinkHz;
	while (--nsec >= 0)
	{
		setIOValue(&io, value);
		value ^= 1;
		kdelay_ms(msec);
	}
	set_digital_output_value(&io, 0);
}
bool init(int argc, char *argv[]){

    setDataDir(argc, argv);
    initGLFW();
    ogle::initGLEW();
    bool found_extensions = checkExtensions();
    if (!found_extensions)
        return false;
    
    ogle::Debug::init();

    initGLSettings();

    createParticles();

    createBufferObject();

    return true;
}
Exemple #6
0
static void greenCallback(void* arg)
{
	static KIORegs* iop = 0;
	if (iop == 0)
	{
		static KIORegs ios;
		ios = getIORegs(GREEN_PIN);
		iop = &ios;
		setDataDir(iop, OUTPUT);
		setIOValue(iop, 0);
	}

	int value = 0;

	if (period[kGREEN] > 0)
		value = (int)(++counter[kGREEN] & 1);

	setIOValue(iop, value);
}
Exemple #7
0
static void processOption( int index, char * pOption )
{
    switch(index)
    {
    case 0: // Data path
        memset( spDataDir, 0, sizeof(spDataDir) );
        setDataDir( pOption );
        break;
    case 1: // Netflix path
        setValue( pOption, spNetflix );
        break;
    case 2: // Friendly name
        setValue( pOption, spFriendlyName );
        break;
    case 3: // Model Name
        setValue( pOption, spModelName );
        break;
    case 4: // UUID
        setValue( pOption, spUuid );
        break;
    case 5:
        if (strcmp(pOption, "on")==0){
            wakeOnWifiLan=true;
        }else if (strcmp(pOption, "off")==0){
            wakeOnWifiLan=false;
        }else{
            fprintf(stderr, "Option %s is not valid for %s",
                    pOption, WAKE_OPTION_LONG);
            exit(1);
        }
        break;
    default:
        // Should not get here
        fprintf( stderr, "Option %d not valid\n", index);
        exit(1);
    }
}
Exemple #8
0
static void yellowCallback(void* arg)
{
	static int state;
	static KIORegs* iop = 0;
	if (iop == 0)
	{
		static KIORegs ios;
		ios = getIORegs(YELLOW_PIN);
		iop = &ios;
		setDataDir(iop, OUTPUT);
		setIOValue(iop, 0);
	}

	int value = 0;

	if (period[kYELLOW] > 0)
	{
		value = ++state & 1;
		if (value == 0)
			++counter[kYELLOW];
	}

	setIOValue(iop, value);
}
Exemple #9
0
void redTask()
{
	static int state;
	static KIORegs* iop = 0;
	if (iop == 0)
	{
		static KIORegs ios;
		ios = getIORegs(RED_PIN);
		iop = &ios;
		setDataDir(iop, OUTPUT);
		setIOValue(iop, 0);
	}

	int value = 0;

	if (period[kRED] > 0)
	{
		value = ++state & 1;
		if (value == 0)
			++counter[kRED];
	}

	setIOValue(iop, value);
}
OptionDialog::OptionDialog(QWidget* parent)
{
   int i;

   // I need a lot of control over what is displayed on the DbConfig dialog.
   // Maybe designer can do it? No idea. So I did this hybrid model, and I
   // think it will end up biting my ...
   // anyway. It isn't pretty
   setupUi(this);
   createPostgresElements();
   createSQLiteElements();

   if( parent != 0 )
   {
      setWindowIcon(parent->windowIcon());
   }

   ndxToLangCode <<
      "ca" <<
      "cs" <<
      "da" <<
      "de" <<
      "el" <<
      "en" <<
      "es" <<
      "et" <<
      "eu" <<
      "fr" <<
      "gl" <<
      "hu" <<
      "it" <<
      "lv" <<
      "nb" <<
      "nl" <<
      "pl" <<
      "pt" <<
      "ru" <<
      "sr" <<
      "sv" <<
      "tr" <<
      "zh";

   // Do this just to have model indices to set icons.
   comboBox_lang->addItems(ndxToLangCode);
   // MUST correspond to ndxToLangCode.
   langIcons <<
      /*ca*/ QIcon(":images/flagCatalonia.svg") <<
      /*cs*/ QIcon(":images/flagCzech.svg") <<
      /*da*/ QIcon() <<
      /*de*/ QIcon(":images/flagGermany.svg") <<
      /*el*/ QIcon(":images/flagGreece.svg") <<
      /*en*/ QIcon(":images/flagUK.svg") <<
      /*es*/ QIcon(":images/flagSpain.svg") <<
      /*et*/ QIcon() <<
      /*eu*/ QIcon() <<
      /*fr*/ QIcon(":images/flagFrance.svg") <<
      /*gl*/ QIcon() <<
      /*hu*/ QIcon() <<
      /*it*/ QIcon(":images/flagItaly.svg") <<
      /*lv*/ QIcon() <<
      /*nb*/ QIcon() <<
      /*nl*/ QIcon(":images/flagNetherlands.svg") <<
      /*pl*/ QIcon(":images/flagPoland.svg") <<
      /*pt*/ QIcon(":images/flagBrazil.svg") <<
      /*ru*/ QIcon(":images/flagRussia.svg") <<
      /*sr*/ QIcon() <<
      /*sv*/ QIcon() <<
      /*tr*/ QIcon() <<
      /*zh*/ QIcon(":images/flagChina.svg");
   // Set icons.
   for( i = 0; i < langIcons.size(); ++i )
      comboBox_lang->setItemIcon(i, langIcons[i]);

   // Call this here to set up translatable strings.
   retranslate();

   // Populate combo boxes on the "Units" tab
   weightComboBox->addItem(tr("SI units"), QVariant(SI));
   weightComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   weightComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   temperatureComboBox->addItem(tr("Celsius"), QVariant(Celsius));
   temperatureComboBox->addItem(tr("Fahrenheit"), QVariant(Fahrenheit));

   volumeComboBox->addItem(tr("SI units"), QVariant(SI));
   volumeComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   volumeComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   gravityComboBox->addItem(tr("20C/20C Specific Gravity"), QVariant(Brewtarget::SG));
   gravityComboBox->addItem(tr("Plato/Brix/Balling"), QVariant(Brewtarget::PLATO));

   dateComboBox->addItem(tr("mm-dd-YYYY"), QVariant(Unit::displayUS));
   dateComboBox->addItem(tr("dd-mm-YYYY"), QVariant(Unit::displayImp));
   dateComboBox->addItem(tr("YYYY-mm-dd"), QVariant(Unit::displaySI));

   colorComboBox->addItem(tr("SRM"), QVariant(Brewtarget::SRM));
   colorComboBox->addItem(tr("EBC"), QVariant(Brewtarget::EBC));

   // Populate combo boxes on the "Formulas" tab
   ibuFormulaComboBox->addItem(tr("Tinseth's approximation"), QVariant(Brewtarget::TINSETH));
   ibuFormulaComboBox->addItem(tr("Rager's approximation"), QVariant(Brewtarget::RAGER));
   ibuFormulaComboBox->addItem(tr("Noonan's approximation"), QVariant(Brewtarget::NOONAN));

   colorFormulaComboBox->addItem(tr("Mosher's approximation"), QVariant(Brewtarget::MOSHER));
   colorFormulaComboBox->addItem(tr("Daniel's approximation"), QVariant(Brewtarget::DANIEL));
   colorFormulaComboBox->addItem(tr("Morey's approximation"), QVariant(Brewtarget::MOREY));

   connect( buttonBox, SIGNAL( accepted() ), this, SLOT( saveAndClose() ) );
   connect( buttonBox, SIGNAL( rejected() ), this, SLOT( cancel() ) );

   // database panel stuff
   comboBox_engine->addItem( tr("SQLite (default)"), QVariant(Brewtarget::SQLITE));
   comboBox_engine->addItem( tr("PostgreSQL"), QVariant(Brewtarget::PGSQL));
   connect( comboBox_engine, SIGNAL( currentIndexChanged(int) ), this, SLOT( setEngine(int) ) );
   connect( pushButton_testConnection, SIGNAL( clicked() ), this, SLOT(testConnection()));

   // figure out which database we have
   setDbDialog((Brewtarget::DBTypes)Brewtarget::option("dbType", Brewtarget::SQLITE).toInt());

   // Set the signals
   connect( checkBox_savePassword, SIGNAL(clicked(bool)), this, SLOT(savePassword(bool)));

   connect( btStringEdit_hostname, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_portnum, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_schema, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_dbname, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_username, SIGNAL( textModified() ), this, SLOT(testRequired()));
   connect( btStringEdit_password, SIGNAL( textModified() ), this, SLOT(testRequired()));

   connect( pushButton_browseDataDir, SIGNAL( clicked() ), this, SLOT( setDataDir() ) );
   connect( pushButton_browseBackupDir, SIGNAL( clicked() ), this, SLOT( setBackupDir() ) );
   connect( pushButton_resetToDefault, SIGNAL( clicked() ), this, SLOT( resetToDefault() ) );
   pushButton_testConnection->setEnabled(false);

}
Exemple #11
0
OptionDialog::OptionDialog(QWidget* parent)
{
   int i;
   setupUi(this);

   if( parent != 0 )
   {
      setWindowIcon(parent->windowIcon());
   }

   ndxToLangCode <<
      "ca" <<
      "cs" <<
      "da" <<
      "de" <<
      "el" <<
      "en" <<
      "es" <<
      "et" <<
      "eu" <<
      "fr" <<
      "gl" <<
      "hu" <<
      "it" <<
      "lv" <<
      "nb" <<
      "nl" <<
      "pl" <<
      "pt" <<
      "ru" <<
      "sr" <<
      "sv" <<
      "tr" <<
      "zh";

   // Do this just to have model indices to set icons.
   comboBox_lang->addItems(ndxToLangCode);
   // MUST correspond to ndxToLangCode.
   langIcons <<
      /*ca*/ QIcon(":images/flagCatalonia.svg") <<
      /*cs*/ QIcon(":images/flagCzech.svg") <<
      /*da*/ QIcon() <<
      /*de*/ QIcon(":images/flagGermany.svg") <<
      /*el*/ QIcon(":images/flagGreece.svg") <<
      /*en*/ QIcon(":images/flagUK.svg") <<
      /*es*/ QIcon(":images/flagSpain.svg") <<
      /*et*/ QIcon() <<
      /*eu*/ QIcon() <<
      /*fr*/ QIcon(":images/flagFrance.svg") <<
      /*gl*/ QIcon() <<
      /*hu*/ QIcon() <<
      /*it*/ QIcon(":images/flagItaly.svg") <<
      /*lv*/ QIcon() <<
      /*nb*/ QIcon() <<
      /*nl*/ QIcon(":images/flagNetherlands.svg") <<
      /*pl*/ QIcon(":images/flagPoland.svg") <<
      /*pt*/ QIcon(":images/flagBrazil.svg") <<
      /*ru*/ QIcon(":images/flagRussia.svg") <<
      /*sr*/ QIcon() <<
      /*sv*/ QIcon() <<
      /*tr*/ QIcon() <<
      /*zh*/ QIcon(":images/flagChina.svg");
   // Set icons.
   for( i = 0; i < langIcons.size(); ++i )
      comboBox_lang->setItemIcon(i, langIcons[i]);

   // Call this here to set up translatable strings.
   retranslate();

   // Populate combo boxes on the "Units" tab
   weightComboBox->addItem(tr("SI units"), QVariant(SI));
   weightComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   weightComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   temperatureComboBox->addItem(tr("Celsius"), QVariant(Celsius));
   temperatureComboBox->addItem(tr("Fahrenheit"), QVariant(Fahrenheit));

   volumeComboBox->addItem(tr("SI units"), QVariant(SI));
   volumeComboBox->addItem(tr("US traditional units"), QVariant(USCustomary));
   volumeComboBox->addItem(tr("British imperial units"), QVariant(Imperial));

   gravityComboBox->addItem(tr("20C/20C Specific Gravity"), QVariant(Brewtarget::SG));
   gravityComboBox->addItem(tr("Plato/Brix/Balling"), QVariant(Brewtarget::PLATO));

   dateComboBox->addItem(tr("mm-dd-YYYY"), QVariant(Unit::displayUS));
   dateComboBox->addItem(tr("dd-mm-YYYY"), QVariant(Unit::displayImp));
   dateComboBox->addItem(tr("YYYY-mm-dd"), QVariant(Unit::displaySI));

   colorComboBox->addItem(tr("SRM"), QVariant(Brewtarget::SRM));
   colorComboBox->addItem(tr("EBC"), QVariant(Brewtarget::EBC));

   // Populate combo boxes on the "Formulas" tab
   ibuFormulaComboBox->addItem(tr("Tinseth's approximation"), QVariant(Brewtarget::TINSETH));
   ibuFormulaComboBox->addItem(tr("Rager's approximation"), QVariant(Brewtarget::RAGER));
   ibuFormulaComboBox->addItem(tr("Noonan's approximation"), QVariant(Brewtarget::NOONAN));

   colorFormulaComboBox->addItem(tr("Mosher's approximation"), QVariant(Brewtarget::MOSHER));
   colorFormulaComboBox->addItem(tr("Daniel's approximation"), QVariant(Brewtarget::DANIEL));
   colorFormulaComboBox->addItem(tr("Morey's approximation"), QVariant(Brewtarget::MOREY));

   connect( buttonBox, SIGNAL( accepted() ), this, SLOT( saveAndClose() ) );
   connect( buttonBox, SIGNAL( rejected() ), this, SLOT( cancel() ) );
   connect( pushButton_dbDirBrowse, SIGNAL( clicked() ), this, SLOT( setDataDir() ) );
   connect( pushButton_dbDirDefault, SIGNAL( clicked() ), this, SLOT( defaultDataDir() ) );

}