Esempio n. 1
0
void	BoardInitialize()
{
	char* verz = DATADIR "/sokoban/";
	char* verz2 = CONFIGDIR "/sokoban/";
	FILE *Datei=0;
	int x,y,z;
	int i;
	char* d;

	if (levelverz[level]==1)
		{
		d = malloc (strlen(verz)+strlen(levelname[level])+1);
		strcpy (d,verz);
		strcat (d,levelname[level]);
		}
	else
		{
		d = malloc (strlen(verz2)+strlen(levelname[level])+1);
		strcpy (d,verz2);
		strcat (d,levelname[level]);
		}

	FBFillRect( 0, 0, 720, 576, BLACK );

	Datei = fopen(d, "r");

	free(d);

	if ( !Datei )
	{	// installation error
		doexit=4;
		FBDrawString( 200, 510, 30, "Installation Error. Cant find Level", WHITE, 0 );
		return;
	}

	MAZEW = 0;
	MAZEH = 0;

	for (y=0; y<18; y++)
		{
		for (x=0; x<22; x++)
			{
			setField(x, y, 'a');
			}
		}

	x=0; y=0;
	while(!feof(Datei))
		{
		z = fgetc(Datei);

		if (z!='#' && z!='.' && z!='$' && z!='@' && z!='+' && z!='*' && z!=' ' && z!=0x0d && z!=0x0a)
			{
			MAZEH=y;
			break;
			}
		else if (z == 0x0d)
			{
			z=fgetc(Datei);
			for (i=x; board[i][y] != '#' && i > 3; i--) {x=i;}
			if (MAZEW < x) {MAZEW = x;}
			y++;
			x=0;
			MAZEH=y;
			}
		else if (z == 0x0a)
			{
			for (i=x; board[i][y] != '#' && i > 3; i--) {x=i;}
			if (MAZEW < x) {MAZEW = x;}
			y++;
			x=0;
			MAZEH=y;
			}
		else
			{
			if (y<18 && x<22)
				{
				setField(x, y, z);
				if ((z=='@') || (z=='+'))
					{
					man_x = x;
					man_y = y;
					}
				}
			x++;
			}
		}

	fclose(Datei);

	ox = (720 - (MAZEW*32))/2;
	oy = (576 - (MAZEH*28))/2;

	for (y=0; y<18; y++)
		{
		for (x=0; x<22; x++)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		for (x=21; x>=0; x--)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		}

	for (x=0; x<22; x++)
		{
		for (y=0; y<18; y++)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		for (y=17; y>=0; y--)
			{
			if (getField(x, y) != '#') {setField (x, y, 'a');}
				else break;
			}
		}

	moves = 0;
	pushes = 0;

	DrawBoard();
	DrawScore();
	FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 );
	
	for (i=0; i<=1500;i++)
		{
		Zuege[i]=' ';
		}
}
Esempio n. 2
0
void		Packet_v1_Channel::setClientSessionId(field_t clientSessionId)
{
  setField(clientSessionId, PROTOV1_CHANNEL_CLIENTSESSIONID_OFF, PROTOV1_CHANNEL_CLIENTSESSIONID_SIZE);
}
Esempio n. 3
0
void DBQuery::setField(const char *fmt, const std::string &value) {
  setField(fmt, value.data(), value.length());
}
Esempio n. 4
0
//-- calculates the explosion of one or more bombs
void Spielfeld::explode(Position pos, int reichweite, queue<Position>* toDie = NULL)
{
  cout << "Spielfeld::explode(" << pos.x << "," << pos.y << ");" << endl;
  feld[pos.x][pos.y]->die();                    // Bombe aufräumen
  setField(pos, FREI);                          // Bombe löschen
  netInterface->setItem(pos, FREI);
  netInterface->explode(pos, reichweite);       // Meldung an Clients senden

  // Treffer erkennen (Spielfiguren)
  for ( int pID = 0; pID < MAX_PLAYERS; pID++)
  {
    if ( player[pID] != NULL )
    {
      if ( pos.x == player[pID]->getPosition().x && pos.y == player[pID]->getPosition().y)
      {
        player[pID]->die();
      }
    }
  }


  bool firstBomb = false;
  if ( toDie == NULL )                          // erste Bombe (bei kettenreaktion)
  {
    toDie = new queue<Position>;
    firstBomb = true;
  }


  int distance;
  Position temppos;

  for ( int direction = UP; direction <= LEFT; direction++)
  {
    distance = 0;
    temppos  = pos;
    while ( distance < reichweite )
    {
      switch ( direction )
      {
        case UP   : temppos.y--;
                    break;
        case DOWN : temppos.y++;
                    break;
        case RIGHT: temppos.x++;
                    break;
        case LEFT : temppos.x--;
                    break;
      }
      distance++;

      // Treffer erkennen (Spielelemente)
      if ( feld[temppos.x][temppos.y] != NULL )
      {
        if ( feld[temppos.x][temppos.y]->getType() == BOMBE )
        {
          explode(temppos, ((Bombe*)(feld[temppos.x][temppos.y]))->getReichweite(), toDie);
        }
        else
        {
          toDie->push(temppos);
        }
        distance = reichweite;
      }

      // Treffer erkennen (Spielfiguren)
      for ( int pID = 0; pID < MAX_PLAYERS; pID++)
      {
        if ( player[pID] != NULL )
        {
          if ( temppos.x == player[pID]->getPosition().x && temppos.y == player[pID]->getPosition().y)
          {
            player[pID]->die();
          }
        }
      }

    }
  }


  if ( firstBomb == true)                                   // gesprengte Objekte löschen
  {
    clearKilledElements(toDie);
    delete ( toDie );
    netInterface->sendAll();
  }
}
Esempio n. 5
0
void QgsDataDefinedButton::menuActionTriggered( QAction* action )
{
  if ( action == mActionActive )
  {
    setActive( mActionActive->data().toBool() );
    updateGui();
  }
  else if ( action == mActionDescription )
  {
    showDescriptionDialog();
  }
  else if ( action == mActionExpDialog )
  {
    showExpressionDialog();
  }
  else if ( action == mActionExpression )
  {
    setUseExpression( true );
    setActive( true );
    updateGui();
  }
  else if ( action == mActionCopyExpr )
  {
    QApplication::clipboard()->setText( getExpression() );
  }
  else if ( action == mActionPasteExpr )
  {
    QString exprString = QApplication::clipboard()->text();
    if ( !exprString.isEmpty() )
    {
      setExpression( exprString );
      setUseExpression( true );
      setActive( true );
      updateGui();
    }
  }
  else if ( action == mActionClearExpr )
  {
    // only deactivate if defined expression is being used
    if ( isActive() && useExpression() )
    {
      setUseExpression( false );
      setActive( false );
    }
    setExpression( QString( "" ) );
    updateGui();
  }
  else if ( mFieldsMenu->actions().contains( action ) )  // a field name clicked
  {
    if ( action->isEnabled() )
    {
      if ( getField() != action->text() )
      {
        setField( action->data().toString() );
      }
      setUseExpression( false );
      setActive( true );
      updateGui();
    }
  }
}
void PageOffer_Assets::SetCurrencyBlank()
{
    setField("CurrencyName", QString("<%1>").arg(tr("Click to choose Currency")));
    setField("CurrencyID",   "");
}
Esempio n. 7
0
void RomInfo::fillData()
{
    if (m_gamename == "")
    {
        return;
    }

    MSqlQuery query(MSqlQuery::InitCon());

    QString systemtype;
    if (m_system != "") {
        systemtype  += " AND system = :SYSTEM ";
    }

    QString thequery = "SELECT system,gamename,genre,year,romname,favorite,"
                       "rompath,country,crc_value,diskcount,gametype,plot,publisher,"
                       "version,screenshot,fanart,boxart,inetref,intid FROM gamemetadata "
                       "WHERE gamename = :GAMENAME "
                       + systemtype + " ORDER BY diskcount DESC";

    query.prepare(thequery);
    query.bindValue(":SYSTEM", m_system);
    query.bindValue(":GAMENAME", m_gamename);

    if (query.exec() && query.next())
    {
        setSystem(query.value(0).toString());
        setGamename(query.value(1).toString());
        setGenre(query.value(2).toString());
        setYear(query.value(3).toString());
        setRomname(query.value(4).toString());
        setField("favorite",query.value(5).toString());
        setRompath(query.value(6).toString());
        setCountry(query.value(7).toString());
        setCRC_VALUE(query.value(8).toString());
        setDiskCount(query.value(9).toInt());
        setGameType(query.value(10).toString());
        setPlot(query.value(11).toString());
        setPublisher(query.value(12).toString());
        setVersion(query.value(13).toString());
        setScreenshot(query.value(14).toString());
        setFanart(query.value(15).toString());
        setBoxart(query.value(16).toString());
        setInetref(query.value(17).toString());
        setId(query.value(18).toInt());
    }

    setRomCount(romInDB(m_romname,m_gametype));

    // If we have more than one instance of this rom in the DB fill in all
    // systems available to play it.
    if (RomCount() > 1)
    {
        query.prepare("SELECT DISTINCT system FROM gamemetadata "
                      "WHERE romname = :ROMNAME");
        query.bindValue(":ROMNAME", Romname());
        if (!query.exec())
            MythDB::DBError("RomInfo::fillData - selecting systems", query);

        while (query.next())
        {
            if (m_allsystems.isEmpty())
                m_allsystems = query.value(0).toString();
            else
                m_allsystems += "," + query.value(0).toString();
        }
    }
    else
    {
        m_allsystems = m_system;
    }
}
Esempio n. 8
0
void DBQuery::setField(const char *fmt, unsigned int value) {
  setField(fmt, (int)value);
}
void PageSmart_PartyAcct::SetFieldsBlank()
{
    setField("AcctName", m_qstrClickText);

//    emit completeChanged();
}
Esempio n. 10
0
bool LS3Datastore::setField(QString field, QVariant data) {
    return setField(currentRecordNum(), field, data);
}
Esempio n. 11
0
void DBQuery::setField(const char *fmt, int value) {
  setField(fmt, boost::lexical_cast<string>(value).c_str());
}
void OtrPeerIdentityVerificationQuestionAndAnswerPage::initializePage()
{
	setField("question", QString());
	setField("answer", QString());
}
Esempio n. 13
0
 void             setSecurityManager(RexxObject *manager) { setField(securityManager, new SecurityManager(manager)); }
Esempio n. 14
0
void	MoveMouse()
{
static	int	locked = 0;
int dx=0;
int dy=0;
char zug=' ';

	if ( locked )
	{
		locked--;
		actcode=0xee;
		return;
	}

	switch( actcode )
	{
	case RC_RIGHT :		// Pinguin nach rechts
		if ( man_x+1 < MAZEW )
		{
		dx = 1;
		dy = 0;
		zug = 'r';
		locked=1;
		}
		break;

	case RC_LEFT :		// Pinguin nach links
		if ( man_x > 1 )
		{
		dx = -1;
		dy = 0;
		zug = 'l';
		locked=1;
		}
		break;

	case RC_DOWN :		// Pinguin nach unten
		if ( man_y+1 < MAZEH )
		{
		dx = 0;
		dy = 1;
		zug = 'd';
		locked=1;
		}
		break;

	case RC_UP :		// Pinguin nach oben
		if ( man_y > 1 )
		{
		dx = 0;
		dy = -1;
		zug = 'u';
		locked=1;
		}
		break;

	case RC_MINUS :		// letzte Züge rückgängig machen
		if (moves>0)
			{
			if (getField(man_x,man_y)=='@')
				{
				setField(man_x,man_y,' ');
				}
			else
				{
				setField(man_x,man_y,'.');
				}

			if (Zuege[moves]=='r' || Zuege[moves]=='R')
				{
				man_x--;
				dx=1;
				}
			else if (Zuege[moves]=='l' || Zuege[moves]=='L')
				{
				man_x++;
				dx=-1;
				}
			else if (Zuege[moves]=='u' || Zuege[moves]=='U')
				{
				man_y++;
				dy=-1;
				}
			else if (Zuege[moves]=='d' || Zuege[moves]=='D')
				{
				man_y--;
				dy=1;
				}

			if (getField(man_x,man_y)==' ')
				{
				setField(man_x,man_y,'@');
				}
			else
				{
				setField(man_x,man_y,'+');
				}

			if (isupper(Zuege[moves]))
				{
				if (getField(man_x+2*dx,man_y+2*dy)=='$')
					{
					setField(man_x+2*dx,man_y+2*dy,' ');
					}
				else
					{
					setField(man_x+2*dx,man_y+2*dy,'.');
					}

				if (getField(man_x+dx,man_y+dy)==' ')
					{
					setField(man_x+dx,man_y+dy,'$');
					}
				else
					{
					setField(man_x+dx,man_y+dy,'*');
					}
				pushes--;
				}
			moves--;
			dx=0;
			dy=0;
			DrawBoard();
			DrawScore();
		}
		locked=1;
		break;

	case RC_PLUS :		// Rückgängig rückgängig machen
		if (Zuege[moves+1]!=' ')
			{
			if (Zuege[moves+1]=='r' || Zuege[moves+1]=='R')
				{
				dx=1;
				}
			else if (Zuege[moves+1]=='l' || Zuege[moves+1]=='L')
				{
				dx=-1;
				}
			else if (Zuege[moves+1]=='u' || Zuege[moves+1]=='U')
				{
				dy=-1;
				}
			else if (Zuege[moves+1]=='d' || Zuege[moves+1]=='D')
				{
				dy=1;
				}
			}
		locked=1;
		break;

	case RC_RED :		// vorheriges Level - bei angefangenem Level nachfragen, ob wirklich sicher
		if (moves!=0)
			{
			FBFillRect( 160, 70, 400, 436, B );
			FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 );
			FBDrawString( 160,110, 30, "ROT   abbruch", WHITE, 0 );
			FBDrawString( 160,140, 30, "OK    naechstes Level", WHITE, 0 );
#ifdef USEX
			FBFlushGrafic();
#endif

			actcode=0xee;
			while( actcode != RC_OK && actcode != RC_RED )
				{
					RcGetActCode();
				}
			}
		if (actcode == RC_OK || moves==0)
			{
			if (level > 0)
				{
				level--;
				BoardInitialize();
				}
			else
				{
				level = max_level-1;
				BoardInitialize();
				}
			}
		else
			{
			FBFillRect( 0, 0, 720, 576, BLACK );
			DrawBoard();
			DrawScore();
			}

		locked=1;
		break;

	case RC_GREEN :		// naechstes Level - bei angefangenem Level nachfragen, ob wirklich sicher
		if (moves!=0)
			{
			FBFillRect( 160, 70, 400, 436, B );
			FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 );
			FBDrawString( 160,110, 30, "ROT   abbruch", WHITE, 0 );
			FBDrawString( 160,140, 30, "OK    vorheriges Level", WHITE, 0 );
#ifdef USEX
			FBFlushGrafic();
#endif

			actcode=0xee;
			while( actcode != RC_OK && actcode != RC_RED )
				{
					RcGetActCode();
				}
			}
		if (actcode == RC_OK || moves==0)
			{
			if (level+1 < max_level)
				{
				level++;
				BoardInitialize();
				}
			else
				{
				level = 0;
				BoardInitialize();
				}
			}
		else
			{
			FBFillRect( 0, 0, 720, 576, BLACK );
			DrawBoard();
			DrawScore();
			}

		locked=1;
		break;

	case RC_YELLOW :	// Randfelder ('a') aus-/einblenden
		if (Rand == 0)
			{
			Rand = 1;
			}
		else
			{
			Rand = 0;
			}
		locked=1;
		FBFillRect( 0, 0, 720, 576, BLACK );
		DrawBoard();
		DrawScore();
		FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 );
		break;

	case RC_BLUE :		// Level von vorne beginnen - bei angefangenem Level nachfragen, ob wirklich sicher
		if (moves!=0)
			{
			FBFillRect( 160, 70, 400, 436, B );
			FBDrawString( 160,75, 30, "Das Level ist noch nicht beendet!", WHITE, 0 );
			FBDrawString( 160,110, 30, "ROT   abbruch", WHITE, 0 );
			FBDrawString( 160,140, 30, "OK    vorheriges Level", WHITE, 0 );
#ifdef USEX
			FBFlushGrafic();
#endif
			actcode=0xee;
			while( actcode != RC_OK && actcode != RC_RED )
				{
					RcGetActCode();
				}
			}
		if (actcode == RC_OK || moves==0)
			{
			BoardInitialize();
			}
		else
			{
			FBFillRect( 0, 0, 720, 576, BLACK );
			DrawBoard();
			DrawScore();
			}
		locked=1;
		break;

	case RC_HELP :		// Hilfe anzeigen
		locked=1;
		FBFillRect( 160, 70, 400, 436, B );
		FBDrawString( 160, 70, 30, "ROT   vorheriges Level", WHITE, 0 );
		FBDrawString( 160,100, 30, "GRUEN naechstes Level", WHITE, 0 );
		FBDrawString( 160,130, 30, "GELB  Rand ein/aus", WHITE, 0 );
		FBDrawString( 160,160, 30, "BLAU  Level neu starten", WHITE, 0 );
		FBDrawString( 160,190, 30, "MINUS Zug zurueck", WHITE, 0 );
		FBDrawString( 160,220, 30, "PLUS  Zug vor", WHITE, 0 );
		FBDrawString( 160,260, 30, "HOME  Spiel beenden", WHITE, 0 );
		FBDrawString( 160,290, 30, "STUMM Spiel aus-/einblenden", WHITE, 0 );
		FBDrawString( 160,330, 30, "HILFE diese Hilfe", WHITE, 0 );
		FBDrawString( 160,370, 30, "OK    weiter", WHITE, 0 );
#ifdef USEX
		FBFlushGrafic();
#endif

		actcode=0xee;
		while( actcode != RC_OK )
			{
				RcGetActCode( );
			}
		FBFillRect( 0, 0, 720, 576, BLACK );
		DrawBoard();
		DrawScore();
		FBDrawString( 300, 510, 30, levelname[level], WHITE, 0 );
		break;
	}

	if (dx != 0 || dy != 0)		// Soll Pinguin verschoben werden?
	{
	if (getField(man_x+dx, man_y+dy) == ' ')	// Zug auf leeres Feld - keine Kiste vorhanden
		{
		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'@');

		DrawField(man_x, man_y);

		moves++;
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '.')	// Zug auf Zielfeld - keine Kiste vorhanden
		{
		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'+');

		DrawField(man_x, man_y);

		moves++;
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '$' && getField(man_x+(2*dx), man_y+(2*dy)) == ' ')	// Zug auf Feld mit Kiste - Kiste auf leeres Feld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'$');
		setField(man_x+dx, man_y+dy,' ');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'@');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '$' && getField(man_x+(2*dx), man_y+(2*dy)) == '.')	// Zug auf Feld mit Kiste - Kiste auf Zielfeld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'*');
		setField(man_x+dx, man_y+dy,' ');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'@');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '*' && getField(man_x+(2*dx), man_y+(2*dy)) == ' ')	// Zug auf Zielfeld mit Kiste - Kiste auf leeres Feld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'$');
		setField(man_x+dx, man_y+dy,'.');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'+');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else if (getField(man_x+dx, man_y+dy) == '*' && getField(man_x+(2*dx), man_y+(2*dy)) == '.')	// Zug auf Zielfeld mit Kiste - Kiste auf Zielfeld
		{
		setField(man_x+(2*dx), man_y+(2*dy),'*');
		setField(man_x+dx, man_y+dy,'.');
		DrawField(man_x+(2*dx), man_y+(2*dy));

		if (getField(man_x,man_y)=='@') {setField(man_x,man_y,' ');}
			else {setField(man_x,man_y,'.');}
		DrawField(man_x, man_y);

		man_x += dx; dx = 0;
		man_y += dy; dy = 0;
		setField(man_x,man_y,'+');

		DrawField(man_x, man_y);

		moves++;
		pushes++;
		zug = toupper (zug);
		DrawScore();
		}
	else
		{
		zug = ' ';
		}
	}

	if (zug !=' ')
		{
		Zuege[moves]=zug;
		}

	if (win() == 1)		// durch letzten Zug gewonnen?
		{
		if (level+1 < max_level)
			{
			level++;
			}
		else
			{
			level = 0;
			}

		doexit=1;
		}
#ifdef USEX
	FBFlushGrafic();
#endif
	return;
}
Esempio n. 15
0
void TJClassRef::setField(const std::string& fieldName, const TJStringRef& stringRef)
{
	setField(fieldName, stringRef.get());
}
void PageSmart_PartyAcct::on_pushButtonSelect_clicked()
{
    QWizard * pWizard = wizard();

    if (NULL == pWizard)
        return;

    WizardPartyAcct * pWizardPartyAcct = dynamic_cast<WizardPartyAcct*>(pWizard);

    if (NULL == pWizardPartyAcct)
        return;

    mapIDName & mapConfirmed = pWizardPartyAcct->m_mapConfirmed;
    // -------------------------------------------
    QString qstrTemplate = field("SmartTemplate").toString();
    std::string str_template = qstrTemplate.toStdString();
    // -------------------------------------------
    QString qstrParty = field("PartyName").toString();
    std::string str_party    = qstrParty.toStdString();
    // -------------------------------------------
    QString qstr_current_id = field("AcctName").toString();

    if (0 == qstr_current_id.compare(m_qstrClickText))
        qstr_current_id = QString("");
    // -------------------------------------------
    DlgChooser theChooser(this);
    // -----------------------------------------------
    mapIDName & the_map = theChooser.m_map;

    bool bFoundDefault = false;
    // -----------------------------------------------
    int32_t acct_count = opentxs::OTAPI_Wrap::It()->Party_GetAcctCount(str_template, str_party);

    for (int32_t i = 0; i < acct_count; i++)
    {
        std::string acctName =
            opentxs::OTAPI_Wrap::It()->Party_GetAcctNameByIndex(str_template, str_party, i);

        if ("" == acctName) {
            QMessageBox::information(this, tr("Moneychanger"), tr("Strange, there is an account on this smart contract without a name. Failure."));
            wizard()->reject();
            return;
        }
        QString qstrAcctName = QString::fromStdString(acctName);
        mapIDName::iterator it = mapConfirmed.find(qstrAcctName);

        bool alreadyConfirmed = (mapConfirmed.end() != it);

        std::string partyAcctID = opentxs::OTAPI_Wrap::It()->Party_GetAcctID(str_template, str_party, acctName);

        if (alreadyConfirmed || "" != partyAcctID) {
            continue;
        }
        // ------------------------------
        // It's not confirmed yet, so we can add it to the list of accounts to choose from.
        //
        QString OT_id = qstrAcctName;
        QString OT_name = OT_id;
        // -----------------------------------------------
        if (!OT_id.isEmpty())
        {
            if (!qstr_current_id.isEmpty() && (0 == qstr_current_id.compare(OT_id)))
                bFoundDefault = true;
            // -----------------------------------------------
            the_map.insert(OT_id, OT_name);
        }
    }
    // -----------------------------------------------
    // This should never happen because as long as the account
    // count is not the same as the mapConfirmed size, we thus still
    // have more accounts that need to be confirmed. That's the only
    // reason we're in this function at all -- Moneychanger popped up
    // this wizard to collect the next account because it can see
    // more accounts still need to be confirmed and that's how it decided
    // to pop up this wizard in the first place.
    //
    if (0 == the_map.size())
    {
        QMessageBox::information(this, tr("Moneychanger"),
                                 tr("Strange: though I didn't think it was the case at first, It seems now that all accounts ARE already confirmed on this contract. (Failure.)"));
        wizard()->reject();
        return;
    }
    // -----------------------------------------------
    if (bFoundDefault)
        theChooser.SetPreSelected(qstr_current_id);
    // -----------------------------------------------
    theChooser.setWindowTitle(tr("Choose the next account"));
    // -----------------------------------------------
    if (theChooser.exec() == QDialog::Accepted)
    {
        if (!theChooser.m_qstrCurrentID.isEmpty())
        {
            setField("AcctName", theChooser.m_qstrCurrentID);
            emit completeChanged();
            return;
        }
    }
}
void PageOffer_Assets::SetAssetBlank()
{
    setField("AssetName", QString("<%1>").arg(tr("Click to choose Asset Type")));
    setField("InstrumentDefinitionID",   "");
}
/**
 * Internal method to just set the scope for the method.
 *
 * @param _scope The new scope.
 */
void MethodClass::setScope(RexxClass  *_scope)
{
    setField(scope, _scope);
}
Esempio n. 19
0
//
// Handle incoming messages from phone
//
void inbox_received_callback(DictionaryIterator *iterator, void *context) {
  // Store incoming information
  static char *layDecode[] = {"SPN", "SCB", "SMD",NULL,NULL,NULL,NULL,NULL,NULL,NULL,"PPN","PCB","PMD","PPN","PCB","PMD"};
  static int tackLog[7] = {0,0,0,0,0,0,0};
  static bool warnedLineBurn = false;
  static int currentState = -1;
  static int thisTack = 0, oldTack = 0;
  int angle;
  bool earlyWarnDone = false;
  bool weAreRacing = false;
  bool doScreenTransition;
  #ifdef PBL_COLOR
  bool redAWA, highVMG;
  #endif
  int j, tmp, ii;
  bool foundKey, negNum; 
  #ifdef CONFIG_SUPPORT
  bool foundAKey = false; // Did we find any data keys in the message?
  #endif
  int startingScreen; // To remember which screen we were at when we arrived here so we don't loop forever looking for a screen with data on it
  int a;
  float b;
  static int flashFlag = 0;
  char *sa, *sb;
  bool fieldUpdated[6];
  bool canDoVMG;
  int twd, bs, hdg;
  #ifdef CONFIG_SUPPORT
    bool receivedConfig = false;
  #endif
  
  if (doubleClick || messageClick)
    return; // Get out of here if we are displaying a message - note - we may miss a tack because of this, but unlikely!!
  startingScreen = currentScreen;
#ifdef PBL_COLOR
  text_layer_set_background_color(flash, flashFlag == 0 ? GColorGreen : GColorClear);
#else
  layer_set_bounds(inverter_layer_get_layer(flash), flashFlag == 0 ? GRectZero : GRect(0,0,7,7)); 
#endif
  flashFlag = 1 - flashFlag;
  if (holdThisScreen > 0)
    holdThisScreen--;
  
  weAreRacing = false; // Assume we're not racing unless we receive a mark name
  do
    {
    for (ii = 0; ii < screens[currentScreen].num_fields; ii++) {
      fieldUpdated[ii] = false;
    }
    canDoVMG = false;
    #ifdef PBL_COLOR
    redAWA = false;
    highVMG = false;
    #endif
    doScreenTransition = false;
    weAreRacing = false;
    // Read first item
    Tuple *t = dict_read_first(iterator);
    j = 0;
    while(t != NULL) {
    foundKey = true;
    char *bj;
    bj = buffer[j];
    // Which key was received?
    //APP_LOG(APP_LOG_LEVEL_INFO, "Key %d Value %d", (int)t->key, (int)t->value->int32);
    switch(t->key) {
      
      case KEY_LINE_BURN:      
      case KEY_LAY_TIME:
      case KEY_LINE_TIME:
      case KEY_SECS_TO_START:
      case KEY_LAY_BURN:
      case KEY_TIME_TO_MARK:
      negNum = false;    
      tmp = abs((int)t->value->int32) ;
      negNum = ((int)t->value->int32 < 0);

      if (tmp >= 100)
      {
        if ((tmp < 6000 && isBigField(t->key)) || tmp < 600) // We have room for mins & seconds & always when mins < 10
        {
          snprintf(bj, sizeof(buffer[0]),"%d:%02d", tmp / 60, tmp % 60);
        }
        else if (tmp < 3600)
        {
          snprintf(bj, sizeof(buffer[0]),"%dm", tmp / 60 + ((tmp % 60) >= 30 ? 1:0));
        }
        else
          {
          snprintf(bj, sizeof(buffer[0]),"%dh", tmp / 3600 + ((tmp % 3600) >= 1800 ? 1:0));          
        }
      }
      else // (tmp < 100)
      {
        snprintf(bj, sizeof(buffer[0]),"%ds", tmp);
      }
      break;

      case KEY_LAST_TACK:
      oldTack = thisTack; // Remember the tack from the last message 
      thisTack = (int)t->value->int32;
      negNum = false; // This definitely shouldn't happen!
      if (currentState != 1)
        bj[0] = '\0';
      else
        snprintf(bj, sizeof(buffer[0]),"%d", abs((int)t->value->int32));
      break;
      
      case KEY_TARGET_TACK:
      negNum = false;
      snprintf(bj, sizeof(buffer[0]),"%d", abs((int)t->value->int32));
      
      case KEY_TWD:
      if (t->key == KEY_TWD) {
        canDoVMG = true;
        twd = t->value->int32;
      }
      case KEY_LAY_DIST:
      case KEY_LINE_DIST:

      case KEY_TARGET_ANGLE:
      case KEY_MARK_BEARING:
      case KEY_HEADING_COG:
      case KEY_HEADING:
      if (t->key == KEY_HEADING)
        hdg = t->value->int32;
      case KEY_AWS:

      case KEY_TWS:
      case KEY_DEPTH:
      case KEY_HEEL:
      case KEY_CURRENT_DIR:
      negNum = ((int)t->value->int32 < 0);
      snprintf(bj, sizeof(buffer[0]),"%d", abs((int)t->value->int32));
      break;
 
      case KEY_TWA:
      case KEY_AWA:
      negNum = false;
      angle = (int)t->value->int32;
      #ifdef PBL_COLOR
      redAWA = angle > 180;
      if (colourAWA) {
              snprintf(bj, sizeof(buffer[0]),"%d", angle <= 180 ? angle : abs(angle - 360));
      } else {
              snprintf(bj, sizeof(buffer[0]),"%d%s", angle <= 180 ? angle : abs(angle - 360), angle <= 180 ? "S":"P");
      }
      #else
      snprintf(bj, sizeof(buffer[0]),"%d%s", angle <= 180 ? angle : abs(angle - 360), angle <= 180 ? "S":"P");
      #endif
      break;
      
      case KEY_BOAT_SOG:
      case KEY_BOAT_SPEED:
      if (t->key == KEY_BOAT_SPEED)
        bs = t->value->int32;
      case KEY_TARGET_SPEED: 
      case KEY_CURRENT_SPEED:
      snprintf(bj, sizeof(buffer[0]),"%d.%d", abs((int)t->value->int32)/10, abs((int)t->value->int32) % 10);
      negNum = ((int)t->value->int32 < 0);
      break;
      
      case KEY_LINE_ANGLE: // If this is negative, we will be over the line early - red burn time
      a = t->value->int32;
      #ifdef PBL_COLOR
      highVMG = (a < 0);
      #endif
      a = abs(a);
      negNum = false;
      snprintf(bj, sizeof(buffer[0]),"%d", a);
      break;
      
      case KEY_MARK_DIST:
      case KEY_MARK_LAY_DIST:
      negNum = false;
      if (currentState != 1  && t->key == KEY_MARK_LAY_DIST)
        bj[0] = '\000';
      else
        {
        a = (int)t->value->int32;
        negNum = (a < 0);
        a = abs(a);
        b = a / 18.52;
        bool bf = isBigField((int)t->key);
        if (a < 1000) // Less than 1000m - just show m
          snprintf(bj, sizeof(buffer[0]), "%d", a);
        else if (b < 1000 || bf) // less than 100nm or it's a big field - show nm.n
          {
          int d1, d2, d3;
          d1 = (int)b/100;
          d2 = (((int)b % 100)/10);
          d3 = ((((int)b % 10) > 4) ? 1 : 0);
          if (d3 == 1)
            d2 += 1;
          if (d2 == 10)
            {
            d1 += 1;
            d2 = 0;
          }
          snprintf(bj, sizeof(buffer[0]), "%d.%d", d1, d2);
        }
        else
            {
            snprintf(bj, sizeof(buffer[0]), "%d", (int)b/10);
        }
      }
      break;
      
      case KEY_LAY_SEL:
      //APP_LOG(APP_LOG_LEVEL_INFO, "Key %d Value %d", (int)t->key, (int)t->value->int32);
      negNum = false;
      snprintf(bj, sizeof(buffer[0]),"%s", layDecode[(int)t->value->int32]);
      break;
      
      /* These are the turn style values - Rnn & Lnn */
      case KEY_MARK_TURN:
      case KEY_TACK_HEADER:
      negNum = false;
      if (currentState != 1 && t-> key == KEY_TACK_HEADER)
        bj[0] = '\000';
      else
        {
//        if (t->value->int32 >= 0)
          snprintf(bj, sizeof(buffer[0]), "%c%02d", t->value->int32 >= 0 ? 'R' : 'L', abs((int)t->value->int32));
//        else
//          snprintf(buffer[j], sizeof(buffer[j]), "L%02d", -(int)(t->value->int32));
      }
      break;
      
      case KEY_CURRENT_MARK:
      weAreRacing = true; //This data only arrives once the start is over, we must be racing
      negNum = false;
      sa = t->value->cstring;
      sb = tmpbuf;
             // APP_LOG(APP_LOG_LEVEL_ERROR, "Mark->%s", sa);
      while (*sa != '\000') {
        *sb = *sa; // Copy the current char
        if (*sb == ':' && *(sa+1) == ':') { // Found :: don't increment b so we ignore the extra :
          sa++;
          continue;
        }
        else if (*sb == ':' && *(sa+1) == '\000') { // End of string coming up & last char was : - don't increment b - it will be zapped
          sa++;
          continue;
        }
        else {
          sa++;
          sb++;
        }
      }
      *sb = '\000';
      snprintf(bj, sizeof(buffer[0]), "%s", tmpbuf);
      break;
      
      case KEY_TACK_STATE:
      a = (int)t->value->int32;
      negNum = a < 0;
      snprintf(bj, sizeof(buffer[0]), "%d", abs((int)(t->value->int32)));
      if (currentState == 1 && a != 1) // Just detected a tack
        {
        tackLog[0] = oldTack;
        int i;
        for (i = 6; i > 0; i--) // Shuffle them all up one
          tackLog[i] = tackLog[i-1];
      }
      currentState = a;
      // Now display the log
      int k = 1; // Start the log at 1 - 0 is the current tack ready to be shuffled up
      int i = 0;
      for (i=0; i < screens[currentScreen].num_fields; i++) // Go look for TACK LOG on the screen
      {
        if (keyTitles[screens[currentScreen].field_data_map[i]].key == KEY_TACK_LOG) // Tack Log is displayed
        {
          if (tackLog[k] == 0)
            tackLogBuffer[k][0] = '\000';
          else
            snprintf(tackLogBuffer[k], sizeof(tackLogBuffer[0]), "%d", tackLog[k]);
          setField(i, false, tackLogBuffer[k]);
          fieldUpdated[i] = true;
          k++; // Step to the next tacklog entry
        }
      }
      break;
      #ifdef CONFIG_SUPPORT
      case KEY_CONFIG_BOLD: useBold = (t->value->int32 != 0);
      foundKey = false;
      receivedConfig = true;
      break;
      
      case KEY_CONFIG_RACEBOX: racebox = t->value->int32;
      foundKey = false;
      receivedConfig = true;
      break;
      
      case KEY_CONFIG_VIBEDISCONNECT: vibeDisconnect = t->value->int32;
      foundKey = false;
      receivedConfig = true;
      break;
      
      
      case KEY_CONFIG_COLOURAWA: 
      #ifdef PBL_COLOR
        colourAWA = t->value->int32 != 0;
      #endif // PBL_COLOUR
      foundKey = false;
      receivedConfig = true;
      break;

      #endif //CONFIG_SUPPORT
      default:
      APP_LOG(APP_LOG_LEVEL_ERROR, "Key %d not recognized, value %d", (int)t->key, (int)t->value->int32);
      foundKey = false;
      break;
    }
    if (foundKey) // Now look through the fields on the current screen to see if it is displayed
      {
      #ifdef CONFIG_SUPPORT
      foundAKey = true;
      #endif
      if (t->key == KEY_LINE_BURN) // Do vibrate regardless of what is displayed
              {
              if (!earlyWarnDone && t->value->int32 < 10 && t->value->int32 >0)
                {
                vibes_double_pulse ();
                earlyWarnDone = true;
              }
              else if (t->value->int32 <= 0)
                {
                if (!warnedLineBurn)
                    {
                    vibes_long_pulse();
                    warnedLineBurn = true;
                }
              }
              else
                {
                warnedLineBurn = false;
              }
            }
                
      int i;
        for (i=0; i<screens[currentScreen].num_fields; i++)
          {
          if (weAreRacing && keyTitles[screens[currentScreen].field_data_map[i]].preStart) // We are racing & we have pre-start data displayed
              doScreenTransition = true; // Force a transition if we are racing with a screen displaying prestart data
          if (keyTitles[screens[currentScreen].field_data_map[i]].key == (int)t->key) // Did we find a match?
            { // To this point we have only decoded the message into the buffer
            setField(i, negNum, bj);  // Display the data - we found a match
            fieldUpdated[i] = true;
          }
        }
    // Use next buffer - the buffer remains in use even after the data actually appears on the screen
    // So we need to use a different buffer for each message.
      j++;
    }
    t = dict_read_next(iterator); // Look for next item
  }
#ifdef CONFIG_SUPPORT    
  if (receivedConfig) {
    screenMessageTimer = 3;
    screenMessage("Configuration received");
}
  if (foundAKey) {
  // Messages are still arriving
    if (tickCounter >= 7 && vibeDisconnect)
      vibes_double_pulse();
    tickCounter = 0;
  }
#endif    
  if (weAreRacing && doScreenTransition && holdThisScreen == 0) // We are racing, are showing some prestart data & don't need to hold this screen
    {
      do // Loop around looing for the next in use screen
        {
        currentScreen = (1 + currentScreen) % NUM_SCREENS;
      } while (screens[currentScreen].num_fields == 0);
    if (currentScreen == startingScreen)
      doScreenTransition = false; // Stop looking - we're back where we started!
    updatescreen(currentScreen, NULL); 
  }
  } while (weAreRacing && doScreenTransition && holdThisScreen == 0);
  
  int VMGtoWind;
  
  if (canDoVMG) {
    VMGtoWind = mycos(M_PI * ((hdg - twd) / 180.0)) * (bs * 10);
    VMGtoWind = VMGtoWind / 10 + (VMGtoWind % 10 >=5 ? 1 : 0);
    snprintf(VMGtoWindBuffer, sizeof(VMGtoWindBuffer), "%d.%d", abs(VMGtoWind)/10, abs(VMGtoWind)%10);
  }
  
  // Post process screen fields - VMGWind, blank non-updated fields etc.
  for (ii = 0; ii < screens[currentScreen].num_fields; ii++) {
    int fieldKeyTitle = keyTitles[screens[currentScreen].field_data_map[ii]].key;
    if (canDoVMG) {
      if (fieldKeyTitle == KEY_VMG_WIND) {
        setField(ii, false, VMGtoWindBuffer);  
        fieldUpdated[ii] = true;
      }
    }
    #ifdef PBL_COLOR
    if ((fieldKeyTitle == KEY_LINE_BURN && highVMG) || (colourAWA && (fieldKeyTitle == KEY_AWA || fieldKeyTitle == KEY_TWA) && redAWA)) {
      // APP_LOG(APP_LOG_LEVEL_ERROR, "High VMG/AWA Port in post process");
      text_layer_set_text_color(s_data_layer[screens[currentScreen].field_layer_map[ii]], redTextColour); 
    }
    else if (colourAWA && (fieldKeyTitle == KEY_AWA || fieldKeyTitle == KEY_TWA) && !redAWA) {
      // APP_LOG(APP_LOG_LEVEL_ERROR, "AWA Starboard in post process");
      text_layer_set_text_color(s_data_layer[screens[currentScreen].field_layer_map[ii]], greenTextColour);       
    }
    #endif
    if (!fieldUpdated[ii])
      {
      setField(ii, false, ""); // If a field has not been updated, blank it out - it will be mapped to the wrong buffer[] element
    }
  }
  
}
Esempio n. 20
0
bool ConnectFriendWizard::validateCurrentPage()
{
    error = true;

    switch ((Page) currentId()) {
    case Page_Intro:
        break;
    case Page_Text:
    {
        std::string certstr = ui->friendCertEdit->toPlainText().toUtf8().constData();
        uint32_t cert_load_error_code;

        if (rsPeers->loadDetailsFromStringCert(certstr, peerDetails, cert_load_error_code)) {
            mCertificate = certstr;
#ifdef FRIEND_WIZARD_DEBUG
            std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;
#endif
            break;
        }
        // error message
        setField("errorMessage", tr("Certificate Load Failed") + ": \n\n" + getErrorString(cert_load_error_code)) ;
        error = false;
        break;
    }
    case Page_Cert:
    {
        QString fn = ui->friendFileNameEdit->text();
        if (QFile::exists(fn)) {
            //Todo: move read from file to p3Peers::loadCertificateFromFile

            // read from file
            std::string certstr;
            QFile CertFile(fn);
            if (CertFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
                certstr = QString(CertFile.readAll()).toStdString();
                CertFile.close();
            }

            if (certstr.empty()) {
                setField("errorMessage", QString(tr("Certificate Load Failed:can't read from file %1 ")).arg(fn) );
                error = false;
                break;
            }

            uint32_t cert_error_code;
            if (rsPeers->loadDetailsFromStringCert(certstr, peerDetails, cert_error_code)) {
                mCertificate = certstr;
#ifdef FRIEND_WIZARD_DEBUG
                std::cerr << "ConnectFriendWizard got id : " << peerDetails.id << "; gpg_id : " << peerDetails.gpg_id << std::endl;
#endif
            } else {
                setField("errorMessage", QString(tr("Certificate Load Failed:something is wrong with %1 ")).arg(fn) + ": " + getErrorString(cert_error_code));
                error = false;
            }
        } else {
            setField("errorMessage", QString(tr("Certificate Load Failed:file %1 not found")).arg(fn));
            error = false;
        }
        break;
    }
    case Page_Foff:
        break;
    case Page_Rsid:
    {
        QString rsidstring = ui->friendRsidEdit->text();

        if (rsidstring.isEmpty()) {
            return false;
        }

        // search for peer id in string
        std::string rsidstr = PeerDefs::idFromRsid(rsidstring, false);

        if (rsidstr.empty() || !rsPeers->getPeerDetails(rsidstr, peerDetails)) {
            setField("errorMessage", tr("This Peer %1 is not available in your Network").arg(rsidstring));
            error = false;
        }
        break;
    }
    case Page_Email:
    {
        QString mailaddresses = ui->addressEdit->text();
        if (mailaddresses.isEmpty()) {
            return false;
        }

        QString body = ui->inviteTextEdit->toPlainText();

        body += "\n" + GetStartedDialog::GetCutBelowText();
        body += "\n\n" + QString::fromUtf8(rsPeers->GetRetroshareInvite(false).c_str());

        sendMail (mailaddresses, ui->subjectEdit->text(), body);
    }
    break;
    case Page_ErrorMessage:
        break;
    case Page_Conclusion:
        break;
    case Page_FriendRequest:
        break;
    case Page_FriendRecommendations:
    {
        std::list<std::string> recommendIds;
        ui->frec_recommendList->selectedSslIds(recommendIds, false);

        if (recommendIds.empty()) {
            QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend for recommendation."), QMessageBox::Ok, QMessageBox::Ok);
            return false;
        }

        std::list<std::string> toIds;
        ui->frec_toList->selectedSslIds(toIds, false);

        if (toIds.empty()) {
            QMessageBox::warning(this, "RetroShare", tr("Please select at least one friend as recipient."), QMessageBox::Ok, QMessageBox::Ok);
            return false;
        }

        std::list<std::string>::iterator toId;
        for (toId = toIds.begin(); toId != toIds.end(); toId++) {
            MessageComposer::recommendFriend(recommendIds, *toId, ui->frec_messageEdit->toHtml(), true);
        }
    }
    }

    return true;
}
Esempio n. 21
0
void ConversionWizard::setAdpFileName(const QString &fileName)
{
    setField(QLatin1String("adpFileName"), fileName);
}
Esempio n. 22
0
bool ThingSpeakClient::writeField(const int field, const double val, const char *wrApiKey)
{
    setField(field,val);
    return writeFields(wrApiKey);
}
Esempio n. 23
0
void ActionScript::internalAddThing(lua_State *L, const Thing* thing, const unsigned int thingid)
{
	lua_newtable(L);
	if(dynamic_cast<const Item*>(thing)){
		const Item *item = dynamic_cast<const Item*>(thing);
		setField(L,"uid", thingid);
		setField(L,"itemid", item->getID());
		setField(L,"type", item->getItemCountOrSubtype());
		setField(L,"actionid", item->getActionId());
	}
	else if(dynamic_cast<const Creature*>(thing)){
		setField(L,"uid", thingid);
		setField(L,"itemid", 1);
		char type;
		if(dynamic_cast<const Player*>(thing)){
			type = 1;
		}
		else if(dynamic_cast<const Monster*>(thing)){
			type = 2;
		}
		else{//npc
			type = 3;
		}
		setField(L,"type", type);
		setField(L,"actionid", 0);
	}
	else{
		setField(L,"uid", 0);
		setField(L,"itemid", 0);
		setField(L,"type", 0);
		setField(L,"actionid", 0);
	}
}
Esempio n. 24
0
//------------------------------------------------------------
void RegisterIdPage::set(int row)
{
	setField("labelId", intOrgIdList.at(row));
	pidprLbl->setText(QString(codec->toUnicode("Назва підприємства : %1 ")).arg(pidprListWidget->currentItem()->text()));
}
Esempio n. 25
0
void		Packet_v1_Channel::setChannelId(field_t channelId)
{
  setField(channelId, PROTOV1_CHANNEL_CHANNELID_OFF, PROTOV1_CHANNEL_CHANNELID_SIZE);
}
Esempio n. 26
0
//Constructor
ProjectorPageWidget::ProjectorPageWidget(QWidget *parent) :
    QWizardPage(parent)
{
    //WizardPage Title
    setTitle("Projector Initialization");


    //Layout initialization
    projectorLayout = new QGridLayout(this);
    button_groupbox = new QGroupBox(this);
    spinbox_groupbox = new QGroupBox(this);
    verticalLayout = new QVBoxLayout(button_groupbox);
    formLayout = new QFormLayout(spinbox_groupbox);

    //Label initialization
    /*Deprecated
    microsecondsPerRound_label = new QLabel("us per round: ");
    */
    welcome = new QLabel("Welcome to Volvux!");
    projectorInstructions = new QLabel("First, initialize and setup the projector: ");
    ledCurrent_label = new QLabel("LED Current [mA]: ");
    ledPercentage_label = new QLabel("LED Percentage: ");
    nSlicesProjector_label = new QLabel("# Slices: ");
    projectorFrequency_label = new QLabel("Bit depth: ");
    projectorMicrosecPerFrame_label = new QLabel("us per frame: ");

    //Button initialization
    initilizeProjector = new QPushButton(button_groupbox);
    releaseProjector = new QPushButton(button_groupbox);

    //Spinbox initialization
    /*Deprecated
    microsecondsPerRound = new QSpinBox(); */
    ledCurrent = new QSpinBox();
    projectorBitDepth = new QSpinBox();
    microsecondsPerFrame = new QSpinBox();
    projectorNSlices = new QSpinBox();

    //Doublespinbox initialization
    projectorLEDPercentage = new QDoubleSpinBox();



    //Label properties settings
    QFont font;
    font.setPointSize(10);
    projectorInstructions->setFont(font);

    //Button properties settings
    //Visualized name
    initilizeProjector->setText("Initialize Projector");
    releaseProjector->setText("Release Projector");
    //Set default enabled buttons
    releaseProjector->setEnabled(false);
    //Set toolTip buttons
    releaseProjector->setToolTip("To enable it, please initialize the projector");


    //Spinbox properties settings
    /*Deprecated
    microsecondsPerRound ->setEnabled(false);*/

    //Projector LED current settings
    ledCurrent->setRange(0,10000);
    ledCurrent->setEnabled(false);
    //Bit Depth settings
    projectorBitDepth->setEnabled(false);
    //Microseconds per frame settings
    microsecondsPerFrame->setEnabled(false);
    //Number of slices settings
    projectorNSlices->setRange(0,1000);
    projectorNSlices->setValue(400);
    projectorNSlices->setEnabled(false);
    //Projector LED percentage settings
    projectorLEDPercentage->setEnabled(false);

    //DEBUG
    qDebug("%d è il mio valore di default",projectorNSlices->value());
    registerField("Slices",projectorNSlices);
    setField("Slices",projectorNSlices->value());
    qDebug("%d prima del change",field("Slices").toInt());
    //http://stackoverflow.com/questions/16565799/how-can-i-detect-the-back-button-being-pressed-in-qwizard
    QAbstractButton  *next_button = wizard()->button(QWizard::NextButton);
    QObject::connect(next_button,SIGNAL(clicked()),this, SLOT(quit()));




    //Groupbox properties settings
    button_groupbox->setTitle("Projector controls");
    spinbox_groupbox->setTitle("Settings");



    //Vertical layout buttons
    verticalLayout->addWidget(initilizeProjector);
    verticalLayout->addWidget(releaseProjector);

    //Form layout
    /*Deprecated
    formLayout->setWidget(3,QFormLayout::LabelRole, projectorFrequency_label);
    formLayout->setWidget(3,QFormLayout::FieldRole, projectorBitDepth);
    formLayout->setWidget(4,QFormLayout::LabelRole, microsecondsPerRound_label);
    formLayout->setWidget(4,QFormLayout::FieldRole, microsecondsPerRound);
    */
    formLayout->setWidget(0,QFormLayout::LabelRole, ledCurrent_label);
    formLayout->setWidget(0,QFormLayout::FieldRole, ledCurrent);
    formLayout->setWidget(1,QFormLayout::LabelRole, ledPercentage_label);
    formLayout->setWidget(1,QFormLayout::FieldRole, projectorLEDPercentage);
    formLayout->setWidget(2,QFormLayout::LabelRole, nSlicesProjector_label);
    formLayout->setWidget(2,QFormLayout::FieldRole, projectorNSlices);
    formLayout->setWidget(3,QFormLayout::LabelRole, projectorMicrosecPerFrame_label);
    formLayout->setWidget(3,QFormLayout::FieldRole, microsecondsPerFrame);

    //GridLayout Headers
    projectorLayout->addWidget(welcome,0,0);
    projectorLayout->addWidget(projectorInstructions,1,0);
    QSpacerItem* horizontalSpacer = new QSpacerItem(298, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
    projectorLayout->addItem(horizontalSpacer,0,1);
    projectorLayout->addItem(horizontalSpacer,1,1);

    //GridLayout buttons
    projectorLayout->addWidget(button_groupbox,3,0);

    //GridLayout spinbox
    //projectorLayout->addLayout(formLayout,3,1); //uncomment if you don't want to group them in a groupbox
    projectorLayout->addWidget(spinbox_groupbox,3,1); //comment if you don't want to group them in a groupbox


    //               Enable button after a signal
    QObject::connect(this->initilizeProjector,SIGNAL(clicked()),this,SLOT(onPushButtonProjectorInitializeClicked()));
    QObject::connect(this->releaseProjector,SIGNAL(clicked()),this,SLOT(onPushButtonProjectorReleaseClicked()));
    QObject::connect(this->projectorNSlices,SIGNAL(valueChanged(int)),this,SLOT(onSpinboxProjectorNSlicesChanged(int)));

    //QObject::connect(this->ui->spinBoxProjectorLEDcurrent,SIGNAL(valueChanged(int)),this,SLOT(onspinBoxProjectorLEDcurrentChanged(int)));
    //QObject::connect(this->doubleSpinBoxProjectorLEDpercentage,SIGNAL(valueChanged(double)),this,SLOT(onSpinBoxProjectorLEDpercentageChanged(double)));





    //Set Layout QWizardPage
    setLayout(projectorLayout);

}
Esempio n. 27
0
void DBQuery::setField(const char *fmt, const char *value) {
  setField(fmt, value, strlen(value));
}
Esempio n. 28
0
void TJClassRef::setField(const std::string& fieldName, const TJObjectRef& field)
{
	setField(fieldName, field.get());
}
Esempio n. 29
0
void DBQuery::setField(const char *fmt, int value) {
  setField(fmt, folly::to<std::string>(value).c_str());
}
/**
 * Checks and retrieves credentials provided by the host + does account lookup on eventually
 * renamed user accounts.
 *
 * @return  IPRT status code.
 */
int VBoxCredProvCredential::RetrieveCredentials(void)
{
    PRTUTF16 pwszUser     = NULL;
    PRTUTF16 pwszPassword = NULL;
    PRTUTF16 pwszDomain   = NULL;

    int rc = VbglR3CredentialsQueryAvailability();
    if (RT_SUCCESS(rc))
    {
        /*
         * Set status to "terminating" to let the host know this module now
         * tries to receive and use passed credentials so that credentials from
         * the host won't be sent twice.
         */
        VBoxCredProvReportStatus(VBoxGuestFacilityStatus_Terminating);

        rc = VbglR3CredentialsRetrieveUtf16(&pwszUser, &pwszPassword, &pwszDomain);

        VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Retrieved credentials with rc=%Rrc\n", rc);
    }

    if (RT_SUCCESS(rc))
    {
        VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Received credentials for user '%ls'\n", pwszUser);

        /*
         * In case we got a "display name" (e.g. "John Doe")
         * instead of the real user name (e.g. "jdoe") we have
         * to translate the data first ...
         */
        PWSTR pwszExtractedName = NULL;
        if (   TranslateAccountName(pwszUser, &pwszExtractedName)
            && pwszExtractedName)
        {
            VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Translated account name '%ls' -> '%ls'\n",
                                pwszUser, pwszExtractedName);

            RTMemWipeThoroughly(pwszUser, (RTUtf16Len(pwszUser) + 1) * sizeof(RTUTF16), 3 /* Passes */);
            RTUtf16Free(pwszUser);

            pwszUser = RTUtf16Dup(pwszExtractedName);

            CoTaskMemFree(pwszExtractedName);
            pwszExtractedName = NULL;
        }
        else
        {
            /*
             * Okay, no display name, but maybe it's a
             * principal name from which we have to extract the domain from?
             * ([email protected] -> jdoe in domain my-domain.sub.net.com.)
             */
            PWSTR pwszExtractedDomain = NULL;
            if (ExtractAccoutData(pwszUser, &pwszExtractedName, &pwszExtractedDomain))
            {
                /* Update user name. */
                if (pwszExtractedName)
                {
                    if (pwszUser)
                    {
                        RTMemWipeThoroughly(pwszUser, (RTUtf16Len(pwszUser) + 1) * sizeof(RTUTF16), 3 /* Passes */);
                        RTUtf16Free(pwszUser);
                    }

                    pwszUser = RTUtf16Dup(pwszExtractedName);

                    CoTaskMemFree(pwszExtractedName);
                    pwszExtractedName = NULL;
                }

                /* Update domain. */
                if (pwszExtractedDomain)
                {
                    if (pwszDomain)
                    {
                        RTMemWipeThoroughly(pwszDomain, (RTUtf16Len(pwszDomain) + 1) * sizeof(RTUTF16), 3 /* Passes */);
                        RTUtf16Free(pwszDomain);
                    }

                    pwszDomain = RTUtf16Dup(pwszExtractedDomain);

                    CoTaskMemFree(pwszExtractedDomain);
                    pwszExtractedDomain = NULL;
                }

                VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Extracted account name '%ls' + domain '%ls'\n",
                                    pwszUser ? pwszUser : L"<NULL>", pwszDomain ? pwszDomain : L"<NULL>");
            }
        }

        m_fHaveCreds = true;
    }

    if (m_fHaveCreds)
    {
        VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Setting fields\n");

        setField(VBOXCREDPROV_FIELDID_USERNAME,   pwszUser,     true /* fNotifyUI */);
        setField(VBOXCREDPROV_FIELDID_PASSWORD,   pwszPassword, true /* fNotifyUI */);
        setField(VBOXCREDPROV_FIELDID_DOMAINNAME, pwszDomain,   true /* fNotifyUI */);
    }

    VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Wiping ...\n");

    VbglR3CredentialsDestroyUtf16(pwszUser, pwszPassword, pwszDomain, 3 /* cPasses */);

    VBoxCredProvVerbose(0, "VBoxCredProvCredential::RetrieveCredentials: Returned rc=%Rrc\n", rc);
    return rc;
}