Esempio n. 1
0
  ReflowParameters ControlPage::run() {

    uint32_t start;

    // draw the full GUI

    redrawAll();

    // go into a keypress/timeout event loop

    start=MillisecondTimer::millis();

    for(;;) {

      // each second, sample the temperature and display it

      if(MillisecondTimer::hasTimedOut(start,1000)) {
        drawTemperature();
        start=MillisecondTimer::millis();
      }

      if(_buttonPressed) {

        // interrupt handler has indicated that a button is down

        switch(_buttonId) {

          case ButtonIdentifier::LEFT:
            handleLeft();
            break;

          case ButtonIdentifier::RIGHT:
            handleRight();
            break;

          case ButtonIdentifier::OK:
            if(handleOk()) {

              // user has clicked reflow, return the parameters we gathered on this page

              ReflowParameters params;

              params.P=_p.getValue();
              params.I=_i.getValue();
              params.D=_d.getValue();
              params.Leaded=_leadedChecked;

              return params;
            }
            break;
        }

        // ready for the next press

        _buttonPressed=false;
      }
    }
  }
Esempio n. 2
0
void PrintPrepareResizeOptionsDialog::readSettings(const QString& rcname, const QString& groupName)
{
    ResizeOptionsBaseDialog::readSettings(rcname, groupName);

    KConfig config(rcname);
    KConfigGroup group = config.group(groupName);

    m_paperSizeComboBox->setCurrentIndex(group.readEntry(OPTION_PAPER_SIZE_NAME, 0));
    m_dpiComboBox->setCurrentIndex(group.readEntry(OPTION_DPI_NAME, 0));
    m_customPaperWidthInput->setValue(group.readEntry(OPTION_CUSTOM_PAPER_WIDTH_NAME, 13));
    m_customPaperHeightInput->setValue(group.readEntry(OPTION_CUSTOM_PAPTER_HEIGHT_NAME, 9));
    m_customDpiInput->setValue(group.readEntry(OPTION_CUSTOM_DPI_NAME, 300));
    m_stretchCheckBox->setChecked(group.readEntry(OPTION_STRETCH_NAME, false));
    m_customSettingsCheckBox->setChecked(group.readEntry(OPTION_CUSTOM_SETTINGS_NAME, false));

    handleOk();
}
Esempio n. 3
0
static int handleNextMessage(sender_state_t sendst,
                             struct slice *xmitSlice,
                             struct slice *rexmitSlice)
{
    int pos = pc_getConsumerPosition(sendst->rc.incoming);
    union message *msg = &sendst->rc.q[pos].msg;
    int clNo = sendst->rc.q[pos].clNo;

#if DEBUG
    flprintf("handle next message\n");
#endif

    pc_consumeAny(sendst->rc.incoming);
    switch(ntohs(msg->opCode)) {
        case CMD_OK:
            handleOk(sendst, 
                     findSlice(xmitSlice, rexmitSlice, ntohl(msg->ok.sliceNo)),
                     clNo);
            break;
        case CMD_DISCONNECT:
            handleDisconnect(sendst->rc.participantsDb, 
                             xmitSlice, rexmitSlice, clNo);
            break;          
        case CMD_RETRANSMIT:
#if DEBUG
            flprintf("Received retransmittal request for %ld from %d:\n",
                     (long) xtohl(msg->retransmit.sliceNo), clNo);
#endif
            handleRetransmit(sendst,
                             findSlice(xmitSlice, rexmitSlice,
                                       ntohl(msg->retransmit.sliceNo)),
                             clNo,
                             msg->retransmit.map,
                             msg->retransmit.rxmit);
            break;
        default:
            udpc_flprintf("Bad command %04x\n", 
                          (unsigned short) msg->opCode);
            break;
    }
    pc_consumed(sendst->rc.incoming, 1);
    pc_produce(sendst->rc.freeSpace, 1);
    return 0;
}
Esempio n. 4
0
void ResizeOptionsBaseDialog::slotOk()
{
    // first ensure that the gui handling of the subclass was ok
    bool subclassOk = handleOk();
    if (!subclassOk)
    {
        kDebug() << "subclass indicated an error in gui handling, "
                      << "stopping own handling here.";
        return;
    }

    // then handle own
    m_commandBuilder->setQuality(m_qualityInput->value());
    if (m_resizeFilterComboBox->currentText() == m_defaultFilterName)
    {
        m_commandBuilder->setFilterName("");
    }
    else
    {
        m_commandBuilder->setFilterName(m_resizeFilterComboBox->currentText());
    }

    accept();
}
Esempio n. 5
0
void ReflowPage::run() {

    uint32_t start;

    // start off with a full page redraw

    redrawAll();

    // go into a keypress/timeout event loop

    start=MillisecondTimer::millis();

    for(;;) {

        // if we're cooking then the reflow object needs to get updated

        if(_mode==COOKING) {

            // update the reflow controller and stop the process when it's finished or aborted

            switch(_reflow->update()) {

            case Reflow::STOP:
                stopReflow();
                break;

            case Reflow::UPDATED:
                plotProgress();
                break;

            default:
                break;
            }
        }

        // each second, sample the temperature and display it
        // if we're cooking, show the power output

        if(MillisecondTimer::hasTimedOut(start,1000)) {
            drawTemperatureButton();

            if(_mode==COOKING)
                drawPowerRectangle();

            start=MillisecondTimer::millis();
        }

        // check if any of the buttons has been pressed

        if(_buttonPressed) {

            // take action depending on which button it was

            switch(_buttonId) {

            case ButtonIdentifier::LEFT:
                handleDirection();
                break;

            case ButtonIdentifier::RIGHT:
                handleDirection();
                break;

            case ButtonIdentifier::OK:
                if(handleOk())
                    return;

                break;
            }

            // ready for the next press

            _buttonPressed=false;
        }
    }
}
Esempio n. 6
0
bool HTTPCookieAuth::processLogin(HTTPRequestPtr& http_request, TCPConnectionPtr& tcp_conn)
{
	// strip off trailing slash if the request has one
	std::string resource(HTTPServer::stripTrailingSlash(http_request->getResource()));

	if (resource != m_login && resource != m_logout) {
		return false; // no login processing done
	}

	std::string redirect_url = HTTPTypes::url_decode(http_request->getQuery("url"));
	std::string new_cookie;
	bool delete_cookie = false;

	if (resource == m_login) {
		// process login
		// check username
		std::string username = HTTPTypes::url_decode(http_request->getQuery("user"));
		std::string password = HTTPTypes::url_decode(http_request->getQuery("pass"));

		// match username/password
		PionUserPtr user=m_user_manager->getUser(username,password);
		if (!user) { // authentication failed, process as in case of failed authentication...
			handleUnauthorized(http_request,tcp_conn);
			return true;
		}
		// ok we have a new user session, create  a new cookie, add to cache

		// create random cookie
		std::string rand_binary;
		rand_binary.reserve(RANDOM_COOKIE_BYTES);
		for (unsigned int i=0; i<RANDOM_COOKIE_BYTES ; i++) {
			rand_binary += static_cast<unsigned char>(m_random_die());
		}
		HTTPTypes::base64_encode(rand_binary, new_cookie);

		// add new session to cache
		PionDateTime time_now(boost::posix_time::second_clock::universal_time());
		boost::mutex::scoped_lock cache_lock(m_cache_mutex);
		m_user_cache.insert(std::make_pair(new_cookie,std::make_pair(time_now,user)));
	} else {
		// process logout sequence
		// if auth cookie presented - clean cache out
		const std::string auth_cookie(http_request->getCookie(AUTH_COOKIE_NAME));
		if (! auth_cookie.empty()) {
			boost::mutex::scoped_lock cache_lock(m_cache_mutex);
			PionUserCache::iterator user_cache_itr=m_user_cache.find(auth_cookie);
			if (user_cache_itr!=m_user_cache.end()) {
				m_user_cache.erase(user_cache_itr);
			}
		}
		// and remove cookie from browser
		delete_cookie = true;
	}
	
	// if redirect defined - send redirect
	if (! redirect_url.empty()) {
		handleRedirection(http_request,tcp_conn,redirect_url,new_cookie,delete_cookie);
	} else {
		// otherwise - OK
		handleOk(http_request,tcp_conn,new_cookie,delete_cookie);
	}

	// yes, we processed login/logout somehow
	return true;
}