Пример #1
0
      // 수신을 게시합니다.
      void receive()
      {
        if (buffer_.full())
        {
          buffer_.grow();
        }

        session_.get_socket().async_receive(
          buffer_.prepare(), 
          session_.get_strand().wrap([this, self = session_.shared_from_this()](const auto& error, std::size_t transferred)
          {
            if (!error)
            {
              buffer_.commit(transferred);

              session_.internal_receive_handler(buffer_);

              receive();
            }
            else
            {// 오류 발생
              if (!disabled())
              {
                disabled(true);
                session_.internal_error_handler(error);
              }
            }
          }
        ));
      }
Пример #2
0
      void progress_sending()
      {
        const auto top = send_queue_.front();

        // @note async_write는 모든 바이트를 송신을 보장합니다.
        boost::asio::async_write(session_.get_socket(), boost::asio::buffer(top.data(), top.size()), 
          session_.get_strand().wrap([this, self = session_.shared_from_this()](const auto& error, std::size_t)
          {
            if (!error)
            {
              session_.internal_send_handler();

              send_queue_.pop_front();

              // 보낼 데이터가 남았다면 송신을 계속합니다.
              if (!send_queue_.empty())
              {
                progress_sending();
              }
            }
            else
            {// 오류 발생
              if (!disabled())
              {
                disabled(true);
                session_.internal_error_handler(error);
              }
            }
          }) // end wrap
        );
      }
Пример #3
0
void SecondaryDriveRight::set(bool mainDrive, bool secondaryDriveLeft, int leftRightCenter) { 
  if(isOn() && tooMuchCurrentDraw()) {
    _stalled = true;
  }
  if(disabled()){
    return;
  }
  int maxPowerIncrease = 30;
  int minPower = 0;
  int out = 0;

  if(!mainDrive) {
    minPower = _minPower;
    out = minPower;
  }
  int scaledTurn = leftRightCenter/maxPowerIncrease;
  if(scaledTurn > 1) {
    if(!secondaryDriveLeft) {
      out = 0 - (minPower + abs(scaledTurn));
    } else {
      out = minPower;  
    }
  } else if(scaledTurn < -1) {
    out = minPower + abs(scaledTurn);
  }

  out = map(out, -180, 180, 0, 179);
  on();
  _motor->write(out);
}
Пример #4
0
void sJarvisNodeComponent::parseEvent(QString component, jarvisEvents event, QStringList args)
{
    if(component != m_id) return;
    if      (event == E_DISABLED)
    {
        emit disabled();
    }else if(event == E_ENABLED)
    {
        emit enabled();
    }else if(event == E_ACTIVATED)
    {
        emit activated();
    }else if(event == E_DEACTIVATED)
    {
        emit deactivated();
    }else if(event == E_RAW_READ)
    {
        emit rawRead();
        emit rawRead(args);
    }else if(event == E_DATA_READ)
    {
        emit dataRead();
        emit dataRead(args);
    }else if(event == E_COFFEE_MAKING)
    {
        emit coffeeMaking();
    }else if(event == E_COFFEE_MADE)
    {
        emit coffeeMade();
    }
}
Пример #5
0
String AudioChannelSet::getDescription() const
{
    if (isDiscreteLayout())            return String ("Discrete #") + String (size());
    if (*this == disabled())           return "Disabled";
    if (*this == mono())               return "Mono";
    if (*this == stereo())             return "Stereo";
    if (*this == createLCR())          return "LCR";
    if (*this == createLRS())          return "LRS";
    if (*this == createLCRS())         return "LCRS";
    if (*this == quadraphonic())       return "Quadraphonic";
    if (*this == pentagonal())         return "Pentagonal";
    if (*this == hexagonal())          return "Hexagonal";
    if (*this == octagonal())          return "Octagonal";
    if (*this == ambisonic())          return "Ambisonic";
    if (*this == create5point0())      return "5.1 Surround";
    if (*this == create5point1())      return "5.1 Surround (+Lfe)";
    if (*this == create6point0())      return "6.1 Surround";
    if (*this == create6point0Music()) return "6.1 (Music) Surround";
    if (*this == create6point1())      return "6.1 Surround (+Lfe)";
    if (*this == create7point0())      return "7.1 Surround (Rear)";
    if (*this == create7point1())      return "7.1 Surround (Rear +Lfe)";
    if (*this == create7point1AC3())   return "7.1 AC3 Surround (Rear + Lfe)";
    if (*this == createFront7point0()) return "7.1 Surround (Front)";
    if (*this == createFront7point1()) return "7.1 Surround (Front +Lfe)";

    return "Unknown";
}
Пример #6
0
template <typename Traits> inline shared_ptr<typename detector_impl<Traits>::definition_type>
detector_impl<Traits>::parse_complex_definition(char const *name, xmlNodePtr node) const {

	typedef complex_definition<Traits> complex_type;
	shared_ptr<complex_type> parent(new complex_type(name));
	
	xml_elems elems(node, "pattern");
	for (xml_elems::const_iterator i = elems.begin(), end = elems.end(); i != end; ++i) {
		if (disabled(*i)) {
			continue;
		}
		char const *value = xml_attr_text(*i, "value"), *type = xml_attr_text(*i, "type");
		if (strncasecmp(type, "string", sizeof("string")) == 0) {
			parent->add(shared_ptr<definition_type>(new string_definition<Traits>(name, xml_node_text(*i), value)));
		}
		else if (strncasecmp(type, "regex", sizeof("regex")) == 0) {
			parent->add(shared_ptr<definition_type>(new regex_definition<Traits>(name, xml_node_text(*i), value)));
		}
		else {
			resource<xmlChar*, xml_string_traits> path(xmlGetNodePath(node));
			throw error("unknown pattern type %s in [%s]", type, (char const*) path.get());
		}
	}
	return parent->has_only_one() ? parent->release_child() : parent.template cast<definition_type>();
}
Пример #7
0
void EventTargetNode::handleLocalEvents(Event *evt, bool useCapture)
{
    if (disabled() && evt->isMouseEvent())
        return;

    EventTarget::handleLocalEvents(this, evt, useCapture);    
}
Пример #8
0
bool MemoryCache::add(CachedResource* resource)
{
    if (disabled())
        return false;

    ASSERT(WTF::isMainThread());

    CachedResourceMap& resources = getSessionMap(resource->sessionID());
#if ENABLE(CACHE_PARTITIONING)
    CachedResourceItem* originMap = resources.get(resource->url());
    if (!originMap) {
        originMap = new CachedResourceItem;
        resources.set(resource->url(), adoptPtr(originMap));
    }
    originMap->set(resource->cachePartition(), resource);
#else
    resources.set(resource->url(), resource);
#endif
    resource->setInCache(true);
    
    resourceAccessed(resource);
    
    LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource->url().string().latin1().data(), resource);
    return true;
}
Пример #9
0
bool EventTargetNode::dispatchMouseEvent(const AtomicString& eventType, int button, int detail,
    int pageX, int pageY, int screenX, int screenY,
    bool ctrlKey, bool altKey, bool shiftKey, bool metaKey, 
    bool isSimulated, Node* relatedTargetArg, PassRefPtr<Event> underlyingEvent)
{
    ASSERT(!eventDispatchForbidden());
    if (disabled()) // Don't even send DOM events for disabled controls..
        return true;
    
    if (eventType.isEmpty())
        return false; // Shouldn't happen.
    
    // Dispatching the first event can easily result in this node being destroyed.
    // Since we dispatch up to three events here, we need to make sure we're referenced
    // so the pointer will be good for the two subsequent ones.
    RefPtr<Node> protect(this);
    
    bool cancelable = eventType != eventNames().mousemoveEvent;
    
    ExceptionCode ec = 0;
    
    bool swallowEvent = false;
    
    // Attempting to dispatch with a non-EventTarget relatedTarget causes the relatedTarget to be silently ignored.
    RefPtr<EventTargetNode> relatedTarget = (relatedTargetArg && relatedTargetArg->isEventTargetNode())
        ? static_cast<EventTargetNode*>(relatedTargetArg) : 0;

    RefPtr<Event> mouseEvent = MouseEvent::create(eventType,
        true, cancelable, document()->defaultView(),
        detail, screenX, screenY, pageX, pageY,
        ctrlKey, altKey, shiftKey, metaKey, button,
        relatedTarget, 0, isSimulated);
    mouseEvent->setUnderlyingEvent(underlyingEvent.get());
    
    dispatchEvent(mouseEvent, ec, true);
    bool defaultHandled = mouseEvent->defaultHandled();
    bool defaultPrevented = mouseEvent->defaultPrevented();
    if (defaultHandled || defaultPrevented)
        swallowEvent = true;
    
    // Special case: If it's a double click event, we also send the dblclick event. This is not part
    // of the DOM specs, but is used for compatibility with the ondblclick="" attribute.  This is treated
    // as a separate event in other DOM-compliant browsers like Firefox, and so we do the same.
    if (eventType == eventNames().clickEvent && detail == 2) {
        RefPtr<Event> doubleClickEvent = MouseEvent::create(eventNames().dblclickEvent,
            true, cancelable, document()->defaultView(),
            detail, screenX, screenY, pageX, pageY,
            ctrlKey, altKey, shiftKey, metaKey, button,
            relatedTarget, 0, isSimulated);
        doubleClickEvent->setUnderlyingEvent(underlyingEvent.get());
        if (defaultHandled)
            doubleClickEvent->setDefaultHandled();
        dispatchEvent(doubleClickEvent, ec, true);
        if (doubleClickEvent->defaultHandled() || doubleClickEvent->defaultPrevented())
            swallowEvent = true;
    }

    return swallowEvent;
}
Пример #10
0
void SchedulePoint::mouseReleaseEvent(QGraphicsSceneMouseEvent *e)
{
    if(disabled())
        return;
    setZValue(0);
    pen.setColor(Qt::white);
    e->accept();
}
Пример #11
0
void MemoryCache::evictResources()
{
    if (disabled())
        return;

    setDisabled(true);
    setDisabled(false);
}
Пример #12
0
void TimersvSettings::changeState(int state) {
	if (state) {
		enable();
		emit enabled();
	} else {
		disable();
		emit disabled();
	}
}
Пример #13
0
static const char *
ipv6_enabled(void)
{
#if defined(IS_LINUX)
    return access("/proc/net/if_inet6", F_OK) == 0 ? enabled() : disabled();
#else
    return enabled();
#endif
}
Пример #14
0
bool_t query(const string_t& Extension)
{
	if(disabled().count(Extension))
		return false;

	if(enabled().count(Extension))
		return true;

	return extensions().count(Extension) ? true : false;
}
Пример #15
0
void State2Button::buttonClicked() {
	if (!state) {
		enable();
		emit enabled();
	}
	else {
		disable();
		emit disabled();
	}
}
	void timer::again()
	{
		if (disabled())
			enable(false);
		if (waiting())
			throw already_waiting();
		iTimerObject.expires_from_now(boost::posix_time::milliseconds(iDuration_ms));
		iTimerObject.async_wait(boost::bind(&handler_proxy::operator(), iHandlerProxy, boost::asio::placeholders::error));
		iWaiting = true;
	}
Пример #17
0
void device_execute_interface::interface_pre_reset()
{
	// reset the total number of cycles
	m_totalcycles = 0;

	// enable all devices (except for disabled devices)
	if (!disabled())
		resume(SUSPEND_ANY_REASON);
	else
		suspend(SUSPEND_REASON_DISABLE, true);
}
Пример #18
0
void SchedulePoint::mousePressEvent(QGraphicsSceneMouseEvent *e)
{
    if(disabled())
        return;

    // provide event handler for mouse click
    emit clicked(this);
    m_pressed = true;
    pen.setColor(Qt::black);
    setZValue(10);
    m_xClickPos = e->pos().x();
    m_yClickPos = e->pos().y();
}
void EventTargetNode::handleLocalEvents(Event* event, bool useCapture)
{
    if (disabled() && event->isMouseEvent())
        return;

    RegisteredEventListenerVector listenersCopy = eventListeners();
    size_t size = listenersCopy.size();
    for (size_t i = 0; i < size; ++i) {
        const RegisteredEventListener& r = *listenersCopy[i];
        if (r.eventType() == event->type() && r.useCapture() == useCapture && !r.removed())
            r.listener()->handleEvent(event, false);
    }
}
Пример #20
0
//render GLAttribute process.
void MGFog::exec()const{
	if(undefined()) return;
	if(disabled()){
		glDisable(GL_FOG);
		return;
	}
	glEnable(GL_FOG);
	glFogi(GL_FOG_MODE,GLfog_mode());
	glFogf(GL_FOG_START,m_start);
	glFogf(GL_FOG_END,m_end);
	glFogf(GL_FOG_DENSITY,m_density);
	const float* color=m_color.color();
	glFogfv(GL_COLOR,color);
}
Пример #21
0
template <typename Traits> inline shared_ptr<typename detector_impl<Traits>::branch_type>
detector_impl<Traits>::parse_branch(xmlNodePtr node) const {
	
	shared_ptr<branch_type> result(new branch_type());
	for (xmlNodePtr n = xmlFirstElementChild(node); 0 != n; n = xmlNextElementSibling(n)) {
		if (disabled(n)) {
			continue;
		}
		else if (xmlStrncasecmp(n->name, (xmlChar const*) "match", sizeof("match")) == 0) {
			xml_elems elems(n, "pattern");
			for (xml_elems::iterator i = elems.begin(), end = elems.end(); i != end; ++i) {
				if (disabled(*i)) {
					continue;
				}
				char const *type = xml_attr_text(*i, "type");
				if (strncasecmp(type, "string", sizeof("string")) == 0) {
					result->add_match(xml_node_text(*i));
				}
				else if (strncasecmp(type, "regex", sizeof("regex")) == 0) {
					result->add_regex_match(xml_node_text(*i));
				}
				else {
					resource<xmlChar*, xml_string_traits> path(xmlGetNodePath(*i));
					throw error("unknown pattern type %s in [%s]", type, (char const*) path.get());
				}
			}
		}
		else if (xmlStrncasecmp(n->name, (xmlChar const*) "branch", sizeof("branch")) == 0) {
			result->add_child(parse_branch(n));
		}
		else if (xmlStrncasecmp(n->name, (xmlChar const*) "define", sizeof("definition")) == 0) {
			result->add_definition(parse_definition(n));
		}
	}
	return result;
}
int PictureButton::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QAbstractButton::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: enabled(); break;
        case 1: disabled(); break;
        default: ;
        }
        _id -= 2;
    }
    return _id;
}
Пример #23
0
void MemoryCache::evictResources(SessionID sessionID)
{
    if (disabled())
        return;

    auto it = m_sessionResources.find(sessionID);
    if (it == m_sessionResources.end())
        return;
    auto& resources = *it->value;

    for (int i = 0, size = resources.size(); i < size; ++i)
        remove(*resources.begin()->value);

    ASSERT(!m_sessionResources.contains(sessionID));
}
Пример #24
0
void PHISHtmlWebKit532::imageButton() const
{
    _out+=_indent+"<button type=\"button\" class=\"phibuttontext\""
        +name()+disabled()+title()+accessKey()+tabIndex()
        +onClickUrl()+startStyle( adjustButtonSize() )+effectStyle();
    _out+="padding:0px;-webkit-appearance:button;\">\n";
    QByteArray url;
    if ( _it->imageId().startsWith( QLatin1String( "phi" ) ) )
        url="/phi.phis?phiimg="+_it->imageIdData()+"&amp;phitmp=1";
    else url="/phi.phis?phiimg="+_it->imageIdData();
    QByteArray style=" style=\"position:relative;vertical-align:middle;";
    _out+='\t';
    imageSource( url, style, _it->id()+"_phiimg", _it->toolTipData() );
    _out+=_indent+"\t<span style=\""+colorStyle()+fontStyle()
        +"\">"+_it->valueData()+"</span>\n";
    _out+=_indent+"</button>\n";
}
Пример #25
0
void PHISHtmlWebKit532::selectBox() const
{
    QByteArray font=fontStyle();
    if ( font.isNull() && _isMacOSX ) {
        QFont f=_p->font();
        font.reserve( 200 );
        font+="font-family:'"+f.family().toUtf8();
        if ( !f.lastResortFamily().isEmpty() ) font+="','"+f.lastResortFamily().toUtf8();
        font+="';";
        if ( f.pointSize() > -1 ) font+="font-size:"+QByteArray::number( f.pointSize()+1 )+"pt;";
    }
    _out+=_indent+"<select class=\"phitext\"";
    _out+=name()+title()+disabled()+accessKey()+tabIndex()
        +startStyle( adjustSelectSize() )+effectStyle()
        +font+colorStyle()+"\">\n";
    _out+=selectOptions();
    _out+=_indent+"</select>\n";
}
void ImggFormatsConvertViewQtWidget::setFormatsCombo(
    QComboBox *cbox, const std::vector<std::string> &fmts,
    const std::vector<bool> &enable) {
  cbox->clear();
  for (const auto &name : fmts) {
    cbox->addItem(QString::fromStdString(name));
  }

  if (enable.empty() || enable.size() != fmts.size())
    return;

  for (size_t fmtIdx = 0; fmtIdx < fmts.size(); fmtIdx++) {
    if (!enable[fmtIdx]) {
      // to display the text in this row as "disabled"
      QModelIndex rowIdx = cbox->model()->index(static_cast<int>(fmtIdx), 0);
      QVariant disabled(0);
      cbox->model()->setData(rowIdx, disabled, Qt::UserRole - 1);
    }
  }
}
Пример #27
0
bool MemoryCache::add(CachedResource& resource)
{
    if (disabled())
        return false;

    ASSERT(WTF::isMainThread());

#if ENABLE(CACHE_PARTITIONING)
    auto key = std::make_pair(resource.url(), resource.cachePartition());
#else
    auto& key = resource.url();
#endif
    ensureSessionResourceMap(resource.sessionID()).set(key, &resource);
    resource.setInCache(true);
    
    resourceAccessed(resource);
    
    LOG(ResourceLoading, "MemoryCache::add Added '%s', resource %p\n", resource.url().string().latin1().data(), &resource);
    return true;
}
Пример #28
0
void PHISHtmlWebKit532::button() const
{
    static QByteArray type=QByteArray::fromRawData( "-webkit-appearance:button;", 26 );
    _out+=_indent+"<input type=\"button\" class=\"phibuttontext\""+name()
        +title()+disabled()+value()+accessKey()+tabIndex()+onClickUrl()
        +startStyle( adjustButtonSize() )+colorStyle();
    if ( _isMacOSX ) {
        if ( _it->height()>35. ) _out+=type;
        QByteArray font=fontStyle();
        if ( font.isNull() ) {
            QFont f=_p->font();
            font.reserve( 200 );
            font+="font-family:'"+f.family().toUtf8();
            if ( !f.lastResortFamily().isEmpty() ) font+="','"+f.lastResortFamily().toUtf8();
            font+="';";
            if ( f.pointSize() > -1 ) font+="font-size:"+QByteArray::number( f.pointSize()+1 )+"pt;";
        }
        _out+=font;
    } else _out+=fontStyle();
    _out+=effectStyle()+_endtag;
}
Пример #29
0
void TagRenamerOptions::saveConfig(unsigned categoryNum) const
{
    // Make sure we don't use translated strings for the config file keys.

    QString typeKey = tagTypeText(false);
    if(categoryNum > 0)
        typeKey.append(QString::number(categoryNum));

    KConfigGroup config(KGlobal::config(), "FileRenamer");

    config.writeEntry(QString("%1Suffix").arg(typeKey), suffix());
    config.writeEntry(QString("%1Prefix").arg(typeKey), prefix());

    QString emptyStr;

    switch(emptyAction()) {
    case ForceEmptyInclude:
        emptyStr = "ForceEmptyInclude";
    break;

    case IgnoreEmptyTag:
        emptyStr = "IgnoreEmptyTag";
    break;

    case UseReplacementValue:
        emptyStr = "UseReplacementValue";
    break;
    }

    config.writeEntry(QString("%1EmptyAction").arg(typeKey), emptyStr);
    config.writeEntry(QString("%1EmptyText").arg(typeKey), emptyText());
    config.writeEntry(QString("%1Disabled").arg(typeKey), disabled());

    if(category() == Track)
        config.writeEntry(QString("%1TrackWidth").arg(typeKey), trackWidth());

    config.sync();
}
Пример #30
0
void SchedulePoint::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
{
    if(disabled())
        return;
    int oldTemp = temp;
    qreal oldX = pos().x();
    // provide event handler for mouse move
    emit clicked(this);
    if(m_pressed == true)
    {
        if(m_yClickPos - m_weekHeight/4 > e->pos().y())
        {
            m_yClickPos = e->pos().y();
            increaseTemp();
        }
        else if(m_yClickPos + m_weekHeight/4 < e->pos().y())
        {
            m_yClickPos = e->pos().y();
            decreaseTemp();
        }

        if(m_xClickPos - m_timeBlockWidth > e->pos().x())
        {
            //m_xClickPos = e->pos().x();
            shiftLeft();
        }
        else if(m_xClickPos + m_timeBlockWidth < e->pos().x())
        {
            //m_xClickPos = e->pos().x();
            shiftRight();
        }
    }

    emit(shareAdjustment(temp-oldTemp, pos().x()-oldX));

    e->accept();
}