Пример #1
0
int existeAtributo(char *nomeTabela, column *c){
    int erro, x, count;
    struct fs_objects objeto;
    memset(&objeto, 0, sizeof(struct fs_objects));
    tp_table *tabela;
    tp_buffer *bufferpoll;
    column *aux = NULL;
    column *pagina = NULL;

    if(iniciaAtributos(&objeto, &tabela, &bufferpoll, nomeTabela) != SUCCESS)
        return ERRO_DE_PARAMETRO;

    erro = SUCCESS;
    for(x = 0; erro == SUCCESS; x++)
        erro = colocaTuplaBuffer(bufferpoll, x, tabela, objeto);

    pagina = getPage(bufferpoll, tabela, objeto, 0);

    if(pagina == NULL){
        pagina = getPage(bufferpoll, tabela, objeto, 1);
    }

    if(pagina != NULL){
        count = 0;
        for(x = 0; x < objeto.qtdCampos; x++){
            if (!pagina[x].nomeCampo) continue;
            for(aux = c; aux != NULL; aux=aux->next) {
                if (!aux->nomeCampo) continue;
                if(objcmp(pagina[x].nomeCampo, aux->nomeCampo) == 0)
                    count++;
            }
        }
        if(count != objeto.qtdCampos){
            free(pagina);
            free(bufferpoll);
            free(tabela);
            return ERRO_DE_PARAMETRO;
        }
    }

    free(pagina);
    free(bufferpoll);
    free(tabela);
    return SUCCESS;
}
Пример #2
0
void copyPages(PAGE ** a_new, PAGE ** a_old, int n_old){
	int i;
	PAGE * tmp;
	PAGE * p_act;
	for(i=0 ; i<n_old ; i++)
		if(a_old[i] != NULL)
			for(p_act=a_old[i] ; p_act != NULL ; p_act = p_act -> p_next)
				(tmp = getPage(p_act -> name)) -> users = p_act -> users;
}
/**
  * Allocates a free physical page of memory.
  * This is chosen using a round robin algorithm, to even out the wear on the physical device.
  * @return NULL on error, page address on success
  */
uint32_t* MicroBitFileSystem::getFreePage()
{
    // Walk the file table, starting at the last allocated block, looking for an unused page.
    int blocksPerPage = (PAGE_SIZE / MBFS_BLOCK_SIZE);

    // get a handle on the next physical page.
    uint16_t currentPage = getBlockNumber(getPage(lastBlockAllocated));
    uint16_t page = (currentPage + blocksPerPage) % fileSystemSize;
    uint16_t recyclablePage = 0;

    // Walk around the file table, looking for a free page.
    while (page != currentPage)
    {
        bool empty = true;
        bool deleted = false;
        uint16_t next;

        for (int i = 0; i < blocksPerPage; i++)
        {
            next = getNextFileBlock(page + i);
            
            if (next == MBFS_DELETED)
                deleted = true;
            
            else if (next != MBFS_UNUSED)
            {
                empty = false;
                break;
            }
        }

        // See if we found one...
        if (empty)
        {
            lastBlockAllocated = page;
            return getBlock(page);
        }

        // make note of the first unused but un-erased page we find (if any).
        if (deleted && !recyclablePage)
            recyclablePage = page;

        page = (page + blocksPerPage) % fileSystemSize;
    }

    // No empty pages are available, but we may be able to recycle one.
    if (recyclablePage)
    {
        uint32_t *address = getBlock(recyclablePage);
        flash.erase_page(address);
        return address;
    }

    // Nothing available at all. Use the default.
    flash.erase_page(defaultScratchPage);
    return defaultScratchPage;
}
Пример #4
0
void fp_EndnoteContainer::clearScreen(void)
{
	UT_DEBUGMSG(("Clearscreen on Endnote container %p , height = %d \n",this,getHeight()));
	fl_ContainerLayout * pCL = static_cast<fl_ContainerLayout *>(getSectionLayout());
	pCL->setNeedsRedraw();
	if(!m_bOnPage)
	{
		return;
	}
	if(m_bCleared)
	{
		return;
	}
	if(getColumn() && (getHeight() != 0))
	{
		if(getPage() == NULL)
		{
			return;
		}
		fl_DocSectionLayout * pDSL = getPage()->getOwningSection();
		if(pDSL == NULL)
		{
			return;
		}
		UT_sint32 iLeftMargin = pDSL->getLeftMargin();
		UT_sint32 iRightMargin = pDSL->getRightMargin();
		UT_sint32 iWidth = getPage()->getWidth();
		iWidth = iWidth - iLeftMargin - iRightMargin;
		UT_sint32 xoff,yoff;
		static_cast<fp_Column *>(getColumn())->getScreenOffsets(this,xoff,yoff);
		UT_sint32 srcX = getX();
		UT_sint32 srcY = getY();
		getFillType()->Fill(getGraphics(),srcX,srcY,xoff,yoff,iWidth,getHeight());
	}
	fp_Container * pCon = NULL;
	UT_sint32 i = 0;
	for(i=0; i< countCons(); i++)
	{
		xxx_UT_DEBUGMSG(("Clear screen on container %d in endnote \n",i));
		pCon = static_cast<fp_Container *>(getNthCon(i));
		pCon->clearScreen();
	}
	m_bCleared = true;
}
Пример #5
0
void IdeVoteEditor::onInit()
{
	ControlBase::onInit();

	m_values->setID(_S("values"));

	m_values->addOption(getPage()->getText(_S("vote_editor.votes.null")), _S(""));
	for(uint32 i = OS_PORTAL_OBJECT_VOTE_MIN; i <= OS_PORTAL_OBJECT_VOTE_MAX; i+=2)
	{
		String value = conversions::to_utf16<uint32>(i);
		m_values->addOption(getPage()->getText(_S("vote_editor.votes.") + value), value);
	}
	
	m_update->setCaption(getPage()->getText(_S("vote_editor.vote.caption")));
	m_update->setID(_S("update"));

	getControls()->add(m_values);
	getControls()->add(m_update);
}
Пример #6
0
void XsltTransformViewer::onLoad()
{
	ViewerBase::onLoad();

	shared_ptr<XMLNode> root = getModuleDocument()->getRoot();
	if(root != nullptr)
	{
		String xmlStr = root->getAttributeString(OS_MODULES_XSLTTRANSFORM_XML);
		String xslStr = root->getAttributeString(OS_MODULES_XSLTTRANSFORM_XSL);
		String xsdStr = root->getAttributeString(OS_MODULES_XSLTTRANSFORM_XSD);

		shared_ptr<XMLDocument> document;

		if(xsdStr.empty())
		{
			document.reset(OS_NEW XMLDocument());
		}
		else
		{
			shared_ptr<XMLSchema> xsd(OS_NEW XMLSchema());
			xsd->parseString(xsdStr);

			document.reset(OS_NEW XMLDocument(xsd));
		}

		if(document->parseString(xmlStr))
		{
			shared_ptr<XMLStylesheet> transformer(OS_NEW XMLStylesheet());
			// Inizializza le funzioni del template
			getPage()->initStylesheet(transformer);

			if(transformer->parseString(xslStr))
			{
				String output;
				if(transformer->applyToString(document, output))
				{
					getControls()->add(shared_ptr<HtmlLiteral>(OS_NEW HtmlLiteral(getPage()->parseOml(output, true, false, false, omlRenderModeOsiris, getInstance().getString()))));
				}
			}
		}
	}
}
Пример #7
0
/*!
 * Draw the frame handles
 */
void  fp_FrameContainer::drawHandles(dg_DrawArgs * pDA)
{
        if(getView() == NULL)
	{
	     getSectionLayout()->format();
	     getSectionLayout()->setNeedsReformat(getSectionLayout());
	}
        if(getView() == NULL)
	{
	     return;
	}
	if(!getPage())
	{
	     return;
	}
	//
	// Only fill to the bottom of the viewed page.
	//
	GR_Graphics * pG = pDA->pG;
	UT_sint32 iFullHeight = getFullHeight();
	fl_DocSectionLayout * pDSL = getDocSectionLayout();
	UT_sint32 iMaxHeight = 0;
	if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (getView()->getViewMode() != VIEW_PRINT))
	{
	    iMaxHeight = pDSL->getActualColumnHeight();
	}
	else
	{
	    iMaxHeight = getPage()->getHeight();
	}
	UT_sint32 iBot = getFullY()+iFullHeight;
	if(iBot > iMaxHeight)
	{
	    iFullHeight = iFullHeight - (iBot-iMaxHeight);
	}
	UT_sint32 iXlow = pDA->xoff - m_iXpad;
	UT_sint32 iYlow = pDA->yoff - m_iYpad;

	UT_Rect box(iXlow + pDA->pG->tlu(2), iYlow + pDA->pG->tlu(2), getFullWidth() - pDA->pG->tlu(4), iFullHeight - pDA->pG->tlu(4));
	getPage()->expandDamageRect(box.left,box.top,box.width,box.height);
	getView()->drawSelectionBox(box, true);
}
Пример #8
0
void fp_FrameContainer::setHeight(UT_sint32 iY)
{
        if(iY != getFullHeight())
	{
	     xxx_UT_DEBUGMSG((" SetHeight Frame iY %d Fullheight %d Height %d \n",iY,getFullHeight(),getHeight()));
	     clearScreen();
	     fp_VerticalContainer::setHeight(iY);
	     fp_Page * pPage = getPage();
	     getDocSectionLayout()->setNeedsSectionBreak(true,pPage);
	}
}
Пример #9
0
void TPalette::erasePage(int index) {
  Page *page = getPage(index);
  if (!page) return;
  m_pages.erase(m_pages.begin() + index);
  int i;
  for (i = 0; i < getPageCount(); i++) m_pages[i]->m_index = i;
  for (i                                = 0; i < page->getStyleCount(); i++)
    m_styles[page->getStyleId(i)].first = 0;
  page->m_palette                       = 0;
  delete page;
}
//-----------------------------------------------------------------------
PagingLandScapeTile* PagingLandScapePageManager::getTileUnscaled(Real posx, Real posz, bool alwaysAnswer)
{
  unsigned int pagex, pagez;
  if (alwaysAnswer) {
    unsigned int tilex, tilez;
    getNearestPageIndicesUnscaled(posx, posz, pagex, pagez);
    getNearestTileIndicesUnscaled(posx, posz, pagex, pagez, tilex, tilez);
    return getPage(pagex, pagez)->getTile(tilex, tilez);
  } else {
    if (getRealPageIndicesUnscaled(posx, posz, pagex, pagez)) {
      unsigned int tilex, tilez;
      if (getRealTileIndicesUnscaled(posx, posz, pagex, pagez, tilex, tilez)) {
        PagingLandScapePage * const p = getPage(pagex, pagez, false);
        if (p)
          return p->getTile(tilex, tilez);
      }
    }
  }
  return 0;
}
Пример #11
0
unsigned long long Cache::
get(long long offset)
{
    Page* page = getPage(offset);
    if (!page)
    {
        return 0;
    }
    page->fill(backingStore);
    return page->getAddress() | Page::PTEVALID;
}
Пример #12
0
void fp_EndnoteContainer::layout(void)
{
	_setMaxContainerHeight(0);
	UT_sint32 iY = 0, iPrevY = 0;
	iY= 0;
	UT_uint32 iCountContainers = countCons();
	fp_Container *pContainer, *pPrevContainer = NULL;
	for (UT_uint32 i=0; i < iCountContainers; i++)
	{
		pContainer = static_cast<fp_Container*>(getNthCon(i));
//
// This is to speedup redraws.
//
		if(pContainer->getHeight() > _getMaxContainerHeight())
			_setMaxContainerHeight(pContainer->getHeight());

		if(pContainer->getY() != iY)
		{
			pContainer->clearScreen();
		}
			
		pContainer->setY(iY);
		UT_sint32 iContainerHeight = pContainer->getHeight();
		UT_sint32 iContainerMarginAfter = pContainer->getMarginAfter();
		if (pPrevContainer)
		{
			pPrevContainer->setAssignedScreenHeight(iY - iPrevY);
		}
		iPrevY = iY;

		iY += iContainerHeight;
		iY += iContainerMarginAfter;
		pPrevContainer = pContainer;
	}

	// Correct height position of the last line
	if (pPrevContainer)
	{
		pPrevContainer->setAssignedScreenHeight(iY - iPrevY + 1);
	}

	UT_sint32 iNewHeight = iY;

	if (getHeight() == iNewHeight)
	{
		return;
	}
	setHeight(iNewHeight);
	fl_EndnoteLayout * pEL = static_cast<fl_EndnoteLayout *>(getSectionLayout());
	FL_DocLayout * pDL = pEL->getDocLayout();
	fl_DocSectionLayout * pDSL = pDL->getDocSecForEndnote(this);
	fp_Page * pPage = getPage();
	pDSL->setNeedsSectionBreak(true,pPage);
}
Пример #13
0
void SearchEditor::onInit()
{
	EditorBase::onInit();

	m_rssBody->addOption(getPage()->getText(_S("plugins.components.modules.search.rssBody.full")), _S("full"));
	m_rssBody->addOption(getPage()->getText(_S("plugins.components.modules.search.rssBody.link")), _S("link"));
	m_rssBody->addOption(getPage()->getText(_S("plugins.components.modules.search.rssBody.none")), _S("none"));

	shared_ptr<XMLNode> root = getModuleDocument()->getRoot();

	if(root != nullptr)
	{
		m_query->readXml(root);

		m_showParams->setCheck(root->getAttributeBool(m_showParams->getID()));
		m_directRun->setCheck(root->getAttributeBool(m_directRun->getID()));
		m_allowRss->setCheck(root->getAttributeBool(m_allowRss->getID()));	
		m_rssDescription->setValue(root->getAttributeString(m_rssDescription->getID()));	
		m_rssBody->setValue(root->getAttributeString(m_rssBody->getID()));	
	}
}
void SpectralLibraryMatchResults::elementDeleted(Subject& subject, const std::string& signal, const boost::any& value)
{
   RasterElement* pRaster = dynamic_cast<RasterElement*>(&subject);
   if (pRaster != NULL)
   {
      ResultsPage* pPage = getPage(pRaster);
      if (pPage != NULL)
      {
         deletePage(pRaster);
      }
   }
}
Пример #15
0
void fp_FootnoteContainer::clearScreen(void)
{
	if(getPage() == NULL)
	{
		return;
	}
	UT_sint32 pos = getPage()->findFootnoteContainer(this);
	if(pos == 0)
	{
		fl_DocSectionLayout * pDSL = getPage()->getOwningSection();
		const UT_RGBColor * pBGColor = getFillType()->getColor();
		UT_sint32 iLeftMargin = pDSL->getLeftMargin();
		UT_sint32 iRightMargin = pDSL->getRightMargin();
//		UT_sint32 diff = getPage()->getWidth()/10;
		UT_sint32 diff = 0; // FIXME make a property
		UT_sint32 xoff,yoff;
		getPage()->getScreenOffsets(this,xoff,yoff);
		UT_sint32 xoffStart = xoff  + diff;
		UT_sint32 width = (getPage()->getWidth() - iLeftMargin -iRightMargin)/3;
		UT_sint32 xoffEnd = xoff + width;

		getGraphics()->setColor(*pBGColor);
		UT_sint32 iLineThick = pDSL->getFootnoteLineThickness();
		getGraphics()->setLineWidth(iLineThick);
		UT_sint32 yline = yoff;
		yline = yline - iLineThick - 4; // FIXME This should not be a magic numer!
		xxx_UT_DEBUGMSG(("fp_TableContainer: clearScreen (%d,%d) to (%d,%d) \n",xoffStart,yline,xoffEnd,yline));
		UT_sint32 srcX = getX() + diff -1;
		UT_sint32 srcY = getY() - iLineThick -4;
		getFillType()->Fill(getGraphics(),srcX,srcY,xoffStart-1, yline, xoffEnd-xoffStart +2, iLineThick+1);
	}

	fp_Container * pCon = NULL;
	UT_sint32 i = 0;
	for(i=0; i< countCons(); i++)
	{
		pCon = static_cast<fp_Container *>(getNthCon(i));
		pCon->clearScreen();
	}
}
Пример #16
0
void PreferencesDialog::showPage(const QString &page)
{
    QStringList parts=page.split(QLatin1Char(':'));
    if (setCurrentPage(parts.at(0))) {
        if (parts.count()>1) {
            QWidget *cur=getPage(parts.at(0));
            if (qobject_cast<InterfaceSettings *>(cur)) {
                static_cast<InterfaceSettings *>(cur)->showPage(parts.at(1));
            }
        }
    }
    Utils::raiseWindow(this);
}
Пример #17
0
void ExtensionsInvalidModule::onLoad()
{
	ViewerBase::onLoad();

	/*
	shared_ptr<HtmlImage> img(OS_NEW HtmlImage(getPage()->getSkin()->getImageUrl(_S("invalid_module.png"))));
	setCss(_S("os_modules_invalid"));
	img->getAttributes()->set(_S("data-os-tooltip"), getPage()->getText(_S("system.invalid_module")) + _S(": ") + m_module.toUTF16());
	getControls()->add(img);
	*/	
	setCss(_S("os_modules_invalid"));
	getControls()->add(shared_ptr<HtmlText>(OS_NEW HtmlText(getPage()->getText(_S("system.invalid_module")))));
}
Пример #18
0
void fp_AnnotationContainer::clearScreen(void)
{
	if(getPage() == NULL)
	{
		return;
	}
	fp_Container * pCon = NULL;
	if(getColumn() && (getHeight() != 0))
	{
		if(getPage() == NULL)
		{
			return;
		}
		fl_DocSectionLayout * pDSL = getPage()->getOwningSection();
		if(pDSL == NULL)
		{
			return;
		}
		UT_sint32 iLeftMargin = pDSL->getLeftMargin();
		UT_sint32 iRightMargin = pDSL->getRightMargin();
		UT_sint32 iWidth = getPage()->getWidth();
		iWidth = iWidth - iLeftMargin - iRightMargin;
		UT_sint32 xoff,yoff;
		pCon = static_cast<fp_Container *>(getNthCon(0));
		if(pCon == NULL)
		  return;
		getScreenOffsets(pCon,xoff,yoff);
		UT_sint32 srcX = getX();
		UT_sint32 srcY = getY();
		getFillType()->Fill(getGraphics(),srcX,srcY,xoff-m_iLabelWidth,yoff,iWidth,getHeight());
	}
	UT_sint32 i = 0;
	for(i=0; i< countCons(); i++)
	{
		pCon = static_cast<fp_Container *>(getNthCon(i));
		pCon->clearScreen();
	}
}
Пример #19
0
static void
describe_HelpScreen (ScreenDescription *description) {
  const HelpPageEntry *page = getPage();

  if (page) {
    description->posx = page->cursorColumn;
    description->posy = page->cursorRow;
    description->cols = page->lineLength;
    description->rows = page->lineCount;
    description->number = currentVirtualTerminal_HelpScreen();
  } else {
    description->unreadable = gettext("help screen not readable");
  }
}
Пример #20
0
void MycosmosController::downloadPage(){
    //    QString urlString = "http://www.google.gr";
    QString urlString = "http://mail.mycosmos.gr/mycosmos/login.aspx";

    //        QUrl urliki(urlString);
    //        QString refererUrl = NULL;

    //        QNetworkRequest nRequest(urlString);
    //        addRequestHeaders(nRequest,refererUrl);

    //        nManager->get(nRequest);
    getPage(urlString,urlString);

}
Пример #21
0
void MybbFeedRequest::checkLogin() {
    QNetworkReply *reply = qobject_cast<QNetworkReply*>(sender());

    if (!reply) {
        setErrorString(tr("Network error"));
        setStatus(Error);
        emit finished(this);
        return;
    }

    QString redirect = getRedirect(reply);

    if (!redirect.isEmpty()) {
        reply->deleteLater();
        
        if (m_redirects < MAX_REDIRECTS) {
            followRedirect(redirect, SLOT(checkLogin()));
        }
        else {
            setErrorString(tr("Maximum redirects reached"));
            setStatus(Error);
            emit finished(this);
        }
        
        return;
    }
        
    switch (reply->error()) {
    case QNetworkReply::NoError:
#ifdef MYBB_DEBUG
        qDebug() << "MybbFeedRequest::checkLogin(). OK";
#endif
        getPage(m_settings.value("url").toString());
        reply->deleteLater();
        break;
    case QNetworkReply::OperationCanceledError:
        setErrorString(QString());
        setStatus(Canceled);
        emit finished(this);
        break;
    default:
#ifdef MYBB_DEBUG
        qDebug() << "MybbFeedRequest::checkLogin(). Error";
#endif
        setErrorString(reply->errorString());
        setStatus(Error);
        emit finished(this);
        break;
    }
}
Пример #22
0
//--------------------------------------------------------------------------
// ExtendedRead_Page:
//
// Read a extended page from the current Eprom Touch Memory.
// The record will be placed into a (uchar) memory location
// starting at the location pointed to by (buf).  This function will 
// read a page out of normal memory.  If the page being read is
// redirected then an error is returned
// The following return codes will be provided to the caller:
//
// portnum    the port number of the port being used for the
//            1-Wire Network.
// SNum       the serial number for the part that the read is
//            to be done on.
// buff       the buffer for the data that was read
// pg         the page that starts the read
//
// return TRUE if the read was successful.
//  
SMALLINT ExtendedRead_Page(int portnum, uchar *SNum, uchar *buff, PAGE_TYPE pg)               
{    
	SMALLINT  bank;
   PAGE_TYPE page;
	uchar     extra[20]; 
   int       len,i;
                     
	bank = getBank(portnum,SNum,pg,REGMEM);
	page = getPage(portnum,SNum,pg,REGMEM);
	
	if(!owIsWriteOnce(bank,portnum,SNum) && ((SNum[0] != 0x18) && 
      (SNum[0] != 0x33) && (SNum[0] != 0xB3)) )
	{
		OWERROR(OWERROR_NOT_WRITE_ONCE);
		return FALSE;
	}
	
   // check on the program job to see if this page is in it 
   if(isJob(portnum,SNum))
   {      
      if(getJobData(portnum,SNum,pg,&buff[1],&len))
      {
         return TRUE;
      }
   }     
  
   if(owIsWriteOnce(bank,portnum,SNum))
   {
      if(!owReadPageExtraCRC(bank,portnum,SNum,page,&buff[0],&extra[0]))
     	   return FALSE;    
   }
   else
   {
      if(!owReadPageExtra(bank,portnum,SNum,page,FALSE,&buff[0],&extra[0]))
         return FALSE;

      for(i=0;i<owGetExtraInfoLength(bank,SNum);i++)
         buff[i+32] = extra[i];

      extra[0] = 0xFF;
   }

	if(extra[0] != 0xFF)
	{
		OWERROR(OWERROR_REDIRECTED_PAGE);
		return FALSE;
	}
   	
   return TRUE;
}
Пример #23
0
/*!
 * Draw the frame boundaries
 */
void  fp_FrameContainer::drawBoundaries(dg_DrawArgs * pDA)
{
	UT_sint32 iXlow = pDA->xoff - m_iXpad;
	UT_sint32 iXhigh = iXlow + getFullWidth() ;
	UT_sint32 iYlow = pDA->yoff - m_iYpad;
	UT_sint32 iYhigh = iYlow + getFullHeight();
	GR_Graphics * pG = pDA->pG;
	if(getPage())
	{
		getPage()->expandDamageRect(iXlow,iYlow,getFullWidth(),getFullHeight());

		//
		// Only fill to the bottom of the viewed page.
		//
		UT_sint32 iFullHeight = getFullHeight();
		fl_DocSectionLayout * pDSL = getDocSectionLayout();
		UT_sint32 iMaxHeight = 0;
		if(!pG->queryProperties(GR_Graphics::DGP_PAPER) && (getView()->getViewMode() != VIEW_PRINT))
		{
		        iMaxHeight = pDSL->getActualColumnHeight();
		}
		else
		{
		        iMaxHeight = getPage()->getHeight();
		}
		UT_sint32 iBot = getFullY()+iFullHeight;
		if(iBot > iMaxHeight)
		{
		        iFullHeight = iFullHeight - (iBot-iMaxHeight);
			iYhigh = iFullHeight;
		}
	}
	_drawLine(m_lineTop,iXlow,iYlow,iXhigh,iYlow,pDA->pG); // top
	_drawLine(m_lineRight,iXhigh,iYlow,iXhigh,iYhigh,pDA->pG); // right
	_drawLine(m_lineBottom,iXlow,iYhigh,iXhigh,iYhigh,pDA->pG); // bottom
	_drawLine(m_lineLeft,iXlow,iYlow,iXlow,iYhigh,pDA->pG); // left
}
Пример #24
0
uint32_t AssetFileCache::readDataFromPage ( char* buf, uint32_t size )
{
    uint32_t maxFromPage = ( pageSize - ( pos % pageSize ) );

    uint32_t bytesToRead;

    if ( size > maxFromPage )
    {
        bytesToRead = maxFromPage;
    }
    else
    {
        bytesToRead = size;
    }

    uint32_t pageNbr = posToPageNbr ( pos );

    Page *page = pages[pageNbr];
    page->lastAccess = time;

    // Check if page is already cached
    if ( page->pageData )
    {
        // LOGI ( "USING CACHE asset = %p, data = %p", asset, page->pageData->data );
    }
    else
    {

        // Get a data block and cache the data
        PageData *data = getPage();
        AAsset_seek ( asset, pageNbr * pageSize, SEEK_SET );
        AAsset_read ( asset, data->data, pageSize );
        // LOGI ( "CACHE MISS asset = %p, Cached data at %p", asset,  data->data );
        page->pageData = data;
        //printBytes( data->data, 50 );
    }


    char * dataSource =  page->pageData->data + ( pos % pageSize );
    //LOGI("buf = %p, dataSource = %p, bytes = %d", buf, dataSource, bytesToRead);
    memcpy ( buf, dataSource, bytesToRead );

    // printBytes( buf, 50 );

    pos += bytesToRead;

    return bytesToRead;

}
Пример #25
0
void IdeMailBox::onReadAllMessages(IEvent *e)
{
	HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e);
	if(htmlEvent == nullptr)
		return;

	MessageFolder folder = conversions::from_utf16<MessageFolder>(htmlEvent->get(0));
	if(folder != messageFolderNone)
	{
		// Marca tutti i messaggi del folder specificato come letti
		getPortal()->getMessenger()->changeMessagesStatus(getPage()->getDatabase(), getSessionAccount(), folder, messageStatusRead);
		// Effettua il render del folder
		_renderFolder(folder);
	}
}
Пример #26
0
void IdeMailBox::onRestoreMessage(IEvent *e)
{
	HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e);
	if(htmlEvent == nullptr)
		return;

	ObjectID id = htmlEvent->get(0).to_ascii();
	if(id.empty() == false)
	{
		// Elimina il messaggio
		getPortal()->getMessenger()->moveMessageToInbox(getPage()->getDatabase(), getSessionAccount(), id);
		// Mostra la posta in arrivo
		_renderFolder(messageFolderInbox);
	}
}
Пример #27
0
void IdeMailBox::onDeleteMessage(IEvent *e)
{
	HtmlEvent *htmlEvent = dynamic_cast<HtmlEvent *>(e);
	if(htmlEvent == nullptr)
		return;

	ObjectID id = htmlEvent->get(0).to_ascii();
	if(id.empty() == false)
	{
		// Elimina il messaggio
		getPortal()->getMessenger()->moveMessageToTrash(getPage()->getDatabase(), getSessionAccount(), id);
		// Mostra la directory di riferimento
		_renderFolder(m_folder);
	}
}
Пример #28
0
/*!
 Draw container content
 \param pDA Draw arguments
 */
void fp_AnnotationContainer::draw(dg_DrawArgs* pDA)
{
	if(getPage() == NULL)
	{
		return;
	}
	fl_AnnotationLayout * pAL2 = static_cast<fl_AnnotationLayout *>(getSectionLayout());
	FL_DocLayout * pDL = pAL2->getDocLayout();
	m_iLabelWidth = 0;
	if(!pDL->displayAnnotations())
	  return;

	UT_DEBUGMSG(("Annotation: Drawing unbroken annotation %p x %d, y %d width %d height %d \n",this,getX(),getY(),getWidth(),getHeight()));

	UT_DEBUGMSG(("Annotation: Drawing PDA->xoff %d, pDA->yoff  %ld \n",pDA->xoff,pDA->yoff));

//
// Only draw the lines in the clipping region.
//
	dg_DrawArgs da = *pDA;

	UT_uint32 count = countCons();
	for (UT_uint32 i = 0; i<count; i++)
	{
		fp_ContainerObject* pContainer = static_cast<fp_ContainerObject*>(getNthCon(i));
		da.xoff = pDA->xoff + pContainer->getX();
		if(i == 0)
		{
		        fl_AnnotationLayout * pAL = static_cast<fl_AnnotationLayout *>(getSectionLayout());
			fp_AnnotationRun * pAR = pAL->getAnnotationRun();
			if(pAR)
			{		
			    m_iLabelWidth = pAR->getWidth();
      			    da.xoff = pDA->xoff + pContainer->getX() - m_iLabelWidth;
			    fp_Line * pLine = static_cast<fp_Line *>(pContainer);
			    da.yoff = pDA->yoff + pContainer->getY() + pLine->getAscent();
			    da.bDirtyRunsOnly = false;
			    m_iXLabel = da.xoff;
			    m_iYLabel = da.yoff;
			    pAR->draw(&da);
			    da.xoff = pDA->xoff + pContainer->getX();
			}
		}
		da.yoff = pDA->yoff + pContainer->getY();
		pContainer->draw(&da);
	}
	_drawBoundaries(pDA);
}
//-----------------------------------------------------------------------
void PagingLandScapePageManager::LoadFirstPage(PagingLandScapeCamera* cam)
{

  const Vector3 CamPos = cam->getDerivedPosition();
  //gets page indices (if outside Terrain gets nearest page)
  unsigned int i, j;
  getPageIndices(CamPos.x, CamPos.z, i, j, true);
  // update the camera page position
  // does modify mIniX, mFinX, mIniZ, mFinZ

  PagingLandScapePage* p = getPage(i, j, false);
  if (p) {
    mPageLoadQueue.push(p);
    p->setInQueue(PagingLandScapePage::QUEUE_LOAD);
  }
}
Пример #30
0
void WebServer::sendPage (WebClient* client) {
	unsigned int l = strlen (client -> request.url);
	if (l == 0 || client -> request.url[l - 1] == '/') {
		// Request for "/", redirect
		DPRINT (F("Redirecting to "));
		DPRINT (client -> request.url);
		DPRINTLN (F(REDIRECT_ROOT_PAGE));

		client -> print (F(HEADER_START REDIRECT_HEADER));
		if (l == 0)
			client -> print ('/');
		else
			client -> print (client -> request.url);
		client -> print (F(REDIRECT_ROOT_PAGE HEADER_END));
	} else {
		const Page *page;
		char *pagename = client -> request.get_basename ();

#if defined (WEBBINO_ENABLE_SD) || defined (WEBBINO_ENABLE_SDFAT)
		if (SD.exists (pagename)) {
			DPRINT (F("Sending page from SD file "));
			DPRINTLN (pagename);

			SDContent content = SDContent (pagename);
			sendContent (client, &content);
		} else
#endif
		if ((page = getPage (pagename))) {
			// Call page function
			PageFunction func = page -> getFunction ();
			if (func)
				func (client -> request);

			FlashContent content = FlashContent (page);
			sendContent (client, &content);
		} else {
			client -> print (F(HEADER_START NOT_FOUND_HEADER HEADER_END));

			client -> print (F("<html><body><h3>No such page: \""));
			client -> print (pagename);
			client -> print (F("\"</h3></body></html>"));
		}
	}

	client -> sendReply ();
}