Logo Search packages:      
Sourcecode: katalog version File versions  Download package

int Katalog::initDocument ( const KURL &  url  ) 

Init the document for further operations

Definition at line 100 of file katalog.cpp.

References m_changed, m_document, and m_rootElement.

{
  QString tmpfile;
  QIODevice * dev = 0L;
  bool newFile = FALSE;
  if( !url.isEmpty() && NetAccess::download( url, tmpfile ) )
  {
    dev = KFilterDev::deviceForFile( tmpfile, "application/x-gzip");
    if(!dev->open( IO_ReadOnly ))
      return UNREADABLE_URL;
  }
  else
    newFile = TRUE;
  
  m_document = QDomDocument();
  if(newFile)
  {
    QDomImplementation implementation;
    m_document = implementation.createDocument(
                   QString::null,
                   ROOT, 
                   implementation.createDocumentType(DOC_TYPE, QString::null, QString::null));
    m_rootElement = m_document.firstChild().toElement();
  }
  else
  {
    int Line;
    int Col;
    QString str;
    if ( !dev || 
         !m_document.setContent( dev, true, &str, &Line, &Col ) ||
         m_document.doctype().name().compare(DOC_TYPE))
    {
      dev->close();
      NetAccess::removeTempFile( tmpfile );
      return NOT_KATALOG;
    }
      
    dev->close();
    NetAccess::removeTempFile( tmpfile );
      
    QDomNode node = m_document.firstChild();
    
    if(node.isNull() || node.nodeName() != ROOT)
      return UNCOMPLETE;
    
    m_rootElement = node.toElement();
  }
  
  m_changed = false;

  return SUCCESS;
}


Generated by  Doxygen 1.6.0   Back to index