Esempio n. 1
0
bool ParsedProperties::parseBlobPropertyBag(v8::Local<v8::Value> propertyBag, const char* blobClassName, v8::Isolate* isolate)
{
    ASSERT(m_endings == "transparent");

    V8TRYCATCH_RETURN(Dictionary, dictionary, Dictionary(propertyBag, isolate), false);

    V8TRYCATCH_RETURN(bool, containsEndings, dictionary.get("endings", m_endings), false);
    if (containsEndings) {
        if (m_endings != "transparent" && m_endings != "native") {
            throwTypeError(ExceptionMessages::failedToConstruct(blobClassName, "The \"endings\" property must be either \"transparent\" or \"native\"."), isolate);
            return false;
        }
    }

    V8TRYCATCH_RETURN(bool, containsType, dictionary.get("type", m_contentType), false);
    if (containsType) {
        if (!m_contentType.containsOnlyASCII()) {
            throwError(v8SyntaxError, ExceptionMessages::failedToConstruct(blobClassName, "The \"type\" property must consist of ASCII characters."), isolate);
            return false;
        }
        m_contentType = m_contentType.lower();
    }

    if (!m_hasFileProperties)
        return true;

    v8::Local<v8::Value> lastModified;
    V8TRYCATCH_RETURN(bool, containsLastModified, dictionary.get("lastModified", lastModified), false);
    if (containsLastModified) {
        V8TRYCATCH_RETURN(long long, lastModifiedInt, toInt64(lastModified), false);
        setLastModified(static_cast<double>(lastModifiedInt) / msPerSecond);
    } else {
Esempio n. 2
0
bool KraftDoc::saveDocument( )
{
    bool result = false;

    DocumentSaverBase *saver = getSaver();
    if( saver ) {
        result = saver->saveDocument( this );
        if ( isNew() ) {
          setLastModified( QDate::currentDate() );
        }

        // We go through the whole document and remove the positions
        // that are to delete because they now were deleted in the
        // database.
        DocPositionListIterator it( mPositions );
        while( it.hasNext() ) {
          DocPositionBase *dp = it.next();
          if( dp->toDelete() ) {
            kDebug() << "Removing pos " << dp->dbId().toString() << " from document object" << endl;
            mPositions.removeAll( dp );
          }
        }
        modified = false;
    }
    return result;
}
Esempio n. 3
0
void QUrlInfo_QtDShell::__override_setLastModified(const QDateTime&  dt0, bool static_call)
{
    if (static_call) {
        QUrlInfo::setLastModified((const QDateTime& )dt0);
    } else {
        setLastModified((const QDateTime& )dt0);
    }
}
Esempio n. 4
0
void Page::backup()
{
    setLastModified(QDateTime::currentDateTime());

    while (m_backHistory.count() >= (PAGE_BACKUPS + 1)) {
        m_backHistory.removeFirst();
    }

    m_backHistory.append(new QPixmap(*m_pPixmap));
    m_forwardHistory.clear();
}
Esempio n. 5
0
/*!
 * Универсальный метод для отдачи тела фида.
 */
bool FeedHandler::serveFeed(ChatChannel channel, const QString &feedName)
{
  if (!ifMethodAllowed())
    return true;

  if (!channel || !channel->feeds().all().contains(feedName)) {
    setNoStore();
    m_response->writeHead(Tufao::HttpServerResponse::NOT_FOUND);
    m_response->end();
    return true;
  }

  FeedPtr feed = channel->feed(feedName);
  qint64 date  = feed->head().date();

  RestReplyCache &cache = m_cache[channel->id() + feedName.toUtf8()];
  if (cache.date != date) {
    cache.date = date;
    cache.etag = etag(date, m_path.toUtf8());

    cache.body = JSON::generate(feed->feed());
  }

  setLastModified(date);
  setETag(cache.etag);
  setNoCache();

  if (!ifModified(cache.etag)) {
    m_response->writeHead(Tufao::HttpServerResponse::NOT_MODIFIED);
    m_response->end();
    return true;
  }

  m_response->writeHead(Tufao::HttpServerResponse::OK);
  if (m_request->method() != "HEAD") {
    setContentLength(cache.body.size());
    m_response->end(cache.body);
  }
  else
    m_response->end();

  return true;
}
Esempio n. 6
0
void
QWebdavUrlInfo::davParsePropstats( const QString & path,
				   const QDomNodeList & propstats )
{
  QString mimeType;
  bool foundExecutable = false;
  bool isDirectory = false;

  setName(path);

  for ( int i = 0; i < propstats.count(); i++) {
    QDomElement propstat = propstats.item(i).toElement();
    QDomElement status = propstat.namedItem( "status" ).toElement();

    if ( status.isNull() ) {
      qDebug() << "Error, no status code in this propstat";
      return;
    }

    int code = codeFromResponse( status.text() );

    if (code == 404)
      continue ;

    QDomElement prop = propstat.namedItem( "prop" ).toElement();

    if ( prop.isNull() ) {
      qDebug() << "Error: no prop segment in this propstat.";
      return;
    }

    for ( QDomNode n = prop.firstChild(); !n.isNull(); n = n.nextSibling() ) {
      QDomElement property = n.toElement();

      if (property.isNull())
        continue;

      properties_[property.namespaceURI()][property.tagName()] = property.text();

      if ( property.namespaceURI() != "DAV:" ) {
	// break out - we're only interested in properties from the DAV namespace
	continue;
      }

      if ( property.tagName() == "creationdate" )
	setCreatedAt(parseDateTime( property.text(), property.attribute("dt") ));
      else if ( property.tagName() == "getcontentlength" )
        setSize(property.text().toULong());
      else if ( property.tagName() == "displayname" )
	setDisplayName(property.text());
      else if ( property.tagName() == "source" )
      {
        QDomElement source;

	source = property.namedItem( "link" ).toElement()
	  .namedItem( "dst" ).toElement();

        if ( !source.isNull() )
          setSource(source.text());
      }
      else if ( property.tagName() == "getcontentlanguage" )
	setContentLanguage(property.text());
      else if ( property.tagName() == "getcontenttype" )
	{
	  if ( property.text() == "httpd/unix-directory" )
	    isDirectory = true;
	  else
	    mimeType = property.text();
	}
      else if ( property.tagName() == "executable" )
	{
	  if ( property.text() == "T" )
	    foundExecutable = true;
	}
      else if ( property.tagName() == "getlastmodified" )
	setLastModified(parseDateTime( property.text(), property.attribute("dt") ));
      else if ( property.tagName() == "getetag" )
	setEntitytag(property.text());
      else if ( property.tagName() == "resourcetype" )
        {
	  if ( !property.namedItem( "collection" ).toElement().isNull() )
	    isDirectory = true;
	}
      else
        qDebug() << "Found unknown webdav property: "
		 << property.tagName() << property.text();
    }
  }
  setDir(isDirectory);
  setFile(!isDirectory);

  if (isDirectory && !name().endsWith("/"))
    setName(name() + "/");

  if ( foundExecutable || isDirectory )
    setPermissions(0700);
  else
    setPermissions(0600);

  if ( !isDirectory && !mimeType.isEmpty() )
    setMimeType(mimeType);
}