mirror of https://github.com/KLayout/klayout.git
Enabled minimum build configuration
Minimum build configuration is without Qt, Ruby, curl and expat. Only Python is required. This commit also provides a functional (through polling) Qt-less HTTP implementation through libcurl if enabled.
This commit is contained in:
parent
6858190a20
commit
5351922440
35
build.sh
35
build.sh
|
|
@ -26,9 +26,9 @@ IS_MAC="no"
|
|||
HAVE_QTBINDINGS=1
|
||||
HAVE_64BIT_COORD=0
|
||||
HAVE_QT=1
|
||||
HAVE_QT5=""
|
||||
HAVE_CURL=""
|
||||
HAVE_EXPAT=""
|
||||
HAVE_QT5="" # not set
|
||||
HAVE_CURL=0
|
||||
HAVE_EXPAT=0
|
||||
|
||||
RUBYINCLUDE=""
|
||||
RUBYINCLUDE2=""
|
||||
|
|
@ -198,9 +198,10 @@ while [ "$*" != "" ]; do
|
|||
echo " -with-qtbinding Create Qt bindings for ruby scripts [default]"
|
||||
echo " -without-qtbinding Don't create Qt bindings for ruby scripts"
|
||||
echo " -with-64bit-coord Use long (64bit) coordinates - EXPERIMENTAL FEATURE"
|
||||
echo " (only available for gcc>=4.4 for 64bit build)"
|
||||
echo " (only available for gcc>=4.4 for 64bit build)"
|
||||
echo " -without-64bit-coord Don't use long (64bit) coordinates [default]"
|
||||
echo " -without-qt Qt-less build of the core libraries (including pymod)"
|
||||
echo " (implies -without-qtbinding)"
|
||||
echo ""
|
||||
echo " -dry-run Don't build, just run qmake"
|
||||
echo ""
|
||||
|
|
@ -210,7 +211,7 @@ while [ "$*" != "" ]; do
|
|||
echo ""
|
||||
echo " -rblib <file> Location of the .so/.dll to link for Ruby support"
|
||||
echo " -rbinc <dir> Location of the Ruby headers (in particular 'ruby.h')"
|
||||
echo " -rbinc and -rblib must be set to enable Ruby support"
|
||||
echo " -rbinc and -rblib must be set to enable Ruby support"
|
||||
echo " -rbinc2 <dir> Second include path for Ruby 1.9 (containing 'ruby/config.h')"
|
||||
echo " -rbvers <xyyzz> Ruby version code"
|
||||
echo ""
|
||||
|
|
@ -268,11 +269,6 @@ if [ "$HAVE_QT5" = "" ]; then
|
|||
fi
|
||||
|
||||
echo "Using qmake: $QMAKE"
|
||||
if [ "$HAVE_QT5" != "0" ]; then
|
||||
echo " Using Qt 5 API"
|
||||
else
|
||||
echo " Using Qt 4 API"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
# if not given, locate ruby interpreter (prefer 1.9, then default, finally 1.8 as fallback)
|
||||
|
|
@ -431,13 +427,30 @@ if [ "$PYTHON" != "" ] && [ "$PYTHON" != "-" ]; then
|
|||
|
||||
fi
|
||||
|
||||
if [ $HAVE_QT = 0 ]; then
|
||||
HAVE_QTBINDINGS=0
|
||||
fi
|
||||
|
||||
echo "Features:"
|
||||
if [ $HAVE_QT = 0 ]; then
|
||||
echo " Qt not used at all"
|
||||
fi
|
||||
if [ $HAVE_QTBINDINGS != 0 ]; then
|
||||
echo " Qt bindings enabled"
|
||||
if [ "$HAVE_QT5" != "0" ]; then
|
||||
echo " Qt bindings enabled (Qt 5 API)"
|
||||
else
|
||||
echo " Qt bindings enabled (Qt 4 API)"
|
||||
fi
|
||||
fi
|
||||
if [ $HAVE_64BIT_COORD != 0 ]; then
|
||||
echo " 64 bit coordinates enabled"
|
||||
fi
|
||||
if [ $HAVE_EXPAT != 0 ]; then
|
||||
echo " Uses libexpat for XML parsing"
|
||||
fi
|
||||
if [ $HAVE_CURL != 0 ]; then
|
||||
echo " Uses libcurl for network access"
|
||||
fi
|
||||
if [ "$RPATH" = "" ]; then
|
||||
RPATH="$BIN"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
# pykl library definition file
|
||||
# klayout library definition file
|
||||
|
||||
__all__ = [ "tl", "db", "lay" ]
|
||||
__all__ = [ "tl", "db", "lay", "rdb" ]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
# pykl library definition file
|
||||
# klayout library definition file
|
||||
|
||||
__all__ = [ "tl", "db", "lay", "QtCore", "QtGui", "QtXml", "QtSql", "QtNetwork", "QtDesigner" ]
|
||||
__all__ = [ "tl", "db", "lay", "rdb", "QtCore", "QtGui", "QtXml", "QtSql", "QtNetwork", "QtDesigner" ]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
# pykl library definition file
|
||||
# klayout library definition file
|
||||
|
||||
__all__ = [ "tl", "db", "lay",
|
||||
__all__ = [ "tl", "db", "lay", "rdb",
|
||||
"QtCore", "QtGui", "QtNetwork", "QtSql", "QtWidgets", "QtDesigner",
|
||||
"QtMultimedia", "QtPrintSupport", "QtSvg", "QtXmlPatterns", "QtXml" ]
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
# klayout library definition file
|
||||
|
||||
__all__ = [ "tl", "db", "lay", "rdb" ]
|
||||
|
||||
|
|
@ -17,7 +17,11 @@ equals(HAVE_QTBINDINGS, "1") {
|
|||
INIT_PY = $$PWD/../__init__.py.qt4
|
||||
}
|
||||
} else {
|
||||
INIT_PY = $$PWD/../__init__.py.noqt
|
||||
equals(HAVE_QT, "0") {
|
||||
INIT_PY = $$PWD/../__init__.py.qtless
|
||||
} else {
|
||||
INIT_PY = $$PWD/../__init__.py.noqt
|
||||
}
|
||||
}
|
||||
|
||||
QMAKE_POST_LINK += && $(COPY) $$INIT_PY $$DESTDIR_PYMOD/__init__.py
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace rba
|
|||
|
||||
static void fail (const char *file, int line)
|
||||
{
|
||||
throw tl::ScriptError (tl::to_string (QObject::tr ("Ruby support not compiled in")).c_str (), file, line, "missing_feature", std::vector<tl::BacktraceElement> ());
|
||||
throw tl::ScriptError (tl::to_string (tr ("Ruby support not compiled in")).c_str (), file, line, "missing_feature", std::vector<tl::BacktraceElement> ());
|
||||
}
|
||||
|
||||
static RubyInterpreter *sp_rba_interpreter = 0;
|
||||
|
|
|
|||
|
|
@ -131,6 +131,11 @@ equals(HAVE_CURL, "1") {
|
|||
tlHttpStreamQt.cc \
|
||||
tlWebDAV.cc \
|
||||
|
||||
} else {
|
||||
|
||||
SOURCES += \
|
||||
tlHttpStreamNoQt.cc \
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,14 +23,10 @@
|
|||
#ifndef HDR_tlHttpStream
|
||||
#define HDR_tlHttpStream
|
||||
|
||||
#if defined(HAVE_CURL)
|
||||
# include "tlHttpStreamCurl.h"
|
||||
#elif defined(HAVE_QT)
|
||||
# include "tlHttpStreamQt.h"
|
||||
#endif
|
||||
|
||||
#include "tlObject.h"
|
||||
#include "tlException.h"
|
||||
#include "tlStream.h"
|
||||
#include "tlEvents.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
|
@ -63,6 +59,105 @@ public:
|
|||
{ }
|
||||
};
|
||||
|
||||
class InputHttpStreamPrivateData;
|
||||
|
||||
/**
|
||||
* @brief A http input delegate for tl::InputStream
|
||||
*
|
||||
* Implements the reader from a server using the HTTP protocol
|
||||
*/
|
||||
class TL_PUBLIC InputHttpStream
|
||||
: public InputStreamBase
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Open a stream with the given URL
|
||||
*/
|
||||
InputHttpStream (const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Close the file
|
||||
*
|
||||
* The destructor will automatically close the connection.
|
||||
*/
|
||||
virtual ~InputHttpStream ();
|
||||
|
||||
/**
|
||||
* @brief Sets the credential provider
|
||||
*/
|
||||
static void set_credential_provider (HttpCredentialProvider *cp);
|
||||
|
||||
/**
|
||||
* @brief Sends the request for data
|
||||
* To ensure prompt delivery of data, this method can be used prior to
|
||||
* "read" to trigger the download from the given URL.
|
||||
* This method will return immediately. When the reply is available,
|
||||
* the "ready" event will be triggered. "read" can then be used to
|
||||
* read the data or - in case of an error - throw an exception.
|
||||
* If "send" is not used before "read", "read" will block until data
|
||||
* is available.
|
||||
* If a request has already been sent, this method will do nothing.
|
||||
*/
|
||||
void send ();
|
||||
|
||||
/**
|
||||
* @brief Closes the connection
|
||||
*/
|
||||
void close ();
|
||||
|
||||
/**
|
||||
* @brief Sets the request verb
|
||||
* The default verb is "GET"
|
||||
*/
|
||||
void set_request (const char *r);
|
||||
|
||||
/**
|
||||
* @brief Sets data to be sent with the request
|
||||
* If data is given, it is sent along with the request.
|
||||
* This version takes a null-terminated string.
|
||||
*/
|
||||
void set_data (const char *data);
|
||||
|
||||
/**
|
||||
* @brief Sets data to be sent with the request
|
||||
* If data is given, it is sent along with the request.
|
||||
* This version takes a data plus length.
|
||||
*/
|
||||
void set_data (const char *data, size_t n);
|
||||
|
||||
/**
|
||||
* @brief Sets a header field
|
||||
*/
|
||||
void add_header (const std::string &name, const std::string &value);
|
||||
|
||||
/**
|
||||
* @brief Gets the "ready" event
|
||||
* Connect to this event for the asynchroneous interface.
|
||||
* This event is fired when data becomes available or the
|
||||
* connection has terminated with an error.
|
||||
*/
|
||||
tl::Event &ready ();
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether data is available
|
||||
*/
|
||||
bool data_available ();
|
||||
|
||||
/**
|
||||
* @brief Read from the stream
|
||||
* Implements the basic read method.
|
||||
*/
|
||||
virtual size_t read (char *b, size_t n);
|
||||
|
||||
virtual void reset ();
|
||||
virtual std::string source () const;
|
||||
virtual std::string absolute_path () const;
|
||||
virtual std::string filename () const;
|
||||
|
||||
private:
|
||||
InputHttpStreamPrivateData *mp_data;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -543,6 +543,105 @@ private:
|
|||
static CurlNetworkManager *ms_instance;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// InputHttpStream implementation
|
||||
|
||||
InputHttpStream::InputHttpStream (const std::string &url)
|
||||
{
|
||||
mp_data = new InputHttpStreamPrivateData (url);
|
||||
}
|
||||
|
||||
InputHttpStream::~InputHttpStream ()
|
||||
{
|
||||
delete mp_data;
|
||||
mp_data = 0;
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_credential_provider (HttpCredentialProvider *cp)
|
||||
{
|
||||
CurlNetworkManager::instance ()->credentials ().set_provider (cp);
|
||||
CurlNetworkManager::instance ()->proxy_credentials ().set_provider (cp);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::send ()
|
||||
{
|
||||
mp_data->send ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::close ()
|
||||
{
|
||||
mp_data->close ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_request (const char *r)
|
||||
{
|
||||
mp_data->set_request (r);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data)
|
||||
{
|
||||
mp_data->set_data (data);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data, size_t n)
|
||||
{
|
||||
mp_data->set_data (data, n);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::add_header (const std::string &name, const std::string &value)
|
||||
{
|
||||
mp_data->add_header (name, value);
|
||||
}
|
||||
|
||||
tl::Event &
|
||||
InputHttpStream::ready ()
|
||||
{
|
||||
return mp_data->ready ();
|
||||
}
|
||||
|
||||
bool
|
||||
InputHttpStream::data_available ()
|
||||
{
|
||||
return mp_data->data_available ();
|
||||
}
|
||||
|
||||
size_t
|
||||
InputHttpStream::read (char *b, size_t n)
|
||||
{
|
||||
return mp_data->read (b, n);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::reset ()
|
||||
{
|
||||
mp_data->reset ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::source () const
|
||||
{
|
||||
return mp_data->source ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::absolute_path () const
|
||||
{
|
||||
return mp_data->absolute_path ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::filename () const
|
||||
{
|
||||
return mp_data->filename ();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// CurlConnection implementation
|
||||
|
||||
|
|
@ -1072,63 +1171,63 @@ int CurlNetworkManager::tick ()
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// InputHttpFileCurl implementation
|
||||
// InputHttpStreamPrivateData implementation
|
||||
|
||||
InputHttpStream::InputHttpStream (const std::string &url)
|
||||
InputHttpStreamPrivateData::InputHttpStreamPrivateData (const std::string &url)
|
||||
{
|
||||
m_sent = false;
|
||||
m_ready = false;
|
||||
|
||||
m_connection.reset (CurlNetworkManager::instance ()->create_connection ());
|
||||
m_connection->set_url (url.c_str ());
|
||||
m_connection->data_available_event.add (this, &InputHttpStream::on_data_available);
|
||||
m_connection->finished_event.add (this, &InputHttpStream::on_finished);
|
||||
m_connection->data_available_event.add (this, &InputHttpStreamPrivateData::on_data_available);
|
||||
m_connection->finished_event.add (this, &InputHttpStreamPrivateData::on_finished);
|
||||
}
|
||||
|
||||
InputHttpStream::~InputHttpStream ()
|
||||
InputHttpStreamPrivateData::~InputHttpStreamPrivateData ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
bool
|
||||
InputHttpStream::data_available ()
|
||||
InputHttpStreamPrivateData::data_available ()
|
||||
{
|
||||
return m_connection->read_available () > 0;
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_request (const char *r)
|
||||
InputHttpStreamPrivateData::set_request (const char *r)
|
||||
{
|
||||
m_connection->set_request (r);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data)
|
||||
InputHttpStreamPrivateData::set_data (const char *data)
|
||||
{
|
||||
m_connection->set_data (data);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data, size_t n)
|
||||
InputHttpStreamPrivateData::set_data (const char *data, size_t n)
|
||||
{
|
||||
m_connection->set_data (data, n);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::add_header (const std::string &name, const std::string &value)
|
||||
InputHttpStreamPrivateData::add_header (const std::string &name, const std::string &value)
|
||||
{
|
||||
m_connection->add_header (name.c_str (), value.c_str ());
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::on_finished ()
|
||||
InputHttpStreamPrivateData::on_finished ()
|
||||
{
|
||||
m_progress.reset (0);
|
||||
m_ready_event ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::on_data_available ()
|
||||
InputHttpStreamPrivateData::on_data_available ()
|
||||
{
|
||||
// send the ready event just once
|
||||
if (! m_ready) {
|
||||
|
|
@ -1138,7 +1237,7 @@ InputHttpStream::on_data_available ()
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::send ()
|
||||
InputHttpStreamPrivateData::send ()
|
||||
{
|
||||
m_ready = false;
|
||||
m_progress.reset (0);
|
||||
|
|
@ -1147,7 +1246,7 @@ InputHttpStream::send ()
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::check ()
|
||||
InputHttpStreamPrivateData::check ()
|
||||
{
|
||||
if (m_connection->finished ()) {
|
||||
m_connection->check ();
|
||||
|
|
@ -1155,7 +1254,7 @@ InputHttpStream::check ()
|
|||
}
|
||||
|
||||
size_t
|
||||
InputHttpStream::read (char *b, size_t n)
|
||||
InputHttpStreamPrivateData::read (char *b, size_t n)
|
||||
{
|
||||
if (! m_sent) {
|
||||
send ();
|
||||
|
|
@ -1185,7 +1284,7 @@ InputHttpStream::read (char *b, size_t n)
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::close ()
|
||||
InputHttpStreamPrivateData::close ()
|
||||
{
|
||||
m_progress.reset (0);
|
||||
if (m_connection.get ()) {
|
||||
|
|
@ -1195,34 +1294,27 @@ InputHttpStream::close ()
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::reset ()
|
||||
InputHttpStreamPrivateData::reset ()
|
||||
{
|
||||
throw tl::Exception (tl::to_string (tr ("'reset' is not supported on HTTP input streams")));
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::filename () const
|
||||
InputHttpStreamPrivateData::filename () const
|
||||
{
|
||||
return tl::filename (tl::URI (m_connection->url ()).path ());
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::source () const
|
||||
InputHttpStreamPrivateData::source () const
|
||||
{
|
||||
return m_connection->url ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::absolute_path () const
|
||||
InputHttpStreamPrivateData::absolute_path () const
|
||||
{
|
||||
return m_connection->url ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_credential_provider (HttpCredentialProvider *cp)
|
||||
{
|
||||
CurlNetworkManager::instance ()->credentials ().set_provider (cp);
|
||||
CurlNetworkManager::instance ()->proxy_credentials ().set_provider (cp);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,26 +41,21 @@ class HttpCredentialProvider;
|
|||
*
|
||||
* Implements the reader from a server using the HTTP protocol
|
||||
*/
|
||||
class TL_PUBLIC InputHttpStream
|
||||
: public tl::Object, public InputStreamBase
|
||||
class TL_PUBLIC InputHttpStreamPrivateData
|
||||
: public tl::Object
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @brief Open a stream with the given URL
|
||||
*/
|
||||
InputHttpStream (const std::string &url);
|
||||
InputHttpStreamPrivateData (const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Close the file
|
||||
*
|
||||
* The destructor will automatically close the connection.
|
||||
*/
|
||||
virtual ~InputHttpStream ();
|
||||
|
||||
/**
|
||||
* @brief Sets the credential provider
|
||||
*/
|
||||
static void set_credential_provider (HttpCredentialProvider *cp);
|
||||
virtual ~InputHttpStreamPrivateData ();
|
||||
|
||||
/**
|
||||
* @brief Sends the request for data
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
|
||||
/*
|
||||
|
||||
KLayout Layout Viewer
|
||||
Copyright (C) 2006-2018 Matthias Koefferlein
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
*/
|
||||
|
||||
#include "tlHttpStream.h"
|
||||
#include "tlEvents.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Dummy InputHttpStream implementation
|
||||
|
||||
InputHttpStream::InputHttpStream (const std::string &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
InputHttpStream::~InputHttpStream ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_credential_provider (HttpCredentialProvider *)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::send ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::close ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_request (const char *)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *, size_t)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::add_header (const std::string &, const std::string &)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
tl::Event &
|
||||
InputHttpStream::ready ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
static tl::Event dummy;
|
||||
return dummy;
|
||||
}
|
||||
|
||||
bool
|
||||
InputHttpStream::data_available ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t
|
||||
InputHttpStream::read (char *, size_t)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::reset ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::source () const
|
||||
{
|
||||
// .. nothing yet ..
|
||||
return std::string ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::absolute_path () const
|
||||
{
|
||||
// .. nothing yet ..
|
||||
return std::string ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::filename () const
|
||||
{
|
||||
// .. nothing yet ..
|
||||
return std::string ();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@
|
|||
*/
|
||||
|
||||
#include "tlHttpStream.h"
|
||||
#include "tlHttpStreamQt.h"
|
||||
#include "tlLog.h"
|
||||
#include "tlStaticObjects.h"
|
||||
#include "tlDeferredExecution.h"
|
||||
|
|
@ -88,12 +89,110 @@ AuthenticationHandler::proxyAuthenticationRequired (const QNetworkProxy &proxy,
|
|||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// InputHttpFileQt implementation
|
||||
// InputHttpStream implementation
|
||||
|
||||
InputHttpStream::InputHttpStream (const std::string &url)
|
||||
{
|
||||
mp_data = new InputHttpStreamPrivateData (url);
|
||||
}
|
||||
|
||||
InputHttpStream::~InputHttpStream ()
|
||||
{
|
||||
delete mp_data;
|
||||
mp_data = 0;
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_credential_provider (HttpCredentialProvider *cp)
|
||||
{
|
||||
sp_credential_provider.reset (cp);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::send ()
|
||||
{
|
||||
mp_data->send ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::close ()
|
||||
{
|
||||
mp_data->close ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_request (const char *r)
|
||||
{
|
||||
mp_data->set_request (r);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data)
|
||||
{
|
||||
mp_data->set_data (data);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data, size_t n)
|
||||
{
|
||||
mp_data->set_data (data, n);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::add_header (const std::string &name, const std::string &value)
|
||||
{
|
||||
mp_data->add_header (name, value);
|
||||
}
|
||||
|
||||
tl::Event &
|
||||
InputHttpStream::ready ()
|
||||
{
|
||||
return mp_data->ready ();
|
||||
}
|
||||
|
||||
bool
|
||||
InputHttpStream::data_available ()
|
||||
{
|
||||
return mp_data->data_available ();
|
||||
}
|
||||
|
||||
size_t
|
||||
InputHttpStream::read (char *b, size_t n)
|
||||
{
|
||||
return mp_data->read (b, n);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::reset ()
|
||||
{
|
||||
mp_data->reset ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::source () const
|
||||
{
|
||||
return mp_data->source ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::absolute_path () const
|
||||
{
|
||||
return mp_data->absolute_path ();
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::filename () const
|
||||
{
|
||||
return mp_data->filename ();
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// InputHttpStreamPrivateData implementation
|
||||
|
||||
static QNetworkAccessManager *s_network_manager (0);
|
||||
static AuthenticationHandler *s_auth_handler (0);
|
||||
|
||||
InputHttpStream::InputHttpStream (const std::string &url)
|
||||
InputHttpStreamPrivateData::InputHttpStreamPrivateData (const std::string &url)
|
||||
: m_url (url), mp_reply (0), m_request ("GET"), mp_buffer (0)
|
||||
{
|
||||
if (! s_network_manager) {
|
||||
|
|
@ -111,13 +210,13 @@ InputHttpStream::InputHttpStream (const std::string &url)
|
|||
connect (s_network_manager, SIGNAL (finished (QNetworkReply *)), this, SLOT (finished (QNetworkReply *)));
|
||||
}
|
||||
|
||||
InputHttpStream::~InputHttpStream ()
|
||||
InputHttpStreamPrivateData::~InputHttpStreamPrivateData ()
|
||||
{
|
||||
close ();
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::close ()
|
||||
InputHttpStreamPrivateData::close ()
|
||||
{
|
||||
if (mp_active_reply.get ()) {
|
||||
mp_active_reply->abort ();
|
||||
|
|
@ -127,37 +226,31 @@ InputHttpStream::close ()
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_credential_provider (HttpCredentialProvider *cp)
|
||||
{
|
||||
sp_credential_provider.reset (cp);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_request (const char *r)
|
||||
InputHttpStreamPrivateData::set_request (const char *r)
|
||||
{
|
||||
m_request = QByteArray (r);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data)
|
||||
InputHttpStreamPrivateData::set_data (const char *data)
|
||||
{
|
||||
m_data = QByteArray (data);
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::set_data (const char *data, size_t n)
|
||||
InputHttpStreamPrivateData::set_data (const char *data, size_t n)
|
||||
{
|
||||
m_data = QByteArray (data, int (n));
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::add_header (const std::string &name, const std::string &value)
|
||||
InputHttpStreamPrivateData::add_header (const std::string &name, const std::string &value)
|
||||
{
|
||||
m_headers.insert (std::make_pair (name, value));
|
||||
}
|
||||
|
||||
void
|
||||
InputHttpStream::finished (QNetworkReply *reply)
|
||||
InputHttpStreamPrivateData::finished (QNetworkReply *reply)
|
||||
{
|
||||
if (reply != mp_active_reply.get ()) {
|
||||
return;
|
||||
|
|
@ -177,7 +270,7 @@ InputHttpStream::finished (QNetworkReply *reply)
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::issue_request (const QUrl &url)
|
||||
InputHttpStreamPrivateData::issue_request (const QUrl &url)
|
||||
{
|
||||
delete mp_buffer;
|
||||
mp_buffer = 0;
|
||||
|
|
@ -216,7 +309,7 @@ InputHttpStream::issue_request (const QUrl &url)
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::send ()
|
||||
InputHttpStreamPrivateData::send ()
|
||||
{
|
||||
if (mp_reply == 0) {
|
||||
issue_request (QUrl (tl::to_qstring (m_url)));
|
||||
|
|
@ -224,7 +317,7 @@ InputHttpStream::send ()
|
|||
}
|
||||
|
||||
size_t
|
||||
InputHttpStream::read (char *b, size_t n)
|
||||
InputHttpStreamPrivateData::read (char *b, size_t n)
|
||||
{
|
||||
// Prevents deferred methods to be executed during the processEvents below (undesired side effects)
|
||||
tl::NoDeferredMethods silent;
|
||||
|
|
@ -286,13 +379,13 @@ InputHttpStream::read (char *b, size_t n)
|
|||
}
|
||||
|
||||
void
|
||||
InputHttpStream::reset ()
|
||||
InputHttpStreamPrivateData::reset ()
|
||||
{
|
||||
throw tl::Exception (tl::to_string (QObject::tr ("'reset' is not supported on HTTP input streams")));
|
||||
}
|
||||
|
||||
std::string
|
||||
InputHttpStream::filename () const
|
||||
InputHttpStreamPrivateData::filename () const
|
||||
{
|
||||
return tl::to_string (QFileInfo (QUrl (tl::to_qstring (m_url)).path ()).fileName ());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,102 +59,34 @@ private:
|
|||
int m_retry, m_proxy_retry;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A http input delegate for tl::InputStream
|
||||
*
|
||||
* Implements the reader from a server using the HTTP protocol
|
||||
*/
|
||||
class TL_PUBLIC InputHttpStream
|
||||
: public QObject, public InputStreamBase
|
||||
class InputHttpStreamPrivateData
|
||||
: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Open a stream with the given URL
|
||||
*/
|
||||
InputHttpStream (const std::string &url);
|
||||
InputHttpStreamPrivateData (const std::string &url);
|
||||
|
||||
/**
|
||||
* @brief Close the file
|
||||
*
|
||||
* The destructor will automatically close the connection.
|
||||
*/
|
||||
virtual ~InputHttpStream ();
|
||||
virtual ~InputHttpStreamPrivateData ();
|
||||
|
||||
/**
|
||||
* @brief Sets the credential provider
|
||||
*/
|
||||
static void set_credential_provider (HttpCredentialProvider *cp);
|
||||
|
||||
/**
|
||||
* @brief Sends the request for data
|
||||
* To ensure prompt delivery of data, this method can be used prior to
|
||||
* "read" to trigger the download from the given URL.
|
||||
* This method will return immediately. When the reply is available,
|
||||
* the "ready" event will be triggered. "read" can then be used to
|
||||
* read the data or - in case of an error - throw an exception.
|
||||
* If "send" is not used before "read", "read" will block until data
|
||||
* is available.
|
||||
* If a request has already been sent, this method will do nothing.
|
||||
*/
|
||||
void send ();
|
||||
|
||||
/**
|
||||
* @brief Closes the connection
|
||||
*/
|
||||
void close ();
|
||||
|
||||
/**
|
||||
* @brief Sets the request verb
|
||||
* The default verb is "GET"
|
||||
*/
|
||||
void set_request (const char *r);
|
||||
|
||||
/**
|
||||
* @brief Sets data to be sent with the request
|
||||
* If data is given, it is sent along with the request.
|
||||
* This version takes a null-terminated string.
|
||||
*/
|
||||
void set_data (const char *data);
|
||||
|
||||
/**
|
||||
* @brief Sets data to be sent with the request
|
||||
* If data is given, it is sent along with the request.
|
||||
* This version takes a data plus length.
|
||||
*/
|
||||
void set_data (const char *data, size_t n);
|
||||
|
||||
/**
|
||||
* @brief Sets a header field
|
||||
*/
|
||||
void add_header (const std::string &name, const std::string &value);
|
||||
|
||||
/**
|
||||
* @brief Read from the stream
|
||||
* Implements the basic read method.
|
||||
*/
|
||||
virtual size_t read (char *b, size_t n);
|
||||
|
||||
/**
|
||||
* @brief Gets the "ready" event
|
||||
* Connect to this event for the asynchroneous interface.
|
||||
* This event is fired when data becomes available or the
|
||||
* connection has terminated with an error.
|
||||
*/
|
||||
tl::Event &ready ()
|
||||
{
|
||||
return m_ready;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets a value indicating whether data is available
|
||||
*/
|
||||
bool data_available ()
|
||||
{
|
||||
return mp_reply != 0;
|
||||
}
|
||||
|
||||
virtual size_t read (char *b, size_t n);
|
||||
virtual void reset ();
|
||||
|
||||
virtual std::string source () const
|
||||
|
|
|
|||
|
|
@ -763,6 +763,112 @@ XMLParser::parse (XMLSource &source, XMLStructureHandler &struct_handler)
|
|||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// XMLSource implementation
|
||||
|
||||
XMLSource::XMLSource ()
|
||||
: mp_source (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
XMLSource::~XMLSource ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
XMLSource::reset ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// XMLStringSource implementation
|
||||
|
||||
XMLStringSource::XMLStringSource (const std::string &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLStringSource::XMLStringSource (const char *)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLStringSource::XMLStringSource (const char *, size_t)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLStringSource::~XMLStringSource ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// XMLFileSource implementation
|
||||
|
||||
XMLFileSource::XMLFileSource (const std::string &, const std::string &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLFileSource::XMLFileSource (const std::string &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLFileSource::~XMLFileSource ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// XMLStreamSource implementation
|
||||
|
||||
XMLStreamSource::XMLStreamSource (tl::InputStream &, const std::string &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLStreamSource::XMLStreamSource (tl::InputStream &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
XMLStreamSource::~XMLStreamSource ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// XMLParser implementation
|
||||
|
||||
XMLParser::XMLParser ()
|
||||
: mp_data (0)
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
XMLParser::~XMLParser ()
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
void
|
||||
XMLParser::parse (XMLSource &, XMLStructureHandler &)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace tl {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include "tlUnitTest.h"
|
||||
#include "tlTimer.h"
|
||||
|
||||
#if defined(HAVE_QT) || defined(HAVE_CURL)
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
# include <QCoreApplication>
|
||||
#endif
|
||||
|
|
@ -119,3 +121,5 @@ TEST(3)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#include "tlUnitTest.h"
|
||||
#include "tlFileUtils.h"
|
||||
|
||||
#if defined(HAVE_QT) || defined(HAVE_CURL)
|
||||
|
||||
static std::string test_url1 ("http://www.klayout.org/svn-public/klayout-resources/trunk/testdata");
|
||||
static std::string test_url2 ("http://www.klayout.org/svn-public/klayout-resources/trunk/testdata/text");
|
||||
|
||||
|
|
@ -121,3 +123,5 @@ TEST(5)
|
|||
EXPECT_EQ (ba21, "A text II.I.\n");
|
||||
text21.close ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -20,11 +20,11 @@
|
|||
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#include "tlXMLParser.h"
|
||||
#include "tlUnitTest.h"
|
||||
|
||||
#if defined(HAVE_QT) || defined(HAVE_EXPAT)
|
||||
|
||||
#include <sstream>
|
||||
#include <cmath>
|
||||
|
||||
|
|
@ -652,3 +652,4 @@ TEST (13)
|
|||
EXPECT_EQ (child.txt, "H\xc3\xa4llo");
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue