inline
 T
 max() const
 {
     return startValue() < endValue()
            ? endValue()
            : startValue();
 };
 inline
 T
 min() const
 {
     return startValue() < endValue()
            ? startValue()
            : endValue();
 };
Example #3
0
void MythUIAnimation::IncrementCurrentTime(void)
{
    if (!m_active)
        return;

    int time = currentTime();
    if (direction() == Forward)
        time += GetMythMainWindow()->GetDrawInterval();
    else
        time -= GetMythMainWindow()->GetDrawInterval();

    setCurrentTime(time);

    if (endValue() == currentValue())
    {
        if (direction() == Forward)
        {
            if (m_reversible)
                setDirection(Backward);
            else if (!m_looped)
                m_active = false;
        }
    }
    else if (startValue() == currentValue())
    {
        if (direction() == Backward)
        {
            if (m_reversible)
                setDirection(Forward);
            else if (!m_looped)
                m_active = false;
        }
    }
}
void ControlManagerMainWindow::setLabelColorAlbescent(const QColor &color, const int duration)
{
	mLabelColorAnimation.stop();

	QColor endValue(200, 200, 200);
	int r = color.red(), g = color.green(), b = color.blue();
	if(r != g || g != b)
	{
		if(r >= g && r >= b)
		{
			r = 255;
			g = 170;
			b = 170;
		}
		else if(g >= r && g >= b)
		{
			r = 170;
			g = 255;
			b = 170;
		}
		else if(b >= r && b >= g)
		{
			r = 170;
			g = 170;
			b = 255;
		}
		endValue = QColor(r, g, b);
	}

	mLabelColorAnimation.setStartValue(color);
	mLabelColorAnimation.setEndValue(endValue);
	mLabelColorAnimation.setDuration(duration);
	mLabelColorAnimation.start();
}
//
// value type
//
void
GeneratorBase::doValue(IR__::ValueDef_ptr value)
{
	beginValue(value);

	IR__::ContainedSeq_var contained_seq = value->contents(CORBA__::dk_all, false);
	CORBA::ULong len = contained_seq->length();
	for(CORBA::ULong i = 0; i < len; i++)
	{
		// contained members
		if (((*contained_seq)[i])->def_kind() == CORBA__::dk_ValueMember)
		{
			IR__::ValueMemberDef_var act_member = IR__::ValueMemberDef::_narrow(((*contained_seq)[i]));
			doValueMember(act_member);
		}
	}

	endValue(value);
}
int ProgressStatus::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 8)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 8;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = app(); break;
        case 1: *reinterpret_cast< int*>(_v) = currentValue(); break;
        case 2: *reinterpret_cast< int*>(_v) = endValue(); break;
        case 3: *reinterpret_cast< QString*>(_v) = error(); break;
        case 4: *reinterpret_cast< QString*>(_v) = item(); break;
        case 5: *reinterpret_cast< QString*>(_v) = operation(); break;
        case 6: *reinterpret_cast< QString*>(_v) = units(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Example #7
0
UInt32 HTTPPacket::build(Exception& ex,UInt8* data,UInt32 size) {
	if (_data)
		return 0;
	exception.set(Exception::NIL);

	/// read data
	ReadingStep			step(CMD);
	UInt8*				current(data);
	const UInt8*		end(current+size-4); // 4 == /r/n/r/n
	const char*			signifiant(NULL);
	const char*			key(NULL);

	// headers

	for (; current <= end;++current) {

		if (memcmp(current, EXPAND("\r\n")) == 0 || memcmp(current, EXPAND("\0\n")) == 0) {

			if (!ex && signifiant) {
				// KEY = VALUE
				UInt8* endValue(current);
				while (isblank(*--endValue));
				*(endValue+1) = 0;
				if (!key) { // version case!
					String::ToNumber(signifiant+5, version);
				} else {
					headers[key] = signifiant;
					parseHeader(ex,key,signifiant);
					key = NULL;
				}
			}
			step = LEFT;
			current += 2;
			signifiant = (const char*)current;

			if (memcmp(current, EXPAND("\r\n")) == 0) {
				current += 2;
				content = current;
				current += contentLength;
				if (ex || current > (end+4))
					break; // wait next
				_data = data;
				return _size = current - data;
			}

			++current; // here no continue, the "\r\n" check is not required again
		}

		if (ex)
			continue; // try to go to "\r\n\r\n"

		// http header, byte by byte
		UInt8 byte = *current;

		if ((step == LEFT || step == CMD || step == PATH) && (isspace(byte) || byte==0)) {
			if (step == CMD) {
				if(!signifiant) // Space before signifiant
					ex.set(Exception::PROTOCOL,"Unexpected space before command");

				// by default command == GET
				if (!signifiant || (command = HTTP::ParseCommand(ex, signifiant)) == HTTP::COMMAND_UNKNOWN) {
					exception = ex;
					continue;
				}
				signifiant = NULL;
				step = PATH;
			} else if (step == PATH) {
				// parse query
				*current = 0;
				size_t filePos = Util::UnpackUrl(signifiant, path,query);
				file.setPath(file.path(),path);
				if (filePos != string::npos)
					path.erase(filePos - 1);
				else
					file.makeFolder();
				signifiant = NULL;
				step = VERSION;
			} else
				++signifiant; // for trim begin of key or value
		} else if (step > VERSION && !key && (byte == ':' || byte == 0)) {
			// KEY
			key = signifiant;
			step = LEFT;
			UInt8* endValue(current);
			while (isblank(*--endValue));
			*(endValue+1) = 0;
			signifiant = (const char*)current + 1;
		} else if (step == CMD || step == PATH || step == VERSION) {
			if (!signifiant)
				signifiant = (const char*)current;
			if (step == CMD && (current-data)>7) // not a HTTP valid packet, consumes all
				exception = ex.set(Exception::PROTOCOL, "invalid HTTP packet");
		} else
			step = RIGHT;
	}


	if (ex)
		return current - data;

	return 0;  // wait next data
}
Example #8
0
UInt32 RTSPPacket::build(Exception& ex,UInt8* data,UInt32 size) {
	if (_data)
		return 0;
	exception.set(Exception::NIL);

	/// read data
	ReadingStep			step(CMD);
	UInt8*				current(data);
	const UInt8*		end(current+size);
	const char*			signifiant(NULL);
	const char*			key(NULL);

	// headers

	for (; current <= end;++current) {

		if (memcmp(current, EXPAND("\r\n")) == 0 || memcmp(current, EXPAND("\0\n")) == 0) {

			if (!ex && signifiant) {
				// KEY = VALUE
				UInt8* endValue(current);
				while (isblank(*--endValue));
				*(endValue+1) = 0;
				if (!key) { // version case!
					String::ToNumber(signifiant+5, version);
				} else {
					headers[key] = signifiant;
					parseHeader(ex,key,signifiant);
					key = NULL;
				}
			}
			step = LEFT;
			current += 2;
			signifiant = (const char*)current;
			++current; // here no continue, the "\r\n" check is not required again
		}

		if (ex)
			continue; // try to go to "\r\n\r\n"

		// http header, byte by byte
		UInt8 byte = *current;

		if ((step == LEFT || step == CMD || step == PATH) && (isspace(byte) || byte==0)) {
			if (step == CMD) {
				if ((command = RTSP::ParseCommand(ex, signifiant)) == RTSP::COMMAND_UNKNOWN) {
					exception = ex;
					continue;
				}
				if(command == RTSP::COMMAND_DESCRIBE) // Only for DESCRIBE : content = application/sdp
					responseType = HTTP::CONTENT_APPLICATON;
				signifiant = NULL;
				step = PATH;
			} else if (step == PATH) {
				// parse query
				*current = 0;
				size_t filePos = Util::UnpackUrl(signifiant, path,query);
				url.assign(signifiant);

				// Get trackID
				if(filePos != string::npos && path.size() > 9 && String::ICompare(path.substr(filePos),"trackID=",8)==0) {
					trackID = String::ToNumber<UInt8>(ex, 0, path.substr(filePos+8));
					path.erase(filePos - 1); // remove trackID part
					filePos = path.find_last_of('/');
					if (filePos != string::npos)
						filePos++;
				}

				// Record file directory and path
				file.setPath(path);
				if (filePos != string::npos)
					path.erase(filePos - 1);
				else
					file.makeFolder();
				signifiant = NULL;
				step = VERSION;
			} else
				++signifiant; // for trim begin of key or value
		} else if (step > PATH && !key && (byte == ':' || byte == 0)) {
			// KEY
			key = signifiant;
			step = LEFT;
			UInt8* endValue(current);
			while (isblank(*--endValue));
			*(endValue+1) = 0;
			signifiant = (const char*)current + 1;
		} else if (step == CMD || step == PATH || step == VERSION) {
			if (!signifiant)
				signifiant = (const char*)current;
			if (step == CMD && (current-data)>13) // not a RTSP valid command, consumes all
				exception = ex.set(Exception::PROTOCOL, "invalid RTSP command");
		} else
			step = RIGHT;
	}

	_data = data;
	return _size = current - data;
}