Beispiel #1
0
MixClient::MixClient(std::string const& _dbPath):
	m_dbPath(_dbPath), m_miningThreads(0)
{
	std::map<Secret, u256> account;
	account.insert(std::make_pair(c_defaultUserAccountSecret, 1000000 * ether));
	resetState(account);
}
Beispiel #2
0
Enemy::Enemy()
{

  xdir = 1;
  ydir = -1;
 xdir2 = -1;
  ydir2 = 1;
 xdir3 = 1;
  ydir3 = 1;
 xdir4 = -1;
  ydir4 = -1;
 xdir5 = -1;
  ydir5 = 1;
 xdir6 = 1;
  ydir6 = 1;
  image.load("enemy.png");
  image = image.scaled(30,30,Qt::IgnoreAspectRatio,Qt::FastTransformation);
  rect = image.rect();
  rect2 = image.rect();
  rect3 = image.rect();
  rect4 = image.rect();
  rect5 = image.rect();
  rect6 = image.rect();
  resetState();

}
Beispiel #3
0
bool QPinyinImpl::commit_selection(int k)
{
        bool bUpdate = false;
        unsigned int index = ((k-'0')+9)%10;

        if(index<m_pinyin_frame->m_ime_info.candidates_on_page){
                m_pinyin_frame->m_engine.hit(m_pinyin_frame->m_ime_info.first_visible+index);
                if(m_pinyin_frame->m_engine.isPhrase()){
                        QString phrase=m_pinyin_frame->get_phrase(m_pinyin_frame->m_ime_info.first_visible+index);
                        if(m_pinyin_frame->m_bMakingPhrase){
                                m_pinyin_frame->m_ime_info.phrase+=phrase;
                        }
                        else{
                                printf("phrase unicode:");
                                for(int i=0;i<phrase.length();i++){
                                        printf("%04X,",phrase[i].unicode());
                                        SendKey(phrase[i].unicode());
                                }
                                printf("\n");
                        }
                }
                else{
                        if(m_pinyin_frame->m_bMakingPhrase){
                                m_pinyin_frame->m_ime_info.phrase+=m_pinyin_frame->get_char(m_pinyin_frame->m_ime_info.first_visible+index);
                        }
                        else{
                                SendKey(m_pinyin_frame->get_charunicode(index));

                        }
                }
                resetState();
                bUpdate=true;
        }
        return bUpdate;
}
LongLine::LongLine()
{
image.load("long_line.png");

  rect = image.rect();
  resetState();
}
Beispiel #5
0
Paddle::Paddle()
{
  	image.load("pngs/paddle.png");

  	rect = image.rect();
  	resetState();
}
Beispiel #6
0
void ndManager::slotNewFile(){
    slotStatusMsg(tr("Initializing new file..."));
    QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));

    //If no document is open already, create a new parameter file.
    if(!mainDock){
        newFile = true;
        int returnStatus = doc->newDocument();
        if(returnStatus == ndManagerDoc::PARSE_ERROR){
            QApplication::restoreOverrideCursor();
            QMessageBox::critical (this, tr("Error!"),tr("The new parameter file could not be initialize due to parsing error."));
            resetState();
            return;
        }

        const QString url = QDir::currentPath()+QDir::separator() + "Untitled";
        doc->rename(url);
        filePath = url;
        setWindowTitle(url);
    }
    //Open a new instance of the application.
    else{
        QProcess::startDetached("ndmanager");
    }
    QApplication::restoreOverrideCursor();
    slotStatusMsg(tr("Ready."));
}
void LocationInformationWidget::rejectChanges()
{
	resetState();
	emit stopFilterDiveSite();
	emit informationManagementEnded();
	emit coordinatesChanged();
}
    virtual void startClient(const QStringList &mechlist, bool allowClientSendFirst) {
        Q_UNUSED(allowClientSendFirst);

        mechanism_ = QString();
        foreach(QString mech, mechlist) {
            if (mech == "DIGEST-MD5") {
                mechanism_ = "DIGEST-MD5";
                break;
            }
#ifdef SIMPLESASL_PLAIN
            if (mech == "PLAIN" && allow_plain)
                mechanism_ = "PLAIN";
#endif
        }

        if(!capable || mechanism_.isEmpty()) {
            authCondition_ = QCA::SASL::NoMechanism;
            result_ = Error;
            if (!capable)
                qWarning("simplesasl.cpp: Not enough capabilities");
            if (mechanism_.isEmpty())
                qWarning("simplesasl.cpp: No mechanism available");
            QMetaObject::invokeMethod(this, "resultsReady", Qt::QueuedConnection);
            return;
        }

        resetState();
        result_ = Continue;
        step = 0;
        tryAgain();
    }
void LocationInformationWidget::acceptChanges()
{
	emit stopFilterDiveSite();
	char *uiString;
	struct dive_site *currentDs = get_dive_site_by_uuid(displayed_dive_site.uuid);
	currentDs->latitude = displayed_dive_site.latitude;
	currentDs->longitude = displayed_dive_site.longitude;
	uiString = ui.diveSiteName->text().toUtf8().data();
	if (!same_string(uiString, currentDs->name)) {
		free(currentDs->name);
		currentDs->name = copy_string(uiString);
	}
	uiString = ui.diveSiteDescription->text().toUtf8().data();
	if (!same_string(uiString, currentDs->description)) {
		free(currentDs->description);
		currentDs->description = copy_string(uiString);
	}
	uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data();
	if (!same_string(uiString, currentDs->notes)) {
		free(currentDs->notes);
		currentDs->notes = copy_string(uiString);
	}
	if (dive_site_is_empty(currentDs)) {
		LocationInformationModel::instance()->removeRow(get_divesite_idx(currentDs));
		displayed_dive.dive_site_uuid = 0;
	}

	mark_divelist_changed(true);
	resetState();
	emit informationManagementEnded();
	emit coordinatesChanged();
}
void LocationInformationWidget::acceptChanges()
{
	char *uiString;
	currentDs->latitude = displayed_dive_site.latitude;
	currentDs->longitude = displayed_dive_site.longitude;
	uiString = ui.diveSiteName->text().toUtf8().data();
	if (!same_string(uiString, currentDs->name)) {
		free(currentDs->name);
		currentDs->name = copy_string(uiString);
	}
	uiString = ui.diveSiteDescription->text().toUtf8().data();
	if (!same_string(uiString, currentDs->description)) {
		free(currentDs->description);
		currentDs->description = copy_string(uiString);
	}
	uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data();
	if (!same_string(uiString, currentDs->notes)) {
		free(currentDs->notes);
		currentDs->notes = copy_string(uiString);
	}
	if (dive_site_is_empty(currentDs)) {
		delete_dive_site(currentDs->uuid);
		displayed_dive.dive_site_uuid = 0;
		setLocationId(0);
	} else {
		setLocationId(currentDs->uuid);
	}
	mark_divelist_changed(true);
	resetState();
	emit informationManagementEnded();
	emit coordinatesChanged();
}
//-----------------------------------------------------------------------------
// SatAppToneProvider::playTone
//-----------------------------------------------------------------------------
void SatAppToneProvider::playTone(SatAppAction& action)
{
    qDebug("SATAPP: SatAppToneProvider::playTone >");
    resetState();
    
    mCurrentAction = &action;
    int tone = action.value(KeyToneId).toInt();
    int duration = action.value(KeyDuration).toInt();
    QString text = action.value(KeyText).toString();
    QByteArray sequence;
    mState = recognizeTone(tone,sequence,duration);
    if (mState == PlayStandardTone)
    {
        playStandardTone(text,sequence,duration);
    }
    else if (mState == PlayUserSelectedTone)
    {
        playUserSelectedTone(text,tone,duration);
    }
    else
    {
        mCurrentAction->complete(ESatCmdDataNotUnderstood);
        mCurrentAction = 0;
    }
    qDebug("SATAPP: SatAppToneProvider::playTone <");
}
Beispiel #12
0
  void setToState(const ArrayType& state) {
    resetState();
    for(size_t i = 0; i < n; ++i) {
      if(state[i])
	flip(i);
    }
  }
Beispiel #13
0
U32 LLCurl::Easy::report(CURLcode code)
{
	U32 responseCode = 0;	
	std::string responseReason;
	
	if (code == CURLE_OK)
	{
		check_curl_code(curl_easy_getinfo(mCurlEasyHandle, CURLINFO_RESPONSE_CODE, &responseCode));
		//*TODO: get reason from first line of mHeaderOutput
	}
	else
	{
		responseCode = 499;
		responseReason = strerror(code) + " : " + mErrorBuffer;
		setopt(CURLOPT_FRESH_CONNECT, TRUE);
	}

	if (mResponder)
	{	
		mResponder->completedRaw(responseCode, responseReason, mChannels, mOutput);
		mResponder = NULL;
	}
	
	resetState();
	return responseCode;
}
void JabberEditAccountWidget::apply()
{
	AccountDetails = dynamic_cast<JabberAccountDetails *>(account().details());
	if (!AccountDetails)
		return;

	account().setAccountIdentity(Identities->currentIdentity());
	account().setId(AccountId->text());
	account().setRememberPassword(RememberPassword->isChecked());
	account().setPassword(AccountPassword->text());
	account().setHasPassword(!AccountPassword->text().isEmpty());
	AccountDetails->setUseCustomHostPort(CustomHostPort->isChecked());
	AccountDetails->setCustomHost(CustomHost->text());
	AccountDetails->setCustomPort(CustomPort->text().toInt());
	AccountDetails->setEncryptionMode((JabberAccountDetails::EncryptionFlag)EncryptionMode->itemData(EncryptionMode->currentIndex()).toInt());
	AccountDetails->setPlainAuthMode((JabberAccountDetails::AllowPlainType)PlainTextAuth->itemData(PlainTextAuth->currentIndex()).toInt());
	AccountDetails->setLegacySSLProbe(LegacySSLProbe->isChecked());
	AccountDetails->setAutoResource(AutoResource->isChecked());
	AccountDetails->setResource(ResourceName->text());
	AccountDetails->setPriority(Priority->text().toInt());
	AccountDetails->setDataTransferProxy(DataTransferProxy->text());
	AccountDetails->setSendGoneNotification(SendGoneNotification->isChecked());
	AccountDetails->setSendTypingNotification(SendTypingNotification->isChecked());
	Proxy->apply();

	if (PersonalInfoWidget->isModified())
		PersonalInfoWidget->apply();

	IdentityManager::instance()->removeUnused();
	ConfigurationManager::instance()->flush();

	resetState();
}
void QKeySequenceEditPrivate::init()
{
    Q_Q(QKeySequenceEdit);

    lineEdit = new QLineEdit(q);
    lineEdit->setObjectName(QStringLiteral("qt_keysequenceedit_lineedit"));
    keyNum = 0;
    prevKey = -1;
    releaseTimer = 0;

    QVBoxLayout *layout = new QVBoxLayout(q);
    layout->setContentsMargins(0, 0, 0, 0);
    layout->addWidget(lineEdit);

    key[0] = key[1] = key[2] = key[3] = 0;

    lineEdit->setFocusProxy(q);
    lineEdit->installEventFilter(q);
    resetState();

    q->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    q->setFocusPolicy(Qt::StrongFocus);
    q->setAttribute(Qt::WA_MacShowFocusRect, true);
    q->setAttribute(Qt::WA_InputMethodEnabled, false);

    // TODO: add clear button
}
Beispiel #16
0
int main(){
    signal(SIGINT, intHandle);
    signal(SIGPIPE, SIG_IGN);

    while(1){
        initClientSocket(&hints, &res, P2host, P12port, &sfd);
        connectClientSocket(res, &sfd, 5);
        fprintf(stderr, "Connected to P2\n");

        while(1){
            int64_t n = rand() % 1024;
            int64_t sign = rand() % 2 ? -1 : 1;
            n *= sign;
            printf("%"PRId64"\n", n);
            //It's 2014 and there's no standard hton64? Am I missing something?
            int64_t data = htobe64(n);
            conStat = send(sfd, (void*)&data, sizeof(int64_t), 0);
            if(conStat <= 0){
                fprintf(stderr, "Error sending data (%d): %s\n", errno, strerror(errno));
                resetState();
                break;
            }
            usleep(250000);
        }
    }
    return 0;
}
bool OrientationFilter::init(const OrientationFilterConstants &constants)
{
    resetState();
    m_constants= constants;

    return true;
}
Beispiel #18
0
void Spacecraft::initStateVector(Vector<double> rv, Vector<double> dp)
{
    // first the size of input vector should be checked
    if(rv.size()!=6)
    {
        Exception e("Error in Spacecraft::initStateVector(): the size of rv should be 6.");
        GPSTK_THROW(e);
    }

    resetState();

    // set position
    r(0) = rv(0);
    r(1) = rv(1);
    r(2) = rv(2);

    // set velocity
    v(0) = rv(3);
    v(1) = rv(4);
    v(2) = rv(5);

    // set force model parameters
    p = dp;

    // set dr_dp0 and dv_dp0
    const int np = p.size();

    dr_dp0.resize(3*np,0.0);
    dv_dp0.resize(3*np,0.0);

}  // End of method 'Spacecraft::initStateVector()'
Beispiel #19
0
void LLCurl::Easy::prepRequest(const std::string& url,
							   const std::vector<std::string>& headers,
							   ResponderPtr responder, bool post)
{
	resetState();
	
	if (post) setoptString(CURLOPT_ENCODING, "");

//	setopt(CURLOPT_VERBOSE, 1); // usefull for debugging
	setopt(CURLOPT_NOSIGNAL, 1);

	if (LLSocks::getInstance()->isHttpProxyEnabled())
	{
		std::string address = LLSocks::getInstance()->getHTTPProxy().getIPString();
		U16 port = LLSocks::getInstance()->getHTTPProxy().getPort();
		setoptString(CURLOPT_PROXY, address.c_str());
		setopt(CURLOPT_PROXYPORT, port);
		if (LLSocks::getInstance()->getHttpProxyType() == LLPROXY_SOCKS)
		{
			setopt(CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5);
		}
		else
		{
			setopt(CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
		}
	}

	mOutput.reset(new LLBufferArray);
	setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
	setopt(CURLOPT_WRITEDATA, (void*)this);

	setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
	setopt(CURLOPT_READDATA, (void*)this);
	
	setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
	setopt(CURLOPT_HEADERDATA, (void*)this);

	setErrorBuffer();
	setCA();

	setopt(CURLOPT_SSL_VERIFYPEER, true);
	setopt(CURLOPT_TIMEOUT, CURL_REQUEST_TIMEOUT);

	setoptString(CURLOPT_URL, url);

	mResponder = responder;

	if (!post)
	{
		slist_append("Connection: keep-alive");
		slist_append("Keep-alive: 300");
		// Accept and other headers
		for (std::vector<std::string>::const_iterator iter = headers.begin();
			 iter != headers.end(); ++iter)
		{
			slist_append((*iter).c_str());
		}
	}
}
Beispiel #20
0
void QKeySequenceEditPrivate::finishEditing()
{
    Q_Q(QKeySequenceEdit);

    resetState();
    emit q->keySequenceChanged(keySequence);
    emit q->editingFinished();
}
JabberEditAccountWidget::JabberEditAccountWidget(Account account, QWidget *parent) :
		AccountEditWidget(account, parent)
{
	createGui();
	loadAccountData();
	loadAccountDetailsData();
	resetState();
}
Beispiel #22
0
/**
Constructor to load image of animal and reset its state on the board

@pre
@post
@param None
@return None
*/
Animal::Animal()
{
  randAnimal();
  image.load(picture);

  rect = image.rect();
  resetState();
}
powerupSkates::powerupSkates(): Powerup()
{
	x = rand() % 450;
	y = rand() % 550;
	image.load("Skates.png");
	rect = image.rect();
	resetState();
}
TaskManagerSchedulerTimeIntervals::TaskManagerSchedulerTimeIntervals( unsigned long* _timeIntervalsInMs , unsigned char _timeIntervalsCount , bool _isCyclic ) : dp( PSTR( "TaskManagerSchedulerTimeIntervals" ) )//: p(_p)
{
	timeIntervalsInMs = _timeIntervalsInMs;
	timeIntervalsCount = _timeIntervalsCount;
	isCyclic = _isCyclic;

	resetState();
}
bool StandardContactList::load_old()
{
    QString cfgName = ProfileManager::instance()->profilePath() + QDir::separator() + "contacts.conf";
    QFile f(cfgName);
    if (!f.open(QIODevice::ReadOnly)){
        log(L_ERROR, "[2]Can't open %s", qPrintable(cfgName));
        return false;
    }

    ParserState state;
    while(!f.atEnd())
    {
        QString line = QString::fromLocal8Bit(f.readLine());
        line = line.trimmed();
        //log(L_DEBUG, "Line: %s", qPrintable(line));
        if(line.startsWith("[Group="))
        {
            state.nextSection = ParserState::Group;
            load_old_dispatch(state);
            resetState(state);
            state.groupId = line.mid(7, line.length() - 8).toInt();
            if(state.groupId > 0)
                addGroup(createGroup(state.groupId));
        }
        else if(line.startsWith("[Contact="))
        {
            state.nextSection = ParserState::Contact;
            load_old_dispatch(state);
            resetState(state);
            state.contactId = line.mid(9, line.length() - 10).toInt();
            if(state.contactId > 0)
                addContact(createContact(state.contactId));
        }
        else if(line.startsWith("["))
        {
            state.nextSection = ParserState::Client;
            load_old_dispatch(state);
            state.dataname = line.mid(1, line.length() - 2);
        }
        else
        {
            state.data.append(line + "\n");
        }
    }
    return true;
}
Poison::Poison(): Powerup()
{
	x = rand() % 450;
	y = rand() % 550;
	image.load("Poison.png");
	rect = image.rect();
	resetState();
}
extern "C" int main(void)
{
	//state == 0: IDLE wait for scan start signal
	//state == 1: INITIATE SCAN: reset all data and start new scan
	//state == 2; scanning... transmitting data
	//state == 3: scan complete cleanup and reset to state 0
	int state = STATEIDLE;

	//Main loop
	while(1){
		//IDLE
		//Wait for command to start scanning
		if (state == STATEIDLE){
			if(checkIncomingCmd() == 1){
				if(checkPCCmd() == 1){
					sendPCStart();
					state = STATEINITIATE;
				}
			}
		//INITIATE
		}else if(state == STATEINITIATE){
			resetState();
			state = STATESCAN;
		//SCANNING
		}else if (state == STATESCAN){
			if(checkIncomingCmd() == 1){
				if(checkPCCmd() == 1){
					sendPCStart();
					state = STATEINITIATE;
				}
			}
			if(packData() == 1){
				usb_rawhid_send(data_out, 15);
			}
			if(rotation == MAXROTATION){
				state = STATEEND; 
			}
		//scan complete cleanup and reset to state 0
		}else if (state == STATEEND){
			resetState();
			sendPCEnd();
			state = STATEIDLE;
		}//STATEEND
	}//main loop
}//main
Beispiel #28
0
void LLCurl::Easy::prepRequest(const std::string& url,
							   const std::vector<std::string>& headers,
							   ResponderPtr responder, S32 time_out, bool post)
{
	resetState();
	
	if (post) setoptString(CURLOPT_ENCODING, "");

	//setopt(CURLOPT_VERBOSE, 1); // useful for debugging
	setopt(CURLOPT_NOSIGNAL, 1);

	// Set the CURL options for either Socks or HTTP proxy
	LLProxy::getInstance()->applyProxySettings(this);

	mOutput.reset(new LLBufferArray);
	mOutput->setThreaded(true);
	setopt(CURLOPT_WRITEFUNCTION, (void*)&curlWriteCallback);
	setopt(CURLOPT_WRITEDATA, (void*)this);

	setopt(CURLOPT_READFUNCTION, (void*)&curlReadCallback);
	setopt(CURLOPT_READDATA, (void*)this);
	
	setopt(CURLOPT_HEADERFUNCTION, (void*)&curlHeaderCallback);
	setopt(CURLOPT_HEADERDATA, (void*)this);

	// Allow up to five redirects
	if (responder && responder->followRedir())
	{
		setopt(CURLOPT_FOLLOWLOCATION, 1);
		setopt(CURLOPT_MAXREDIRS, MAX_REDIRECTS);
	}

	setErrorBuffer();
	setCA();

	setopt(CURLOPT_SSL_VERIFYPEER, true);
	
	//don't verify host name so urls with scrubbed host names will work (improves DNS performance)
	setopt(CURLOPT_SSL_VERIFYHOST, 0);
	setopt(CURLOPT_TIMEOUT, llmax(time_out, CURL_REQUEST_TIMEOUT));

	setoptString(CURLOPT_URL, url);

	mResponder = responder;

	if (!post)
	{
		slist_append("Connection: keep-alive");
		slist_append("Keep-alive: 300");
		// Accept and other headers
		for (std::vector<std::string>::const_iterator iter = headers.begin();
			 iter != headers.end(); ++iter)
		{
			slist_append((*iter).c_str());
		}
	}
}
void TextPlacementDelegator::mapProjectionChanged(const MapsToDrawIt& beginIt,
                                                  const MapsToDrawIt& endIt,
                                                  int trackingMode)
{
   m_impl->mapItBegin = beginIt;
   m_impl->mapItEnd = endIt;
   
   resetState();
}
void
TextPlacementDelegator::updateMaps(const MapsToDrawIt& beginIt,
                                   const MapsToDrawIt& endIt)
{
   m_impl->mapItBegin = beginIt;
   m_impl->mapItEnd = endIt;
   
   resetState();
}