Exemplo n.º 1
0
EnCryptDialog::EnCryptDialog(QWidget *parent) :
    QDialog(parent)
{

    wasOkPressed = false;
    setWindowTitle(tr("Encrypt Text"));
    //setWindowIcon(new QIcon(iconPath+"password.png"));
    QGridLayout *grid = new QGridLayout(this);
    QGridLayout *input = new QGridLayout(this);
    QGridLayout *msgGrid = new QGridLayout(this);
    QGridLayout *button = new QGridLayout(this);
    setLayout(grid);


    hint.setText("");
    password.setText("");
    password.setEchoMode(QLineEdit::Password);
    password2.setText("");
    password2.setEchoMode(QLineEdit::Password);


    input->addWidget(new QLabel(tr("Password"), this), 1,1);
    input->addWidget(&password, 1, 2);
    input->addWidget(new QLabel(tr("Verify"), this), 2,1);
    input->addWidget(&password2, 2, 2);
    input->addWidget(new QLabel(tr("Hint"), this), 3,1);
    input->addWidget(&hint, 3, 2);
    input->addWidget(new QLabel(tr("Remember Password")), 4,1);
    input->addWidget(&rememberPassword, 4,2);
    input->setContentsMargins(10, 10,  -10, -10);
    grid->addLayout(input, 1,1);

    msgGrid->addWidget(&error, 1, 1);
    grid->addLayout(msgGrid, 2, 1);

    ok.setText(tr("OK"));
    connect(&ok, SIGNAL(clicked()), this, SLOT(okButtonPressed()));
    ok.setEnabled(false);

    QPushButton *cancel = new QPushButton(tr("Cancel"), this);
    connect(cancel, SIGNAL(clicked()), this, SLOT(cancelButtonPressed()));
    button->addWidget(&ok, 1, 1);
    button->addWidget(cancel, 1,2);
    grid->addLayout(button, 3, 1);

    connect(&password, SIGNAL(textChanged(QString)), this, SLOT(validateInput()));
    connect(&password2, SIGNAL(textChanged(QString)), this, SLOT(validateInput()));
    connect(&hint, SIGNAL(textChanged(QString)), this, SLOT(validateInput()));
    this->setFont(global.getGuiFont(font()));

}
Exemplo n.º 2
0
int main()
{
	FILE *f = openLog("unitTestLog.txt");
	cunit_init();	// Initiate CUnit
	Roots root;
	Terms terms;

	// First unit test, should
	//terms.a = "1", terms.b = "2", terms.c = "1";
	terms = validateInput("1", "2", "1");
	if (terms.input == 1)
	{
		root = eqnControl(terms.a, terms.b, terms.c);
		
		//fwrite(assert_neq("x1", root.x1, -2.0), f);
		assert_neq("x1", root.x1, -2.0);
		fprintf(f, "x1: %f assert not equal %f\n", (double)root.x1, -2.0);
		assert_neq("x2", root.x2, -2.0);
		fprintf(f, "x2: %f assert not equal %f\n", (double)root.x2, -2.0);
	}

	printf("-------------------------------\n");

	//terms.a = "2"; terms.b = "5"; terms.c = "-3";
	terms = validateInput("2", "5", "-3");
	if (terms.input == 1)
	{
		root = eqnControl(terms.a, terms.b, terms.c);
		assert_eq("x1", root.x1, 0.5);
		fprintf(f, "x1: %f assert equal %f\n", (double)root.x1, 0.5);
		assert_eq("x2", root.x2, -3.0);
		fprintf(f, "x2: %f assert equal %f\n", (double)root.x2, -3.0);
	}	

	printf("-------------------------------\n");
	//char terms.a, terms.b, terms.c;
	//terms.a = "a"; terms.b = "b"; terms.c = "c";
	terms = validateInput("a", "b", "c");
	if (terms.input == 1)
	{
		root = eqnControl(terms.a, terms.b, terms.c);
		assert_eq("x1", root.x1, 0.5);
		fprintf(f, "x1: %f assert equal %f\n", (double)root.x1, 0.5);
		assert_eq("x2", root.x2, -3.0);
		fprintf(f, "x2: %f assert equal %f\n", (double)root.x2, -3.0);
	}
	fclose(f);
}
Exemplo n.º 3
0
/*
 * buttonDoneClick
 */
void guiMessage::buttonDoneClick(wxCommandEvent& event) {
    int            index = comboUsers->GetSelection();
    messageDetails message;
    stringstream    Message;

    if(_messageLoaded) {
        if( _message && _cleanup) {
            delete _message;
            _message = 0;
        }

        Destroy();
        return;
    }

    if( index == wxNOT_FOUND )
        return;

    message._data		= (const char*) messageText->GetValue().mb_str(wxConvUTF8);
    message._receiverID = *((size_t*) comboUsers->GetClientData(index));
    
    if( !validateInput( message ) )
        return;

	if(_mainApp->serverGet()) {
		moduleMessages *modMessages = _mainApp->serverGet()->moduleGet< moduleMessages >( modMESSAGES );

		if(modMessages)
			modMessages->messageSend( message );
	}

    Destroy();
}
Exemplo n.º 4
0
void inputSize (US *size) {
    do {
	system("clear");
	intro();
	printf("What size is the suduku?? ");
    } while (validateInput(size,100) == false);   
}
Exemplo n.º 5
0
///@brief Adds book described in the form.
void AddBook::save()
{
	if(!validateInput())
		return;
	Book b;
	b.setIsbn(isbnLineEdit->text().toStdString().c_str());
	b.setTitle(titleLineEdit->text());
	b.setEdition(editionLineEdit->text().toInt());
	b.setCritique(critiqueLineEdit->text());
	b.setDescription(descriptionLineEdit->text());
	b.setRating(ratingWidget->getRating());
	b.setCover(coverLineEdit->text());
	b.setEbook(ebookLineEdit->text());
	b.setPubDate(pubDateEdit->date());
	b.setUDC(udcLineEdit->text());

	b.setThemes(getSelectedThemes());
	b.setPublishers(getSelectedPublishers());
	b.setAuthors(getSelectedAuthors());
	b.setTranslator(getSelectedTranslator());

	try
	{
		c->insertBook(b);
	}
	catch(DataBaseException dbe)
	{
		MessageBoxDataBaseException q(&dbe, this);
		q.appendText(tr("The book has not been added."));
		q.exec();
	}
	emit closeRequested();
}
Exemplo n.º 6
0
ActionCreator::ActionCreator(QWidget *parent) : QDialog(parent)
{
    m_layout = new QVBoxLayout(this);

    // Action Type
    m_cActionType = new QComboBox(this);
    m_cActionType->addItem("Send click(s)");
    m_cActionType->addItem("Send keypress");
    m_cActionType->addItem("Send serial data");
    m_cActionType->addItem("Multiple actions");
    m_layout->addWidget(m_cActionType);

    // Activator
    m_eActivator = new QLineEdit(this);
    m_eActivator->setPlaceholderText("Enter activator...");
    m_layout->addWidget(m_eActivator);

    // Validation
    m_buttonBox = new QDialogButtonBox(this);
    m_buttonBox->addButton("Create", QDialogButtonBox::AcceptRole);
    m_buttonBox->addButton("Cancel", QDialogButtonBox::RejectRole);
    m_layout->addWidget(m_buttonBox);

    this->setLayout(m_layout);

    connect(m_buttonBox, SIGNAL(accepted()), SLOT(validateInput()));
    connect(m_buttonBox, SIGNAL(rejected()), SLOT(reject()));
}
void EditIpAccessRuleDialog::onOkButtonClick()
{
  if (!validateInput()) {
    return ;
  }
  if (m_data != NULL) {
    if (m_access[0].isChecked()) {
      m_data->setAction(IpAccessRule::ACTION_TYPE_ALLOW);
    } else if (m_access[1].isChecked()) {
      m_data->setAction(IpAccessRule::ACTION_TYPE_DENY);
    } else if (m_access[2].isChecked()) {
      m_data->setAction(IpAccessRule::ACTION_TYPE_QUERY);
    }

    StringStorage firstIp;
    StringStorage lastIp;

    m_firstIp.getText(&firstIp);
    m_lastIp.getText(&lastIp);

    m_data->setFirstIp(firstIp.getString());
    m_data->setLastIp(lastIp.getString());

  } // if
  kill(IDOK);
}
Exemplo n.º 8
0
void ofxLSystem::build(){
    //check if axiom, rules and theta are ok,
    // if not, define some default
    try {
        validateInput(axiom, rulesContainer, theta);
    } catch (ofxLSInputError& e) {
        ofLogError(e.what());
        theta = 25.00;
        axiom = "F";
        rulesContainer = {"F -> F[+F][-F]"};
    }
    //clear the mesh
    mesh.clear();

    // setup the turtle, the sentences and the geometry
    setMeshMode(geometry);
    turtle.setup(stepLength, stepWidth, theta, geometry, randomYRotation, scaleWidth, resolution, textureRepeat);
    const vector<string> sentences =
        ofxLSystemGrammar::buildSentences(rulesContainer, depth, axiom, constants);

    // populate the mesh
    turtle.generate(mesh, sentences.back(), depth);
    getMesh().clear();
    getMesh().append(mesh);
    setBoundingBox(turtle.getBuildedBoundingBox());
    getMesh().enableNormals();
}
QgsGeometryCheckerSetupTab::QgsGeometryCheckerSetupTab( QgisInterface* iface , QWidget *parent )
    : QWidget( parent ), mIface( iface )

{
  ui.setupUi( this );
  ui.progressBar->hide();
  ui.labelStatus->hide();
  ui.comboBoxInputLayer->setFilters( QgsMapLayerProxyModel::HasGeometry );
  mRunButton = ui.buttonBox->addButton( tr( "Run" ), QDialogButtonBox::ActionRole );
  mAbortButton = new QPushButton( tr( "Abort" ) );
  mRunButton->setEnabled( false );

  connect( mRunButton, SIGNAL( clicked() ), this, SLOT( runChecks() ) );
  connect( ui.comboBoxInputLayer, SIGNAL( currentIndexChanged( int ) ), this, SLOT( validateInput() ) );
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layersAdded( QList<QgsMapLayer*> ) ), this, SLOT( updateLayers() ) );
  connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( updateLayers() ) );
  connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.lineEditOutput, SLOT( setEnabled( bool ) ) );
  connect( ui.radioButtonOutputNew, SIGNAL( toggled( bool ) ), ui.pushButtonOutputBrowse, SLOT( setEnabled( bool ) ) );
  connect( ui.buttonGroupOutput, SIGNAL( buttonClicked( int ) ), this, SLOT( validateInput() ) );
  connect( ui.pushButtonOutputBrowse, SIGNAL( clicked() ), this, SLOT( selectOutputFile() ) );
  connect( ui.lineEditOutput, SIGNAL( textChanged( QString ) ), this, SLOT( validateInput() ) );
  connect( ui.checkBoxSliverPolygons, SIGNAL( toggled( bool ) ), ui.widgetSliverThreshold, SLOT( setEnabled( bool ) ) );
  connect( ui.checkBoxSliverArea, SIGNAL( toggled( bool ) ), ui.doubleSpinBoxSliverArea, SLOT( setEnabled( bool ) ) );

  updateLayers();

  Q_FOREACH ( const QgsGeometryCheckFactory* factory, QgsGeometryCheckFactoryRegistry::getCheckFactories() )
  {
    factory->restorePrevious( ui );
  }
Exemplo n.º 10
0
void mainUI::on_tool_BEcp_clicked(){
 int index = getSelectedBE();
  if(index != -1){
    if(ui->tree_BE->topLevelItem(index)->text(1).toLower() == "yes"){
      QMessageBox::warning(this,tr("Running Boot Environment"),tr("You cannot make a copy of the currently running boot environment!") );
      return;
    }
    bool updateGRUB=false;
    if( ui->tree_BE->topLevelItemCount() == 1){updateGRUB=true;} //moving from 1 to 2
    QString name = ui->tree_BE->topLevelItem(index)->text(0);
    //Get the new name from the user
    bool ok;
    QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a name for the new boot environment"), QLineEdit::Normal, name, &ok,0, Qt::ImhDigitsOnly | Qt::ImhUppercaseOnly | Qt::ImhLowercaseOnly); 
    if(ok && !newname.isEmpty()){
      if( !validateInput(newname) ){
        on_tool_BEcp_clicked(); //try again
        return;
      }
      if( checkName(newname) ){
	if(updateGRUB && !G_showMenu){ 
	  G_showMenu=true; 
	  saveGRUBdefaults(G_themeFile, G_fontFile, G_timer, G_showMenu, G_defaultBE);  
        }
        beadmCopy(name,newname);
        updateBEList();
	updateGRUBdefaults(true);
      }
    }
  }	
}
Exemplo n.º 11
0
void mainUI::on_tool_BEmv_clicked(){
  int index = getSelectedBE();
  if(index != -1){
    /*if(ui->tree_BE->topLevelItem(index)->text(0).toLower() == "default"){
      QMessageBox::warning(this,tr("Base Boot Environment"), tr("You cannot rename the base environment that all other BE's need to function!") );
      return;
    }*/
    if(ui->tree_BE->topLevelItem(index)->text(1).toLower() == "yes"){
      QMessageBox::warning(this,tr("Running Boot Environment"), tr("You cannot rename a boot environment that you are currently running!") );
      return;
    }
    if(ui->tree_BE->topLevelItem(index)->text(2).toLower() == "yes"){
      QMessageBox::warning(this,tr("Default Boot Environment"), tr("You cannot rename the boot environment that is currently set as the default!") );
      return;
    }
    QString name = ui->tree_BE->topLevelItem(index)->text(0);
    //Get the new name from the user
    bool ok;
    QString newname = QInputDialog::getText( this, tr("New BE name"), tr("Choose a new name for this boot environment"), QLineEdit::Normal, name, &ok,0, Qt::ImhLowercaseOnly | Qt::ImhUppercaseOnly | Qt::ImhDigitsOnly ); 
    if(ok && !newname.isEmpty()){
      if( !validateInput(newname) ){
        on_tool_BEmv_clicked(); //try again
        return;
      }
      if( checkName(newname) ){
        beadmRename(name,newname);
        updateBEList();
	updateGRUBdefaults(true); //Make sure to rebuild the GRUB menu with the new name
      }
    }
  }
}
Exemplo n.º 12
0
void ConfigDialog::onOKButtonClick()
{
  if (validateInput()) {
    onApplyButtonClick();
    kill(0);
  }
}
Exemplo n.º 13
0
///@brief Adds author described in the form.
void AddAuthor::save()
{
	if(!validateInput())
		return;
	Author a;
	a.setFirstName(firstNameLineEdit->text());
	a.setLastName(lastNameLineEdit->text());
	a.setDescription(descriptionLineEdit->text());
	a.setCritique(critiqueLineEdit->text());
	a.setPicture(pictureLineEdit->text());
	a.setRating(ratingWidget->getRating());

	a.setThemes(getSelectedThemes());

	try
	{
		c->insertAuthor(a);
	}
	catch(DataBaseException dbe)
	{
		MessageBoxDataBaseException q(&dbe, this);
		q.appendText(tr("The author has not been added."));
		q.exec();
	}
	emit closeRequested();
}
long long getNextPageNumber(char *buf, int bufSize, FILE *istream) {
    long long pageNo = INVALID_INPUT;
    do {
        if(fgets(buf, bufSize, istream) == NULL)
            return END_OF_FILE;
    } while((pageNo = validateInput(buf)) == INVALID_INPUT);
    return pageNo;
}
Exemplo n.º 15
0
int main(){

    int **array=NULL;

    int response;

    int dimensionResponse;
    printf("Welcome to Rotate Array!\n");

    while(1){
        printf("What would you like to do?\n");
        printf("1.Read and display 2D array from file, display and rotate it.\n");
        printf("2. Specify dimensions and generate random 2D array to display and rotate it.\n");
        printf("3. Quit\n");
        //validates input to prevent crashing when a char or string is entered
        response = validateInput();

        switch(response){
            case 1:
                array=readFile(array);
                displayArray(array);
                controlArray(array);

                break;
            case 2:
                printf("Speicify the row and column dimensions of your 2D array.\n");
                dimensionResponse = validateInput();
                array = generateRandom(dimensionResponse);
                displayArray(array);
                controlArray(array);

                break;
            case 3:
                printf("Goodbye!");
                return 0;
            default:
                printf("Please enter a valid number.\n");
                break;

        }

    }

    return 0;
}
void ChangePasswordServerDialog::tryToCreatePassword() {
  if (!validateInput()) {
    QMessageBox::critical(this, translations::trError, trInvalidInput);
    return;
  }
  std::string password = common::ConvertToString(passwordLineEdit_->text());
  core::events_info::ChangePasswordRequest req(this, std::string(), password);
  server_->ChangePassword(req);
}
Exemplo n.º 17
0
void 
SoMVTVolumeCalculator::inputChanged (SoField* whichField)
{
	if (whichField == &process)
	{
		if (validateInput())
		{
			calculateVolumeMeasures();
		}
	}
}
Exemplo n.º 18
0
int main(int argc, char* argv[]){
	refresh(START);
	int mode;
	mode = validateInput(argc,argv);
	if(mode!=RESTRICTED){
		launch(mode);
	}else{
		printf("Program Terminated \n\tCorrect Format: ./app MODE XXXX\n");
		Exit(ERR_IO);
	}
	refresh(STOP);
	return 0;
}
Exemplo n.º 19
0
int main() {
	// initialize the variable to store the query string at
	char *data;
	FILE *dashboard;
	char line[1000];
	char *username;
	char *password;

	// Store the query string environment variable by CGI's GET
	data = getenv("QUERY_STRING");
	
	// get the username and password fields
	username = getUsername(data);
	password = getPassword(data);

	// Print the output to the browser
	printf("Content-Type:text/html\n\n");
	printf("<html>");

	// have the dashboard up and running on the cgi server
	// use fgets to read it line by line
	dashboard = fopen(DASHBOARD, "r+");

	// If the file does not exist, print error and exit program.
	if( dashboard == NULL ) {
		printf("<p>Error! Attempted to access invalid page %s</p>", DASHBOARD);
	}

	printf("<p> Data is: %s</p>\n", data);
	printf("<p> Username is %s</p>\n", username);
	printf("<p> Password is %s</p>\n", password);

	int validInput = validateInput(username, password);

	printf("<p> ValidInput is %d</p>\n", validInput);
	
	while(fgets(line, sizeof(line), dashboard) != NULL) {
		//printf("<p>hmm</p>\n");
		if(strstr(line, "</body>") != NULL) {
			printf("<p>true!!</p>\n");
			
			printf("%s\n", line);
		}
		else{
			printf("%s\n", line);
		}
	}
	fclose(dashboard);

	return 0;
}
Exemplo n.º 20
0
void inputSuduku (US *suduku, US size) {
    US row, col;;
    for ( row = 0 ; row < size ; row++ ) {
        for (col = 0 ; col < size ; col++) {
            do {
		system("clear");
		intro();
		printf("Please enter your suduku puzzle below, with 0 for spaces. Press <ENTER> after each number.\n");
		outputPartSuduku(suduku, size, row, col);
	    } while (validateInput(&(suduku[row*size+col]),size) == false);;
	};
    };
    printf("Thanks!");
}
Exemplo n.º 21
0
bool KOTodoEditor::processInput()
{
    if(!validateInput()) return false;

    if(mTodo)
    {
        bool rc = true;
        Todo *oldTodo = mTodo->clone();
        Todo *todo = mTodo->clone();

        kdDebug(5850) << "KOTodoEditor::processInput() write event." << endl;
        writeTodo(todo);
        kdDebug(5850) << "KOTodoEditor::processInput() event written." << endl;

        if(*mTodo == *todo)
            // Don't do anything
            kdDebug(5850) << "Todo not changed\n";
        else
        {
            kdDebug(5850) << "Todo changed\n";
            //IncidenceChanger::assignIncidence( mTodo, todo );
            writeTodo(mTodo);
            mChanger->changeIncidence(oldTodo, mTodo);
        }
        delete todo;
        delete oldTodo;
        return rc;

    }
    else
    {
        mTodo = new Todo;
        mTodo->setOrganizer(Person(KOPrefs::instance()->fullName(),
                                   KOPrefs::instance()->email()));

        writeTodo(mTodo);

        if(!mChanger->addIncidence(mTodo, this))
        {
            delete mTodo;
            mTodo = 0;
            return false;
        }
    }

    return true;

}
Exemplo n.º 22
0
    void reverseWords(string &s) {
        validateInput(s);
        int l = s.length(), i = l - 1;
        int start, end = l - 1;
        string ostr = "";

        while(i >= 0) {
            while(s.at(i) == ' ') i--;
            end = i;
            while(i >= 0 && s.at(i) != ' ') i--;
            start = i + 1;

            ostr.append(s.substr(start, end - start + 1) + " ");
         }
            s = ostr.substr(0, ostr.length() - 1);
    }
Exemplo n.º 23
0
Arquivo: main.c Projeto: moikop/ab
int main(int argc, char** argv) {
    FILE* logf;
    tdns dns;
    char cmd[100];
    char file_dns[100] = "dns.txt";
    char logfile[] = "log.txt";
    int loaded;
    int error;
    int crear;

    /*validacion parámetros de entrada*/
    if(validateInput(argc, argv, cmd)!=RES_OK) {
        showHelp(argv[0]);
        return RES_ERROR;
    }
    logf = fopen(logfile,"a");
    if(!logf) {
        printf("No se pudo abrir el archivo de log.\n");
        return RES_ERROR;
    }

    crear = createDNS(&dns,sizeof(tdomain));
    if(crear!=RES_OK) {
        printf("Ocurrió un error: %i.\n",crear);
        return RES_ERROR;
    }

    /*procesamos el archivo con las direcciones y dominios; en el proceso */
    loaded = loadTree(&dns,file_dns);
    if(loaded!=RES_OK) {
        printf("Ocurrió un error: %i.\n",loaded);
        return loaded;
    }

    /*Decidimos que accion es la que nos pide el usuario*/
    error = processData(&dns,argv,cmd,logf);
    if(error!=RES_OK) {
        printf("Ocurrió un error: %i.\n",error);
        fclose(logf);
        return RES_ERROR;
    }

    fclose(logf);

    return RES_OK;
}
Exemplo n.º 24
0
int wmain(int argc, wchar_t* argv[])
{
	if (argc == 1)
	{
		printUsage();
		exit(1);
	}

	for (int i = 1; i < argc; i++)
	{
		if (!wcscmp(argv[i], _T("-f")) || !wcscmp(argv[i], _T("-file")))
		{
			filename = argv[++i];
		}
		else if (!wcscmp(argv[i], _T("-vol")) || !wcscmp(argv[i], _T("-volume")))
		{
			volume = 5;
			++i;
		}
		else if (!wcscmp(argv[i], _T("-h")) || !wcscmp(argv[i], _T("-help")) || !wcscmp(argv[i], _T("--h")) || !wcscmp(argv[i], _T("--help")))
		{
			printUsage();
			exit(0);
		}
		else if (!wcscmp(argv[i], _T("-v")) || !wcscmp(argv[i], _T("--v")))
		{
			printVersion();
			exit(0);
		}
		else
		{
			printf("invalid argument %s.\n", argv[i]);
			exit(1);
		}
	}
	if (validateInput())
	{
		play();
	}
	else
	{
		exit(1);
	}
}
void CopyBuildOver::okClick(){
    if(!validateInput())
        return;

    int machineId = -1;

    for(int i = 0; i < management->getMachineCount(); i++){
        Machine *machine = management->getMachineAt(i);
        if(machine != 0){
            if(!machine->getMachineIP().compare(ui->lineEditMachineIP->text()))
                machineId = machine->getMachineID();
        }
    }

    if(machineId <= -1)
        return;

    emit copyBuildOver(machineId, ui->lineEditBuildName->text());
    this->close();
}
Exemplo n.º 26
0
int main(int argc, char *argv[]) {
  if (!validateInput(argc)) {
    return 0;
  }

  int heightCount = argc - 1;
  int heights[heightCount];

  for (int i = 0; i < heightCount; i++) {
    heights[i] = atoi(argv[i + 1]);
  }

  int cliff = 0;
  int volume = 0;
  bool counting = false;

  for (int i = 0; i < heightCount; i++) {
    if (i == 0) {
      continue;
    }

    int previous = heights[i - 1];
    int current = heights[i];

    if (previous > current && !counting) {
      counting = true;
      cliff = previous;
    }

    if (counting) {
      if (cliff > current && i != heightCount - 1) {
        volume += cliff - current;
      } else {
        counting = false;
      }
    }
  }

  printf("%i", volume);
  return 0;
}
Exemplo n.º 27
0
void UploadInfoPage::setInfo_path(DesuraId id, const char* path)
{
	setInfo(id);
	if (path)
	{
		m_tbItemFile->SetValue(gcString(path));

		if (validateInput())
		{
			m_butUpload->Enable(false);
			m_tbItemFile->Enable(false);
			m_butFile->Enable(false);

			initUpload(path);
		}
		else
		{
			gcMessageBox(GetParent(),  Managers::GetString(L"#UDF_ERROR_VALIDATION"), Managers::GetString(L"#UDF_ERRTITLE") );
		}
	}
}
Exemplo n.º 28
0
void ConfigDialog::onApplyButtonClick()
{
  // Check values that specified in gui.
  bool canApply = validateInput();

  // Fill global server configuration with values from gui.
  if (canApply) {
    m_administrationConfigDialog.apply();
    m_serverConfigDialog.apply();
    m_ipAccessControlDialog.apply();
    m_videoRegionsConfigDialog.apply();
  } else {
    return ;
  }

  // If reload command is specified then we're working in online mode
  // and we don't to save configuration locally.
  if (m_reloadConfigCommand != NULL) {
    m_reloadConfigCommand->execute();

    m_administrationConfigDialog.updateUI();
    m_ipAccessControlDialog.updateUI();

    m_ctrlApplyButton.setEnabled(false);
  } else {
     // Else we're working in offline mode and we need to save config
    if (!m_config->save()) {
      MessageBox(m_ctrlThis.getWindow(),
                 StringTable::getString(IDS_CANNOT_SAVE_CONFIG),
                 StringTable::getString(IDS_MBC_ERROR),
                 MB_OK | MB_ICONERROR);
    } else {
      m_ctrlApplyButton.setEnabled(false);
      MessageBox(m_ctrlThis.getWindow(),
        StringTable::getString(IDS_OFFLINE_CONFIG_SAVE_NOTIFICATION),
        StringTable::getString(IDS_MBC_TVNCONTROL),
        MB_OK | MB_ICONINFORMATION);
    } // if cannot save.
  } // if offline mode (reload command not specified).
}
Exemplo n.º 29
0
/****************************************************************************************************
Function Name: NewRoundSetup()

Purpose:	Start a New Game. This means prepare the beginning of the round, which requires the setting up of all the variables.
			COntinue game can also use this
Parameters: bool a_isNewGame is it a new game?
, string a_whoWonLastRound just check on winner of the last round for a continue game

Return Value: none

Local Variables: 1. int numberOfSquare => input that determines the size of the Tileset

Algorithm:

Assistance Received:

*****************************************************************************************************/
void Tournament::NewRoundSetup(bool a_isNewGame, string a_whoWonLastRound)
{
	int numberOfSquares = 0;
	do
	{
		do
		{
			cout << "Please Enter whether you'd like play with 9,10 or 11 squares." << endl;

		} while (!validateInput(numberOfSquares));


	} while (numberOfSquares !=9 && numberOfSquares !=10 && numberOfSquares !=11);

	//this is more of general idea solidification than it is necessary to do.
	m_sizeOfTileset = numberOfSquares;


	//Load a new game of specific size
	m_GameEngine.IntializeNewRound( m_sizeOfTileset, a_isNewGame, a_whoWonLastRound);

}
Exemplo n.º 30
0
/*-----------------------------------------------------------------------------*/
int main(int argc, char *argv[]) {

        Input input = validateInput(argc, argv);
	printf("awget:\n\tRequest: %s\n\t", input.URL);

	char ** fileLines = readFile(input.filename);	

	printf("chainlist is\n\t");
        for(int j = 1; fileLines[j] != NULL; j++) {
	    printf("%s\n\t", fileLines[j]);
	}

	Packet * aPacket = buildPacket(fileLines, input.URL);

	int randStepNum = getRandStepNum(aPacket->chainFile[0]); //Get random stepping stone number
	
	char * steppingStone = fileLines[randStepNum]; //Get random stepping stone

	printf("next SS is %s\n\t", steppingStone);

	//Connect to stepping stone
        int socketfd = setupSocket(getIP(steppingStone), atoi(getPort(steppingStone)));

	//Remove stepping stone from file
	removeSS(randStepNum, aPacket); 

	//Write to stepping stone
	socketfd = writeSocket(socketfd, aPacket);

	printf("waiting for file...\n..\n");	

	//Read the data
	char *filename = getFilename(input.URL);
	makeFile(socketfd, filename);
	printf("\tReceived file <%s>\n\tGoodbye!\n", filename);
	close(socketfd);
        free (aPacket);
}