Ejemplo n.º 1
0
bool Packet::check()const{
	if(this->pb){
		if(headerSize() < sizeof(BaseSize)) return false;
		if(headerSize() > Capacity) return false;
		return true;
	}
	return false;
}
Ejemplo n.º 2
0
void HeaderedWidget::resizeEvent(QResizeEvent* event)
{
  QSize headerSize(event->size());
  headerSize.setHeight(headerView->sizeHint().height());
  headerView->resize(headerSize);

  QScrollArea::resizeEvent(event);
}
Ejemplo n.º 3
0
		/**
		 * The object is serialized using the messageCallack.
		 * @note This function may return immediately.
		 */
		 virtual BareMessage * isend(const void * object, const void * user_ptr = nullptr ){
			uint64_t msg_size = headerSize() + messageCallback->serializeMessageLen(object);
			char * payload = (char*) malloc(msg_size);

			assert(payload);

			uint64_t pos = 0;

			// memset(payload, 255, msg_size);

			serializeHeader(payload, pos, msg_size);
			assert(headerSize() == pos);

			messageCallback->serializeMessage(object, payload, pos);
			assert(pos == msg_size);

			BareMessage * msg = new BareMessage(payload, msg_size, user_ptr);

			isend(msg);
			return msg;
		}		
Ejemplo n.º 4
0
/*!
 * \brief Parses the header read using the specified \a reader.
 * \throws Throws InvalidDataException if the data read from the stream is
 *         no valid frame header.
 */
void AdtsFrame::parseHeader(IoUtilities::BinaryReader &reader)
{
    m_header1 = reader.readUInt16BE();
    // check whether syncword is present
    if ((m_header1 & 0xFFF6u) != 0xFFF0u) {
        throw InvalidDataException();
    }
    m_header2 = hasCrc() ? reader.readUInt56BE() : (reader.readUInt40BE() << 16);
    // check whether frame length is ok
    if (totalSize() < headerSize()) {
        throw InvalidDataException();
    }
}
Ejemplo n.º 5
0
// ---------------------------------------------------------
// CMsgHeader::SetAndGetSizeL
//
// Calculates and sets the size for the header and returns new size as reference
// aSize. If aInit == ETrue, sets also size for the controls by calling their
// SetAndGetSizeL functions.
// ---------------------------------------------------------
//
void CMsgHeader::SetAndGetSizeL( TSize& aSize, TBool aInit )
    {
    aSize = MsgEditorCommons::MsgHeaderPane().Size();

    TInt numberOfControls( iControls->Count() );
    iMargins.iTop = 0;
    iMargins.iBottom = numberOfControls ? MsgEditorCommons::MsgBaseLineDelta() : 
                                          0;
                                          
    TInt marginsDeltaHeight = iMargins.iTop + iMargins.iBottom;
    TInt marginsDeltaWidth = iMargins.iLeft + iMargins.iRight;
    TSize headerSize( aSize.iWidth, marginsDeltaHeight );
    TSize controlSize( 0, 0 );

    controlSize.iWidth = aSize.iWidth - marginsDeltaWidth;
    CMsgBaseControl* control = NULL;
    TInt minimumHeigth = marginsDeltaHeight;

    for ( TInt cc = 0; cc < numberOfControls; cc++ )
        {
        controlSize.iHeight = aSize.iHeight;
        control = (*iControls)[cc];

        if ( aInit )
            {
            control->SetAndGetSizeL( controlSize );
            }
        else
            {
            controlSize = control->Size();
            }

        headerSize.iHeight += control->DistanceFromComponentAbove() + controlSize.iHeight /* + 1 */;
        minimumHeigth += control->DistanceFromComponentAbove() + control->MinimumSize().iHeight /* + 1 */;

        //MEBLOGGER_WRITEF(_L("MEB: CMsgHeader::SetAndGetSizeL: headerSize.iHeight %d "), headerSize.iHeight);
        }

    if ( minimumHeigth < marginsDeltaHeight )
        // make top margin higher if there is no space for the icon
        {
        TInt additionalTopMargin = marginsDeltaHeight - minimumHeigth;
        headerSize.iHeight += additionalTopMargin;
        iMargins.iTop += additionalTopMargin;
        }

    SetSizeWithoutNotification( headerSize );
    aSize = headerSize;
    }
Ejemplo n.º 6
0
bool Packet::decompress(Controller &_rctrl){
	if(!(flags() & CompressedFlag)){
		return true;
	}
	const uint32 	updatesz = updateCount() * sizeof(uint32);
	const uint32	headersize = headerSize() - updatesz;
	PacketContext	bctx(headersize);
	uint32			datasz = dl + updatesz;
	char			*pd = pb + headersize;
	
	uint32			tmpdatasz = datasz;
	char			*tmppd(pd);
	
	vdbgx(Debug::ipc, "packet before decompress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize());
	if(_rctrl.decompressPacket(bctx, tmppd, tmpdatasz)){
		if(bctx.reqbufid != (uint)-1){
			if(tmppd == pd){
				THROW_EXCEPTION("Requested buffer not returned");
			}
			tmppd -= bctx.offset;
			memcpy(tmppd, pb, headersize);
			Specific::pushBuffer(this->pb, Specific::capacityToIndex(this->bc));
			this->bc = Specific::indexToCapacity(bctx.reqbufid);
			this->pb = tmppd;
		}else{
			//on-place decompression
			if(tmppd != pd){
				THROW_EXCEPTION("Invalid buffer pointer returned");
			}
		}
		this->flags(this->flags() & (~CompressedFlag));
		this->dl += (tmpdatasz - datasz);
		vdbgx(Debug::ipc, "packet success decompress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize());
	}else{
		//decompression failed
		if(bctx.reqbufid != (uint)-1){
			if(pd == tmppd){
				THROW_EXCEPTION("Allocated buffer must be returned even on failed compression");
			}
			tmppd -= bctx.offset;
			Specific::pushBuffer(tmppd, bctx.reqbufid);
		}
		vdbgx(Debug::ipc, "packet failed decompress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize());
		return false;
	}
	return true;
}
Ejemplo n.º 7
0
bool Packet::compress(Controller &_rctrl){
	const uint32 	updatesz = updateCount() * sizeof(uint32);
	const uint32	headersize = headerSize() - updatesz;
	PacketContext	bctx(headersize);
	int32			datasz(dataSize() + updatesz);
	char			*pd(data() - updatesz);
	
	uint32			tmpdatasz(datasz);
	char			*tmppd(pd);
	
	vdbgx(Debug::ipc, "buffer before compress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize());
	if(_rctrl.compressPacket(bctx, this->bufferSize(), tmppd, tmpdatasz)){
		if(tmppd != pd){
			if(bctx.reqbufid == (uint)-1){
				THROW_EXCEPTION("Invalid buffer pointer returned");
			}
			tmppd -= bctx.offset;
			memcpy(tmppd, pb, headersize);
			Specific::pushBuffer(this->pb, Specific::capacityToIndex(this->bc));
			this->bc = Specific::indexToCapacity(bctx.reqbufid);
			this->pb = tmppd;
		}else{
			//the compression was done on-place
		}
		this->flags(this->flags() | CompressedFlag);
		this->dl -= (datasz - tmpdatasz);
		vdbgx(Debug::ipc, "buffer success compress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize());
	}else{
		if(bctx.reqbufid != (uint)-1){
			if(pd == tmppd){
				THROW_EXCEPTION("Allocated buffer must be returned even on no compression");
			}
			tmppd -= bctx.offset;
			Specific::pushBuffer(tmppd, bctx.reqbufid);
		}
		vdbgx(Debug::ipc, "buffer failed compress id = "<<this->id()<<" dl = "<<this->dl<<" size = "<<bufferSize());
	}
	optimize();
	return true;
}
Ejemplo n.º 8
0
LargeAllocation* LargeAllocation::tryCreate(Heap& heap, size_t size, Subspace* subspace)
{
    void* space = subspace->alignedMemoryAllocator()->tryAllocateAlignedMemory(alignment, headerSize() + size);
    if (!space)
        return nullptr;
    if (scribbleFreeCells())
        scribble(space, size);
    return new (NotNull, space) LargeAllocation(heap, size, subspace);
}
Ejemplo n.º 9
0
/******************************************************************************
 * Function: Kirana
 * Inputs:
 * Returns:
 * Description: Default constructor
 ******************************************************************************/

Kirana::Kirana(std::string fileNameParam="K:\Kirana Videos\2018\180215\KirImage_0001.SVF"):
	magicNumber(0),              // magic Number to read at begining ("SVF")
	imageNum(0),                 // number of images
	imageWidth(0),               // width of image in pixels
	imageHeight(0),              // height of image in pixels
	frameZeroSize(0),            // Size of frame 0
	frameZeroOffset(0),          // Frame 0 offset
	headerSize(0),               // size of header in bytes
	metaDataSize(0),             // size of meta data block (images)
	imageInfoSize(0),            // size of image info structure
	imageSeqSize(0),             // Size of image sequence
	offsetBytes(0),              //  number of bytes offset for the file
	setupDataSize(0),            // Size of xml setup block
	versionNum(0),               // Version number
	cropRowLow(0),               // The crop row value on the bottom
	cropRowHigh(0),              // The crop row value in the top
	cropColHigh(0),              // The crop value on the far right
	cropColLow(0),               // The crop value on the far left
	metaData(0),                 // Offset of meta data block
	setupData(0),                // Offset of xml setup block	
	imageInfo(0),                // Offset of image info structure
	imageSeq(0),                 // Offset for image sequence
	width(0),                    // The width of the frame in pixels
Ejemplo n.º 10
0
	size_t nextOffset() { return _offset + headerSize() + _size; }
Ejemplo n.º 11
0
void RTMFPWriter::raiseMessage() {
	bool header = true;
	bool stop = true;
	bool sent = false;
	UInt64 stage = _stageAck+1;

	for(RTMFPMessage* pMessage : _messagesSent) {
		RTMFPMessage& message(*pMessage);
		
		if(message.fragments.empty())
			break;

		// not repeat unbuffered messages
		if(!message.repeatable) {
			stage += message.fragments.size();
			header = true;
			continue;
		}
		
		/// HERE -> message repeatable AND already flushed one time!

		if(stop) {
			_band.flush(); // To repeat message, before we must send precedent waiting mesages
			stop = false;
		}

		map<UInt32,UInt64>::const_iterator itFrag=message.fragments.begin();
		UInt32 available = message.size()-itFrag->first;
	
		while(itFrag!=message.fragments.end()) {
			UInt32 contentSize = available;
			UInt32 fragment(itFrag->first);
			++itFrag;

			// Compute flags
			UInt8 flags = 0;
			if(fragment>0)
				flags |= MESSAGE_WITH_BEFOREPART; // fragmented
			if(itFrag!=message.fragments.end()) {
				flags |= MESSAGE_WITH_AFTERPART;
				contentSize = itFrag->first - fragment;
			}

			UInt32 size = contentSize+4;

			if(header)
				size+=headerSize(stage);

			// Actual sending packet is enough large? Here we send just one packet!
			if(size>_band.availableToWrite()) {
				if(!sent)
					ERROR("Raise messages on writer ",id," without sending!");
				DEBUG("Raise message on writer ",id," finishs on stage ",stage);
				return;
			}
			sent=true;

			// Write packet
			size-=3;  // type + timestamp removed, before the "writeMessage"
			flush(_band.writeMessage(header ? 0x10 : 0x11,(UInt16)size)
				,stage++,flags,header,message,fragment,contentSize);
			available -= contentSize;
			header=false;
		}
	}

	if(stop)
		_trigger.stop();
}
Ejemplo n.º 12
0
void KPaquet::setBodySize(unsigned int size)
{
	_data.resize(headerSize() + size);
}
Ejemplo n.º 13
0
 long IfdMakerNote::size() const
 {
     return headerSize() + ifd_.size() + ifd_.dataSize();
 }
Ejemplo n.º 14
0
void ZGui::CreateWindow ( QWidget * )
{
	///Set title window
	setMainWidgetTitle ( "zTextEdit" );
	
	///load lenguage
	ProgDir = getProgramDir();
	lng->ProgDir = ProgDir;
	lng->autoLoadLng();

	///Load settings
	ZConfig cfg(ProgDir+"/zTextEdit.cfg");
	cfg_fontSize = cfg.readNumEntry(QString("GUI"), QString("FontSize"), 15);
	cfg_underline = cfg.readBoolEntry(QString("GUI"), QString("Underline"), true);
	cfg_autoOpen = cfg.readBoolEntry(QString("GUI"), QString("AutoOpen"), false);
	cfg_menuCopy = cfg.readBoolEntry(QString("GUI"), QString("MenuCopyOnDial"), false);
	#ifdef MDI
	curDlg=0;
	countDlg=1;
	#endif
	if (cfg_autoOpen)
	{
		sFileName = cfg.readEntry(QString("LastFile"), QString("FileName"), "");
		sFilePath = cfg.readEntry(QString("LastFile"), QString("FilePath"), "");
	}
	cfg_chineseCodeDetect = cfg.readBoolEntry(QString("Enginea"), QString("ChineseCodeDetect"), false);
	#ifdef SELECT_CUR_LINE
	cfg_selCurLine = cfg.readBoolEntry(QString("GUI"), QString("SelCurLine"), false);
	#endif
	
	/*
	#if !( defined(EZX_ZN5) || defined(EZX_U9) || defined(EZX_Z6W) )
	cfg_infoBar = cfg.readBoolEntry(QString("GUI"), QString("InfoBar"), false);
	
	//Create info bar
	if ( cfg_infoBar )
	{
  		ZAppInfoArea *pAIA = new ZAppInfoArea(this);
  		#if defined(EZX_Z6) || defined(EZX_V8)
  		pAIA->setActArea( ZAppInfoArea::no_progress_meter );
  		#else
  		pAIA->setActArea( ZAppInfoArea::NO_PROGRESS_METER );
  		#endif
  		pAIA->setInputArea();
  		setAppInfoArea( pAIA );
	}
	#endif
	*/

	///Create main widget on window
	#ifndef MDI
	edit = new ZMultiLineEdit( this, false, 1, "ZMultiLineEdit"  );
	CHECK_PTR(edit);
	setSettingToEdit(edit);
	setContentWidget(edit);
	edit->setGeometry( ZGlobal::getContentR( false ) );
	#else
	wStack = new QWidgetStack(this);
	curDlg=0;
    zmeEditList[curDlg] = new ZMultiLineEdit( this, false, 1, "ZMultiLineEdit"  );
    dlgCapList[curDlg] = "New";
	CHECK_PTR(zmeEditList[curDlg]);
	setSettingToEdit(zmeEditList[curDlg]);
	wStack->addWidget(zmeEditList[curDlg], curDlg);
	setContentWidget(wStack);
	wStack->raiseWidget(curDlg);
	#endif
	textCode=0;

	///Create SoftKey and Menu
	ZSoftKey *softKey = new ZSoftKey ( NULL , this , this );
	
	QPixmap* pm  = new QPixmap();
	QRect rect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);	
	MainMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 );
	MainMenu->setItemSpacing(10);	
	
	///File Menu
	FileMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 );
	FileMenu->setItemSpacing(10);
	pm->load(ProgDir+ "/img/new.png");
	FileMenu->insertItem ( MENU_FIX+lng->getString("NEW"), NULL, pm, true, 0, 0 );
	pm->load(ProgDir+ "/img/open.png");	
	FileMenu->insertItem ( MENU_FIX+lng->getString("OPEN"), NULL, pm, true, 1, 1 );
	pm->load(ProgDir+ "/img/save.png");	
	FileMenu->insertItem ( MENU_FIX+lng->getString("SAVE"), NULL, pm, true, 2, 2 );
	pm->load(ProgDir+ "/img/fake.png");
	FileMenu->insertItem ( MENU_FIX+lng->getString("SAVEAS"), NULL, pm, true, 3, 3 );	
	
	FileMenu->connectItem ( 0, this, SLOT ( slot_fileNew() ) );
	FileMenu->connectItem ( 1, this, SLOT ( slot_fileOpen() ) );	
	FileMenu->connectItem ( 2, this, SLOT ( slot_fileSave() ) );
	FileMenu->connectItem ( 3, this, SLOT ( slot_fileSaveAs() ) );	

	pm->load(ProgDir+ "/img/new.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("FILE"), FileMenu, pm , true , 1, 1 );  

	///Edit Menu
	EditMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 );
	EditMenu->setItemSpacing(10);
	pm->load(ProgDir+ "/img/copy.png");
	EditMenu->insertItem ( MENU_FIX+lng->getString("COPY"), NULL, pm, true, 0, 0);
	pm->load(ProgDir+ "/img/cut.png");
	EditMenu->insertItem ( MENU_FIX+lng->getString("CUT"), NULL, pm, true, 1, 1);
	pm->load(ProgDir+ "/img/paste.png");
	EditMenu->insertItem ( MENU_FIX+lng->getString("PASTE"), NULL, pm, true, 2, 2);
	pm->load(ProgDir+ "/img/select_all.png");
	EditMenu->insertItem ( MENU_FIX+lng->getString("SELECT_ALL"), NULL, pm, true, 3, 3);
	pm->load(ProgDir+ "/img/fake.png");
	EditMenu->insertItem ( MENU_FIX+lng->getString("SELECT_BLOCK"), NULL, pm, true, 4, 4);	
	
	EditMenu->connectItem ( 0, this, SLOT ( slot_editCopy() ) );
	EditMenu->connectItem ( 1, this, SLOT ( slot_editCut() ) );
	EditMenu->connectItem ( 2, this, SLOT ( slot_editPaste() ) );
	EditMenu->connectItem ( 3, this, SLOT ( slot_editSelAll() ) );
	EditMenu->connectItem ( 4, this, SLOT ( slot_editSelectBlock() ) );
	
	pm->load(ProgDir+ "/img/edit.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("EDIT"), EditMenu, pm , true , 2, 2 );  
	
	CodeMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 );
	CodeMenu->setItemSpacing(10);
	#if !(defined(EZX_Z6) || defined(EZX_V8))
	CodeMenu->insertItem ( "UTF-8", NULL, NULL, true, 0, 0, false, true, true );	
	CodeMenu->insertItem ( "Win1251", NULL, NULL, true, 1, 1, false, true );
	CodeMenu->insertItem ( "KOI8-R", NULL, NULL, true, 2, 2, false, true );	
	CodeMenu->insertItem ( "ISO8859-1", NULL, NULL, true, 3, 3, false, true );
	CodeMenu->insertItem ( "ISO8859-2", NULL, NULL, true, 4, 4, false, true );
	CodeMenu->insertItem ( "ISO8859-5", NULL, NULL, true, 5, 5, false, true );
	CodeMenu->insertItem ( "KOI8-U", NULL, NULL, true, 6, 6, false, true );	
	CodeMenu->insertItem ( "Big5", NULL, NULL, true, 7, 7, false, true );	
	CodeMenu->insertItem ( "GBK", NULL, NULL, true, 8, 8, false, true );	
	#else
	CodeMenu->insertItem ( "UTF-8", NULL, NULL, NULL, true, true, true, 0, 0 );	
	CodeMenu->insertItem ( "Win1251", NULL, NULL, NULL, true, true, false, 1, 1 );
	CodeMenu->insertItem ( "KOI8-R", NULL, NULL, NULL, true, true, false, 2, 2 );	
	CodeMenu->insertItem ( "ISO8859-1", NULL, NULL, NULL, true, true, false, 3, 3 );
	CodeMenu->insertItem ( "ISO8859-2", NULL, NULL, NULL, true, true, false, 4, 4 );
	CodeMenu->insertItem ( "ISO8859-5", NULL, NULL, NULL, true, true, false, 5, 5 );
	CodeMenu->insertItem ( "KOI8-U", NULL, NULL, NULL, true, true, false, 6, 6 );	
	CodeMenu->insertItem ( "Big5", NULL, NULL, NULL, true, true, false, 7, 7 );
	CodeMenu->insertItem ( "GBK", NULL, NULL, NULL, true, true, false, 8, 8 );
	#endif	

	#define CODEC_COUNT 9
	connect( CodeMenu, SIGNAL( activated( int ) ), this, SLOT( slot_codecChenged( int ) ) );
	
	pm->load(ProgDir+ "/img/fake.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("CODE"), CodeMenu, pm, true , 3, 3 );  
	
	#ifdef MDI
	DlgMenu = new ZOptionsMenu ( rect, softKey, NULL, 0 );
	DlgMenu->setItemSpacing(10);	
	connect( DlgMenu, SIGNAL( activated( int ) ), this, SLOT( slot_dlgChenged( int ) ) );
	pm->load(ProgDir+ "/img/document.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("DLG"), DlgMenu, pm, true , 3, 3 ); 
	buildDlgMenu();
	#endif
	
	pm->load(ProgDir+ "/img/find.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("SEARCH"), NULL, pm, true, 4, 4 );		
	pm->load(ProgDir+ "/img/options.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("OPTION"), NULL, pm, true, 5, 5 );	
	pm->load(ProgDir+ "/img/about.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("ABOUT"), NULL, pm, true, 6, 6 );	
	pm->load(ProgDir+ "/img/exit.png");
	MainMenu->insertItem ( MENU_FIX+lng->getString("EXIT"), NULL, pm, true, 7, 7 );
	
	MainMenu->connectItem ( 4, this, SLOT ( slot_fileFind() ) );
	MainMenu->connectItem ( 5, this, SLOT ( slot_settings() ) );	
	MainMenu->connectItem ( 6, this, SLOT ( slot_about() ) );
	MainMenu->connectItem ( 7, this, SLOT ( slot_exit() ) );	
	
	softKey->setTextForOptMenuHide(lng->getString("FILE"));
	softKey->setText ( ZSoftKey::LEFT, lng->getString("FILE"), ( ZSoftKey::TEXT_PRIORITY ) 0 );
	softKey->setText ( ZSoftKey::RIGHT, lng->getString("EXIT"), ( ZSoftKey::TEXT_PRIORITY ) 0 );
	softKey->setOptMenu ( ZSoftKey::LEFT, MainMenu );
	softKey->setClickedSlot ( ZSoftKey::RIGHT, this, SLOT ( slot_exit() ) );
	
	#if defined(EZX_ZN5) || defined(EZX_U9) || defined(EZX_Z6W)
	edit->setFixedHeight( SCREEN_HEIGHT - headerSize().height() - softKey->height());
	#endif
	
	setSoftKey ( softKey );
	
	///Connect std signal
	#ifndef EZX_VE66
	connect( qApp, SIGNAL(signalRaise()), this, SLOT(slot_Raise()) );
	connect( qApp, SIGNAL(askReturnToIdle(int)), this, SLOT(slot_ReturnToIdle(int)) );	
	#endif
	
	///init peremen
	textCode = 0;
	pos = NULL;
	isMarck = false;
	
	///load file if need
	if ( !cfg_autoOpen )
		sFileName = "";	
		
	QFile file;
	if ( qApp->argc() > 1  )
	{
		sFileName = "";
		if ( file.exists(QString::fromUtf8(qApp->argv()[1])) )
			sFileName = QString::fromUtf8(qApp->argv()[1]);
		else
		if ( qApp->argc() > 2  )
			if ( file.exists(QString::fromUtf8(qApp->argv()[2])) )
				sFileName = QString::fromUtf8(qApp->argv()[2]);
		sFilePath = getFilePath(sFileName);
		sFileName = getFileName(sFileName);			
	}

	if ( sFileName.isEmpty() || sFilePath.isEmpty() )
		slot_fileNew();
	else
		load(sFilePath+sFileName);
}
Ejemplo n.º 15
0
void FlowWriter::raiseMessage() {
	list<Message*>::const_iterator it;
	bool header = true;
	bool stop = true;
	bool sent = false;
	UInt64 stage = _stageAck+1;

	for(it=_messagesSent.begin();it!=_messagesSent.end();++it) {
		Message& message(**it);
		
		if(message.fragments.empty())
			break;

		// not repeat unbuffered messages
		if(!message.repeatable) {
			stage += message.fragments.size();
			header = true;
			continue;
		}
		
		/// HERE -> message repeatable AND already flushed one time!

		if(stop) {
			_band.flush(false); // To repeat message, before we must send precedent waiting mesages
			stop = false;
		}

		std::map<UInt32,UInt64>::const_iterator 
itFrag=message.fragments.begin();
		UInt32 available;
		BinaryReader& content = message.reader(available);
		
		while(itFrag!=message.fragments.end()) {
			UInt32 contentSize = available;
			UInt32 fragment(itFrag->first);
			++itFrag;

			// Compute flags
			UInt8 flags = 0;
			if(fragment>0)
				flags |= MESSAGE_WITH_BEFOREPART; // fragmented
			if(itFrag!=message.fragments.end()) {
				flags |= MESSAGE_WITH_AFTERPART;
				contentSize = itFrag->first - fragment;
			}

			UInt32 size = contentSize+4;

			if(header)
				size+=headerSize(stage);

			// Actual sending packet is enough large? Here we send just one packet!
			if(size>_band.writer().available()) {
				if(!sent)
					ERROR("Raise messages on flowWriter %s without sending!",NumberFormatter::format(id).c_str());
				DEBUG("Raise message on flowWriter %s finishs on stage %s",NumberFormatter::format(id).c_str(),NumberFormatter::format(stage).c_str());
				return;
			}
			sent=true;

			// Write packet
			size-=3;  // type + timestamp removed, before the "writeMessage"
			flush(_band.writeMessage(header ? 0x10 : 0x11,(UInt16)size)
				,stage++,flags,header,content,contentSize);
			available -= contentSize;
			header=false;
		}
	}

	if(stop)
		_trigger.stop();
}
Ejemplo n.º 16
0
unsigned int KPaquet::totalSize()
{
	return headerSize() + bodySize();
}
Ejemplo n.º 17
0
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
void DynamicTableData::checkAndAdjustDimensions()
{
  QSize dataSize(m_TableData.size(), 0);
  QSize headerSize(m_RowHeaders.size(), m_ColHeaders.size());

  if (m_TableData.size() > 0)
  {
    dataSize.setHeight(m_TableData[0].size());
  }

  if (dataSize == headerSize)
  {
    return;
  }
  else
  {
    /* The header dimensions do not equal the data dimensions.
       The data dimensions will be used and will overwrite the current header dimensions.
       This may result in data loss.
    */
    int nRows = dataSize.width();
    int nCols = dataSize.height();

    // If row header dimension is greater than default row dimension, remove the extra headers
    if (m_RowHeaders.size() > nRows)
    {
      while (m_RowHeaders.size() > nRows)
      {
        m_RowHeaders.pop_back();
      }
    }
    // If row header dimension is less than default row dimension, add blank headers
    else
    {
      int count = m_RowHeaders.size();
      while (m_RowHeaders.size() < nRows)
      {
        m_RowHeaders.push_back(QString::number(count));
        count++;
      }
    }
    // If column header dimension is greater than default column dimension, remove the extra headers
    if (m_ColHeaders.size() > nCols)
    {
      while (m_ColHeaders.size() > nCols)
      {
        m_ColHeaders.pop_back();
      }
    }
    // If column header dimension is less than default column dimension, add blank headers
    else
    {
      int count = m_ColHeaders.size();
      while (m_ColHeaders.size() < nCols)
      {
        m_ColHeaders.push_back(QString::number(count));
        count++;
      }
    }
  }
}
Ejemplo n.º 18
0
int updateInfo(){
	sprintf(info,"PNG Drive version: %d\n", drive->version);
	sprintf(info,"%sTotal size: %d bytes.\n", info,drive->totalspace);
	sprintf(info,"%sAvailable space: %d bytes (File System header is %d bytes).\n", info,availableSpace,headerSize());
	sprintf(info,"%sNumber of files:%d\n",info,drive->filecount);
	return strlen(info);
}
Ejemplo n.º 19
0
bool SkPDFDocument::emitPDF(SkWStream* stream) {
    if (fPages.isEmpty()) {
        return false;
    }
    for (int i = 0; i < fPages.count(); i++) {
        if (fPages[i] == NULL) {
            return false;
        }
    }

    // We haven't emitted the document before if fPageTree is empty.
    if (fPageTree.isEmpty()) {
        SkPDFDict* pageTreeRoot;
        SkPDFPage::GeneratePageTree(fPages, fCatalog.get(), &fPageTree,
                                    &pageTreeRoot);
        fDocCatalog->insert("Pages", new SkPDFObjRef(pageTreeRoot))->unref();

        /* TODO(vandebo): output intent
        SkRefPtr<SkPDFDict> outputIntent = new SkPDFDict("OutputIntent");
        outputIntent->unref();  // SkRefPtr and new both took a reference.
        outputIntent->insert("S", new SkPDFName("GTS_PDFA1"))->unref();
        outputIntent->insert("OutputConditionIdentifier",
                             new SkPDFString("sRGB"))->unref();
        SkRefPtr<SkPDFArray> intentArray = new SkPDFArray;
        intentArray->unref();  // SkRefPtr and new both took a reference.
        intentArray->append(outputIntent.get());
        fDocCatalog->insert("OutputIntent", intentArray.get());
        */

        bool firstPage = true;
        for (int i = 0; i < fPages.count(); i++) {
            int resourceCount = fPageResources.count();
            fPages[i]->finalizePage(fCatalog.get(), firstPage, &fPageResources);
            addResourcesToCatalog(resourceCount, firstPage, &fPageResources,
                                  fCatalog.get());
            if (i == 0) {
                firstPage = false;
                fSecondPageFirstResourceIndex = fPageResources.count();
            }
        }

        // Build font subsetting info before proceeding.
        perform_font_subsetting(fCatalog.get(), fPages, &fSubstitutes);

        // Figure out the size of things and inform the catalog of file offsets.
        off_t fileOffset = headerSize();
        fileOffset += fCatalog->setFileOffset(fDocCatalog.get(),
                (size_t) fileOffset);
        fileOffset += fCatalog->setFileOffset(fPages[0], (size_t) fileOffset);
        fileOffset += fPages[0]->getPageSize(fCatalog.get(),
                (size_t) fileOffset);
        for (int i = 0; i < fSecondPageFirstResourceIndex; i++) {
            fileOffset += fCatalog->setFileOffset(fPageResources[i],
                                                  (size_t) fileOffset);
        }
        // Add the size of resources of substitute objects used on page 1.
        fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset, true);
        if (fPages.count() > 1) {
            // TODO(vandebo): For linearized format, save the start of the
            // first page xref table and calculate the size.
        }

        for (int i = 0; i < fPageTree.count(); i++) {
            fileOffset += fCatalog->setFileOffset(fPageTree[i],
                    (size_t) fileOffset);
        }

        for (int i = 1; i < fPages.count(); i++) {
            fileOffset += fPages[i]->getPageSize(fCatalog.get(),
                    (size_t) fileOffset);
        }

        for (int i = fSecondPageFirstResourceIndex;
                 i < fPageResources.count();
                 i++) {
            fileOffset += fCatalog->setFileOffset(fPageResources[i],
                                                  (size_t) fileOffset);
        }

        fileOffset += fCatalog->setSubstituteResourcesOffsets(fileOffset,
                                                              false);
        fXRefFileOffset = fileOffset;
    }

    emitHeader(stream);
    fDocCatalog->emitObject(stream, fCatalog.get(), true);
    fPages[0]->emitObject(stream, fCatalog.get(), true);
    fPages[0]->emitPage(stream, fCatalog.get());
    for (int i = 0; i < fSecondPageFirstResourceIndex; i++) {
        fPageResources[i]->emit(stream, fCatalog.get(), true);
    }
    fCatalog->emitSubstituteResources(stream, true);
    // TODO(vandebo): Support linearized format
    // if (fPages.size() > 1) {
    //     // TODO(vandebo): Save the file offset for the first page xref table.
    //     fCatalog->emitXrefTable(stream, true);
    // }

    for (int i = 0; i < fPageTree.count(); i++) {
        fPageTree[i]->emitObject(stream, fCatalog.get(), true);
    }

    for (int i = 1; i < fPages.count(); i++) {
        fPages[i]->emitPage(stream, fCatalog.get());
    }

    for (int i = fSecondPageFirstResourceIndex;
            i < fPageResources.count();
            i++) {
        fPageResources[i]->emit(stream, fCatalog.get(), true);
    }

    fCatalog->emitSubstituteResources(stream, false);
    int64_t objCount = fCatalog->emitXrefTable(stream, fPages.count() > 1);
    emitFooter(stream, objCount);
    return true;
}
Ejemplo n.º 20
0
void RTMFPWriter::acknowledgment(PacketReader& packet) {

	UInt64 bufferSize = packet.read7BitLongValue(); // TODO use this value in reliability mechanism?
	
	if(bufferSize==0) {
		// In fact here, we should send a 0x18 message (with id flow),
		// but it can create a loop... We prefer the following behavior
		fail("Negative acknowledgment");
		return;
	}

	UInt64 stageAckPrec = _stageAck;
	UInt64 stageReaden = packet.read7BitLongValue();
	UInt64 stage = _stageAck+1;

	if(stageReaden>_stage) {
		ERROR("Acknowledgment received ",stageReaden," superior than the current sending stage ",_stage," on writer ",id);
		_stageAck = _stage;
	} else if(stageReaden<=_stageAck) {
		// already acked
		if(packet.available()==0)
			DEBUG("Acknowledgment ",stageReaden," obsolete on writer ",id);
	} else
		_stageAck = stageReaden;

	UInt64 maxStageRecv = stageReaden;
	UInt32 pos=packet.position();

	while(packet.available()>0)
		maxStageRecv += packet.read7BitLongValue()+packet.read7BitLongValue()+2;
	if(pos != packet.position()) {
		// TRACE(stageReaden,"..x"Util::FormatHex(reader.current(),reader.available()));
		packet.reset(pos);
	}

	UInt64 lostCount = 0;
	UInt64 lostStage = 0;
	bool repeated = false;
	bool header = true;
	bool stop=false;

	auto it=_messagesSent.begin();
	while(!stop && it!=_messagesSent.end()) {
		RTMFPMessage& message(**it);

		if(message.fragments.empty()) {
			CRITIC("RTMFPMessage ",(stage+1)," is bad formatted on fowWriter ",id);
			++it;
			continue;
		}

		map<UInt32,UInt64>::iterator itFrag=message.fragments.begin();
		while(message.fragments.end()!=itFrag) {
			
			// ACK
			if(_stageAck>=stage) {
				message.fragments.erase(message.fragments.begin());
				itFrag=message.fragments.begin();
				++_ackCount;
				++stage;
				continue;
			}

			// Read lost informations
			while(!stop) {
				if(lostCount==0) {
					if(packet.available()>0) {
						lostCount = packet.read7BitLongValue()+1;
						lostStage = stageReaden+1;
						stageReaden = lostStage+lostCount+packet.read7BitLongValue();
					} else {
						stop=true;
						break;
					}
				}
				// check the range
				if(lostStage>_stage) {
					// Not yet sent
					ERROR("Lost information received ",lostStage," have not been yet sent on writer ",id);
					stop=true;
				} else if(lostStage<=_stageAck) {
					// already acked
					--lostCount;
					++lostStage;
					continue;
				}
				break;
			}
			if(stop)
				break;
			
			// lostStage > 0 and lostCount > 0

			if(lostStage!=stage) {
				if(repeated) {
					++stage;
					++itFrag;
					header=true;
				} else // No repeated, it means that past lost packet was not repeatable, we can ack this intermediate received sequence
					_stageAck = stage;
				continue;
			}

			/// Repeat message asked!
			if(!message.repeatable) {
				if(repeated) {
					++itFrag;
					++stage;
					header=true;
				} else {
					INFO("RTMFPWriter ",id," : message ",stage," lost");
					--_ackCount;
					++_lostCount;
					_stageAck = stage;
				}
				--lostCount;
				++lostStage;
				continue;
			}

			repeated = true;
			// Don't repeate before that the receiver receives the itFrag->second sending stage
			if(itFrag->second >= maxStageRecv) {
				++stage;
				header=true;
				--lostCount;
				++lostStage;
				++itFrag;
				continue;
			}

			// Repeat message

			DEBUG("RTMFPWriter ",id," : stage ",stage," repeated");
			UInt32 fragment(itFrag->first);
			itFrag->second = _stage; // Save actual stage sending to wait that the receiver gets it before to retry
			UInt32 contentSize = message.size() - fragment; // available
			++itFrag;

			// Compute flags
			UInt8 flags = 0;
			if(fragment>0)
				flags |= MESSAGE_WITH_BEFOREPART; // fragmented
			if(itFrag!=message.fragments.end()) {
				flags |= MESSAGE_WITH_AFTERPART;
				contentSize = itFrag->first - fragment;
			}

			UInt32 size = contentSize+4;
			UInt32 availableToWrite(_band.availableToWrite());
			if(!header && size>availableToWrite) {
				_band.flush();
				header=true;
			}

			if(header)
				size+=headerSize(stage);

			if(size>availableToWrite)
				_band.flush();

			// Write packet
			size-=3;  // type + timestamp removed, before the "writeMessage"
			flush(_band.writeMessage(header ? 0x10 : 0x11,(UInt16)size)
				,stage,flags,header,message,fragment,contentSize);
			header=false;
			--lostCount;
			++lostStage;
			++stage;
		}

		if(message.fragments.empty()) {
			if(message.repeatable)
				--_repeatable;
			if(_ackCount || _lostCount) {
				_qos.add(_lostCount / (_lostCount + _ackCount));
				_ackCount=_lostCount=0;
			}
			
			delete *it;
			it=_messagesSent.erase(it);
		} else
			++it;
	
	}

	if(lostCount>0 && packet.available()>0)
		ERROR("Some lost information received have not been yet sent on writer ",id);


	// rest messages repeatable?
	if(_repeatable==0)
		_trigger.stop();
	else if(_stageAck>stageAckPrec || repeated)
		_trigger.reset();
}
Ejemplo n.º 21
0
	size_t offset() { return _offset + headerSize(); }