mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 18:45:10 +01:00
Merge branch 'develop' of https://github.com/pocoproject/poco into develop
This commit is contained in:
commit
3f636a355a
@ -28,6 +28,11 @@
|
||||
#include <cstdlib>
|
||||
|
||||
|
||||
#ifndef SQLITE_OPEN_URI
|
||||
#define SQLITE_OPEN_URI 0
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace SQLite {
|
||||
@ -150,7 +155,7 @@ private:
|
||||
|
||||
inline int connectImpl()
|
||||
{
|
||||
return sqlite3_open(_connectString.c_str(), _ppDB);
|
||||
return sqlite3_open_v2(_connectString.c_str(), _ppDB, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
|
||||
}
|
||||
|
||||
std::string _connectString;
|
||||
@ -184,7 +189,8 @@ void SessionImpl::open(const std::string& connect)
|
||||
close();
|
||||
Utility::throwException(rc);
|
||||
}
|
||||
} catch (SQLiteException& ex)
|
||||
}
|
||||
catch (SQLiteException& ex)
|
||||
{
|
||||
throw ConnectionFailedException(ex.displayText());
|
||||
}
|
||||
|
@ -29,6 +29,11 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef SQLITE_OPEN_URI
|
||||
#define SQLITE_OPEN_URI 0
|
||||
#endif
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Data {
|
||||
namespace SQLite {
|
||||
@ -55,6 +60,7 @@ const std::string Utility::SQLITE_TIME_FORMAT = "%H:%M:%S";
|
||||
Utility::TypeMap Utility::_types;
|
||||
Poco::Mutex Utility::_mutex;
|
||||
|
||||
|
||||
Utility::Utility()
|
||||
{
|
||||
Poco::Mutex::ScopedLock l(_mutex);
|
||||
@ -217,7 +223,7 @@ bool Utility::fileToMemory(sqlite3* pInMemory, const std::string& fileName)
|
||||
sqlite3* pFile;
|
||||
sqlite3_backup* pBackup;
|
||||
|
||||
rc = sqlite3_open(fileName.c_str(), &pFile);
|
||||
rc = sqlite3_open_v2(fileName.c_str(), &pFile, SQLITE_OPEN_READONLY | SQLITE_OPEN_URI, NULL);
|
||||
if(rc == SQLITE_OK )
|
||||
{
|
||||
pBackup = sqlite3_backup_init(pInMemory, "main", pFile, "main");
|
||||
@ -240,7 +246,7 @@ bool Utility::memoryToFile(const std::string& fileName, sqlite3* pInMemory)
|
||||
sqlite3* pFile;
|
||||
sqlite3_backup* pBackup;
|
||||
|
||||
rc = sqlite3_open(fileName.c_str(), &pFile);
|
||||
rc = sqlite3_open_v2(fileName.c_str(), &pFile, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_URI, NULL);
|
||||
if(rc == SQLITE_OK )
|
||||
{
|
||||
pBackup = sqlite3_backup_init(pFile, "main", pInMemory, "main");
|
||||
@ -306,6 +312,4 @@ void* Utility::eventHookRegister(sqlite3* pDB, RollbackCallbackType callbackFn,
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
} } } // namespace Poco::Data::SQLite
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -107,9 +107,9 @@ extern "C" {
|
||||
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
||||
** [sqlite_version()] and [sqlite_source_id()].
|
||||
*/
|
||||
#define SQLITE_VERSION "3.8.6"
|
||||
#define SQLITE_VERSION_NUMBER 3008006
|
||||
#define SQLITE_SOURCE_ID "2014-08-15 11:46:33 9491ba7d738528f168657adb43a198238abde19e"
|
||||
#define SQLITE_VERSION "3.8.7.1"
|
||||
#define SQLITE_VERSION_NUMBER 3008007
|
||||
#define SQLITE_SOURCE_ID "2014-10-29 13:59:56 3b7b72c4685aa5cf5e675c2c47ebec10d9704221"
|
||||
|
||||
/*
|
||||
** CAPI3REF: Run-Time Library Version Numbers
|
||||
@ -497,6 +497,7 @@ SQLITE_API int sqlite3_exec(
|
||||
#define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8))
|
||||
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
|
||||
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
|
||||
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
|
||||
|
||||
/*
|
||||
** CAPI3REF: Flags For File Open Operations
|
||||
@ -2099,7 +2100,7 @@ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
|
||||
** turns off all busy handlers.
|
||||
**
|
||||
** ^(There can only be a single busy handler for a particular
|
||||
** [database connection] any any given moment. If another busy handler
|
||||
** [database connection] at any given moment. If another busy handler
|
||||
** was defined (using [sqlite3_busy_handler()]) prior to calling
|
||||
** this routine, that other busy handler is cleared.)^
|
||||
**
|
||||
@ -2303,6 +2304,10 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
|
||||
** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns
|
||||
** a NULL pointer.
|
||||
**
|
||||
** ^The sqlite3_malloc64(N) routine works just like
|
||||
** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead
|
||||
** of a signed 32-bit integer.
|
||||
**
|
||||
** ^Calling sqlite3_free() with a pointer previously returned
|
||||
** by sqlite3_malloc() or sqlite3_realloc() releases that memory so
|
||||
** that it might be reused. ^The sqlite3_free() routine is
|
||||
@ -2314,24 +2319,38 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
|
||||
** might result if sqlite3_free() is called with a non-NULL pointer that
|
||||
** was not obtained from sqlite3_malloc() or sqlite3_realloc().
|
||||
**
|
||||
** ^(The sqlite3_realloc() interface attempts to resize a
|
||||
** prior memory allocation to be at least N bytes, where N is the
|
||||
** second parameter. The memory allocation to be resized is the first
|
||||
** parameter.)^ ^ If the first parameter to sqlite3_realloc()
|
||||
** ^The sqlite3_realloc(X,N) interface attempts to resize a
|
||||
** prior memory allocation X to be at least N bytes.
|
||||
** ^If the X parameter to sqlite3_realloc(X,N)
|
||||
** is a NULL pointer then its behavior is identical to calling
|
||||
** sqlite3_malloc(N) where N is the second parameter to sqlite3_realloc().
|
||||
** ^If the second parameter to sqlite3_realloc() is zero or
|
||||
** sqlite3_malloc(N).
|
||||
** ^If the N parameter to sqlite3_realloc(X,N) is zero or
|
||||
** negative then the behavior is exactly the same as calling
|
||||
** sqlite3_free(P) where P is the first parameter to sqlite3_realloc().
|
||||
** ^sqlite3_realloc() returns a pointer to a memory allocation
|
||||
** of at least N bytes in size or NULL if sufficient memory is unavailable.
|
||||
** sqlite3_free(X).
|
||||
** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation
|
||||
** of at least N bytes in size or NULL if insufficient memory is available.
|
||||
** ^If M is the size of the prior allocation, then min(N,M) bytes
|
||||
** of the prior allocation are copied into the beginning of buffer returned
|
||||
** by sqlite3_realloc() and the prior allocation is freed.
|
||||
** ^If sqlite3_realloc() returns NULL, then the prior allocation
|
||||
** is not freed.
|
||||
** by sqlite3_realloc(X,N) and the prior allocation is freed.
|
||||
** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the
|
||||
** prior allocation is not freed.
|
||||
**
|
||||
** ^The memory returned by sqlite3_malloc() and sqlite3_realloc()
|
||||
** ^The sqlite3_realloc64(X,N) interfaces works the same as
|
||||
** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead
|
||||
** of a 32-bit signed integer.
|
||||
**
|
||||
** ^If X is a memory allocation previously obtained from sqlite3_malloc(),
|
||||
** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then
|
||||
** sqlite3_msize(X) returns the size of that memory allocation in bytes.
|
||||
** ^The value returned by sqlite3_msize(X) might be larger than the number
|
||||
** of bytes requested when X was allocated. ^If X is a NULL pointer then
|
||||
** sqlite3_msize(X) returns zero. If X points to something that is not
|
||||
** the beginning of memory allocation, or if it points to a formerly
|
||||
** valid memory allocation that has now been freed, then the behavior
|
||||
** of sqlite3_msize(X) is undefined and possibly harmful.
|
||||
**
|
||||
** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(),
|
||||
** sqlite3_malloc64(), and sqlite3_realloc64()
|
||||
** is always aligned to at least an 8 byte boundary, or to a
|
||||
** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time
|
||||
** option is used.
|
||||
@ -2359,8 +2378,11 @@ SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
|
||||
** [sqlite3_free()] or [sqlite3_realloc()].
|
||||
*/
|
||||
SQLITE_API void *sqlite3_malloc(int);
|
||||
SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
|
||||
SQLITE_API void *sqlite3_realloc(void*, int);
|
||||
SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
|
||||
SQLITE_API void sqlite3_free(void*);
|
||||
SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
|
||||
|
||||
/*
|
||||
** CAPI3REF: Memory Allocator Statistics
|
||||
@ -2647,9 +2669,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
|
||||
** an English language description of the error following a failure of any
|
||||
** of the sqlite3_open() routines.
|
||||
**
|
||||
** ^The default encoding for the database will be UTF-8 if
|
||||
** sqlite3_open() or sqlite3_open_v2() is called and
|
||||
** UTF-16 in the native byte order if sqlite3_open16() is used.
|
||||
** ^The default encoding will be UTF-8 for databases created using
|
||||
** sqlite3_open() or sqlite3_open_v2(). ^The default encoding for databases
|
||||
** created using sqlite3_open16() will be UTF-16 in the native byte order.
|
||||
**
|
||||
** Whether or not an error occurs when it is opened, resources
|
||||
** associated with the [database connection] handle should be released by
|
||||
@ -2737,13 +2759,14 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
|
||||
** then it is interpreted as an absolute path. ^If the path does not begin
|
||||
** with a '/' (meaning that the authority section is omitted from the URI)
|
||||
** then the path is interpreted as a relative path.
|
||||
** ^On windows, the first component of an absolute path
|
||||
** is a drive specification (e.g. "C:").
|
||||
** ^(On windows, the first component of an absolute path
|
||||
** is a drive specification (e.g. "C:").)^
|
||||
**
|
||||
** [[core URI query parameters]]
|
||||
** The query component of a URI may contain parameters that are interpreted
|
||||
** either by SQLite itself, or by a [VFS | custom VFS implementation].
|
||||
** SQLite interprets the following three query parameters:
|
||||
** SQLite and its built-in [VFSes] interpret the
|
||||
** following query parameters:
|
||||
**
|
||||
** <ul>
|
||||
** <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of
|
||||
@ -2778,11 +2801,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
|
||||
** a URI filename, its value overrides any behavior requested by setting
|
||||
** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag.
|
||||
**
|
||||
** <li> <b>psow</b>: ^The psow parameter may be "true" (or "on" or "yes" or
|
||||
** "1") or "false" (or "off" or "no" or "0") to indicate that the
|
||||
** <li> <b>psow</b>: ^The psow parameter indicates whether or not the
|
||||
** [powersafe overwrite] property does or does not apply to the
|
||||
** storage media on which the database file resides. ^The psow query
|
||||
** parameter only works for the built-in unix and Windows VFSes.
|
||||
** storage media on which the database file resides.
|
||||
**
|
||||
** <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter
|
||||
** which if set disables file locking in rollback journal modes. This
|
||||
@ -3078,6 +3099,10 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||
**
|
||||
** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
|
||||
** <dd>The maximum depth of recursion for triggers.</dd>)^
|
||||
**
|
||||
** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
|
||||
** <dd>The maximum number of auxiliary worker threads that a single
|
||||
** [prepared statement] may start.</dd>)^
|
||||
** </dl>
|
||||
*/
|
||||
#define SQLITE_LIMIT_LENGTH 0
|
||||
@ -3091,6 +3116,7 @@ SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
|
||||
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
|
||||
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
|
||||
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
|
||||
#define SQLITE_LIMIT_WORKER_THREADS 11
|
||||
|
||||
/*
|
||||
** CAPI3REF: Compiling An SQL Statement
|
||||
@ -3364,18 +3390,18 @@ typedef struct sqlite3_context sqlite3_context;
|
||||
** If the fourth parameter to sqlite3_bind_blob() is negative, then
|
||||
** the behavior is undefined.
|
||||
** If a non-negative fourth parameter is provided to sqlite3_bind_text()
|
||||
** or sqlite3_bind_text16() then that parameter must be the byte offset
|
||||
** or sqlite3_bind_text16() or sqlite3_bind_text64() then
|
||||
** that parameter must be the byte offset
|
||||
** where the NUL terminator would occur assuming the string were NUL
|
||||
** terminated. If any NUL characters occur at byte offsets less than
|
||||
** the value of the fourth parameter then the resulting string value will
|
||||
** contain embedded NULs. The result of expressions involving strings
|
||||
** with embedded NULs is undefined.
|
||||
**
|
||||
** ^The fifth argument to sqlite3_bind_blob(), sqlite3_bind_text(), and
|
||||
** sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
|
||||
** ^The fifth argument to the BLOB and string binding interfaces
|
||||
** is a destructor used to dispose of the BLOB or
|
||||
** string after SQLite has finished with it. ^The destructor is called
|
||||
** to dispose of the BLOB or string even if the call to sqlite3_bind_blob(),
|
||||
** sqlite3_bind_text(), or sqlite3_bind_text16() fails.
|
||||
** to dispose of the BLOB or string even if the call to bind API fails.
|
||||
** ^If the fifth argument is
|
||||
** the special value [SQLITE_STATIC], then SQLite assumes that the
|
||||
** information is in static, unmanaged space and does not need to be freed.
|
||||
@ -3383,6 +3409,14 @@ typedef struct sqlite3_context sqlite3_context;
|
||||
** SQLite makes its own private copy of the data immediately, before
|
||||
** the sqlite3_bind_*() routine returns.
|
||||
**
|
||||
** ^The sixth argument to sqlite3_bind_text64() must be one of
|
||||
** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]
|
||||
** to specify the encoding of the text in the third parameter. If
|
||||
** the sixth argument to sqlite3_bind_text64() is not one of the
|
||||
** allowed values shown above, or if the text encoding is different
|
||||
** from the encoding specified by the sixth parameter, then the behavior
|
||||
** is undefined.
|
||||
**
|
||||
** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that
|
||||
** is filled with zeroes. ^A zeroblob uses a fixed amount of memory
|
||||
** (just an integer to hold its size) while it is being processed.
|
||||
@ -3403,6 +3437,9 @@ typedef struct sqlite3_context sqlite3_context;
|
||||
**
|
||||
** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
|
||||
** [error code] if anything goes wrong.
|
||||
** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
|
||||
** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
|
||||
** [SQLITE_MAX_LENGTH].
|
||||
** ^[SQLITE_RANGE] is returned if the parameter
|
||||
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
|
||||
**
|
||||
@ -3410,12 +3447,16 @@ typedef struct sqlite3_context sqlite3_context;
|
||||
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
|
||||
*/
|
||||
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
|
||||
SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
|
||||
void(*)(void*));
|
||||
SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
|
||||
SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
|
||||
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
|
||||
SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
|
||||
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*, int, const char*, int n, void(*)(void*));
|
||||
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
|
||||
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
|
||||
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
|
||||
void(*)(void*), unsigned char encoding);
|
||||
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
|
||||
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
|
||||
|
||||
@ -4164,7 +4205,7 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
|
||||
** object results in undefined behavior.
|
||||
**
|
||||
** ^These routines work just like the corresponding [column access functions]
|
||||
** except that these routines take a single [protected sqlite3_value] object
|
||||
** except that these routines take a single [protected sqlite3_value] object
|
||||
** pointer instead of a [sqlite3_stmt*] pointer and an integer column number.
|
||||
**
|
||||
** ^The sqlite3_value_text16() interface extracts a UTF-16 string
|
||||
@ -4411,6 +4452,10 @@ typedef void (*sqlite3_destructor_type)(void*);
|
||||
** set the return value of the application-defined function to be
|
||||
** a text string which is represented as UTF-8, UTF-16 native byte order,
|
||||
** UTF-16 little endian, or UTF-16 big endian, respectively.
|
||||
** ^The sqlite3_result_text64() interface sets the return value of an
|
||||
** application-defined function to be a text string in an encoding
|
||||
** specified by the fifth (and last) parameter, which must be one
|
||||
** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
|
||||
** ^SQLite takes the text result from the application from
|
||||
** the 2nd parameter of the sqlite3_result_text* interfaces.
|
||||
** ^If the 3rd parameter to the sqlite3_result_text* interfaces
|
||||
@ -4454,6 +4499,7 @@ typedef void (*sqlite3_destructor_type)(void*);
|
||||
** the [sqlite3_context] pointer, the results are undefined.
|
||||
*/
|
||||
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
|
||||
SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(void*));
|
||||
SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
|
||||
SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
|
||||
SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
|
||||
@ -4464,6 +4510,8 @@ SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
|
||||
SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
|
||||
SQLITE_API void sqlite3_result_null(sqlite3_context*);
|
||||
SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
|
||||
SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
|
||||
void(*)(void*), unsigned char encoding);
|
||||
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
|
||||
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
|
||||
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
|
||||
@ -6160,12 +6208,13 @@ SQLITE_API int sqlite3_test_control(int op, ...);
|
||||
#define SQLITE_TESTCTRL_ISKEYWORD 16
|
||||
#define SQLITE_TESTCTRL_SCRATCHMALLOC 17
|
||||
#define SQLITE_TESTCTRL_LOCALTIME_FAULT 18
|
||||
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19
|
||||
#define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */
|
||||
#define SQLITE_TESTCTRL_NEVER_CORRUPT 20
|
||||
#define SQLITE_TESTCTRL_VDBE_COVERAGE 21
|
||||
#define SQLITE_TESTCTRL_BYTEORDER 22
|
||||
#define SQLITE_TESTCTRL_ISINIT 23
|
||||
#define SQLITE_TESTCTRL_LAST 23
|
||||
#define SQLITE_TESTCTRL_SORTER_MMAP 24
|
||||
#define SQLITE_TESTCTRL_LAST 24
|
||||
|
||||
/*
|
||||
** CAPI3REF: SQLite Runtime Status
|
||||
@ -6356,12 +6405,12 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
|
||||
** the current value is always zero.)^
|
||||
**
|
||||
** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt>
|
||||
** <dd>This parameter returns the approximate number of of bytes of heap
|
||||
** <dd>This parameter returns the approximate number of bytes of heap
|
||||
** memory used by all pager caches associated with the database connection.)^
|
||||
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
|
||||
**
|
||||
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
|
||||
** <dd>This parameter returns the approximate number of of bytes of heap
|
||||
** <dd>This parameter returns the approximate number of bytes of heap
|
||||
** memory used to store the schema for all databases associated
|
||||
** with the connection - main, temp, and any [ATTACH]-ed databases.)^
|
||||
** ^The full amount of memory used by the schemas is reported, even if the
|
||||
@ -6370,7 +6419,7 @@ SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int r
|
||||
** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0.
|
||||
**
|
||||
** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt>
|
||||
** <dd>This parameter returns the approximate number of of bytes of heap
|
||||
** <dd>This parameter returns the approximate number of bytes of heap
|
||||
** and lookaside memory used by all prepared statements associated with
|
||||
** the database connection.)^
|
||||
** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0.
|
||||
|
@ -542,6 +542,7 @@ private:
|
||||
static Var parseObject(const std::string& val, std::string::size_type& pos);
|
||||
static Var parseArray(const std::string& val, std::string::size_type& pos);
|
||||
static std::string parseString(const std::string& val, std::string::size_type& pos);
|
||||
static std::string parseJSONString(const std::string& val, std::string::size_type& pos);
|
||||
static void skipWhiteSpace(const std::string& val, std::string::size_type& pos);
|
||||
|
||||
template <typename T>
|
||||
|
@ -109,6 +109,10 @@ std::string Foundation_API format(const std::string& fmt, const Any& value1, con
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value);
|
||||
@ -119,6 +123,10 @@ void Foundation_API format(std::string& result, const std::string& fmt, const An
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
|
||||
void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
|
||||
|
@ -158,6 +158,10 @@ public:
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void critical(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_CRITICAL,
|
||||
@ -181,6 +185,10 @@ public:
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void error(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_ERROR,
|
||||
@ -204,6 +212,10 @@ public:
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void warning(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_WARNING,
|
||||
@ -227,6 +239,10 @@ public:
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void notice(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_NOTICE,
|
||||
@ -250,6 +266,10 @@ public:
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void information(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_INFORMATION,
|
||||
@ -273,6 +293,10 @@ public:
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void debug(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_DEBUG,
|
||||
@ -296,6 +320,10 @@ public:
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void trace(const std::string& msg);
|
||||
/// If the Logger's log level is at least PRIO_TRACE,
|
||||
@ -319,6 +347,10 @@ public:
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7);
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8);
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9);
|
||||
void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10);
|
||||
|
||||
void dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio = Message::PRIO_DEBUG);
|
||||
/// Logs the given message, followed by the data in buffer.
|
||||
@ -700,6 +732,30 @@ inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any&
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_FATAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_FATAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_FATAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_FATAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::critical(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_CRITICAL);
|
||||
@ -748,6 +804,30 @@ inline void Logger::critical(const std::string& fmt, const Any& value1, const An
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_CRITICAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_CRITICAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_CRITICAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_CRITICAL);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::error(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_ERROR);
|
||||
@ -796,6 +876,30 @@ inline void Logger::error(const std::string& fmt, const Any& value1, const Any&
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_ERROR);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::warning(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_WARNING);
|
||||
@ -844,6 +948,30 @@ inline void Logger::warning(const std::string& fmt, const Any& value1, const Any
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_WARNING);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_WARNING);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_WARNING);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_WARNING);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::notice(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_NOTICE);
|
||||
@ -892,6 +1020,30 @@ inline void Logger::notice(const std::string& fmt, const Any& value1, const Any&
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_NOTICE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_NOTICE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_NOTICE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_NOTICE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::information(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_INFORMATION);
|
||||
@ -940,6 +1092,30 @@ inline void Logger::information(const std::string& fmt, const Any& value1, const
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_INFORMATION);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_INFORMATION);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_INFORMATION);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_INFORMATION);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::debug(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_DEBUG);
|
||||
@ -988,6 +1164,30 @@ inline void Logger::debug(const std::string& fmt, const Any& value1, const Any&
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_DEBUG);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::trace(const std::string& msg)
|
||||
{
|
||||
log(msg, Message::PRIO_TRACE);
|
||||
@ -1036,6 +1236,30 @@ inline void Logger::trace(const std::string& fmt, const Any& value1, const Any&
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_TRACE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_TRACE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_TRACE);
|
||||
}
|
||||
|
||||
|
||||
inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_TRACE);
|
||||
}
|
||||
|
||||
|
||||
inline bool Logger::is(int level) const
|
||||
{
|
||||
return _level >= level;
|
||||
|
@ -275,6 +275,38 @@ std::string format(const std::string& fmt, const Any& value1, const Any& value2,
|
||||
}
|
||||
|
||||
|
||||
std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
std::string result;
|
||||
format(result, fmt, value1, value2, value3, value4, value5, value6, value7);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
std::string result;
|
||||
format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
std::string result;
|
||||
format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
std::string result;
|
||||
format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void format(std::string& result, const std::string& fmt, const Any& value)
|
||||
{
|
||||
std::vector<Any> args;
|
||||
@ -338,6 +370,68 @@ void format(std::string& result, const std::string& fmt, const Any& value1, cons
|
||||
}
|
||||
|
||||
|
||||
void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7)
|
||||
{
|
||||
std::vector<Any> args;
|
||||
args.push_back(value1);
|
||||
args.push_back(value2);
|
||||
args.push_back(value3);
|
||||
args.push_back(value4);
|
||||
args.push_back(value5);
|
||||
args.push_back(value6);
|
||||
args.push_back(value7);
|
||||
format(result, fmt, args);
|
||||
}
|
||||
|
||||
|
||||
void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8)
|
||||
{
|
||||
std::vector<Any> args;
|
||||
args.push_back(value1);
|
||||
args.push_back(value2);
|
||||
args.push_back(value3);
|
||||
args.push_back(value4);
|
||||
args.push_back(value5);
|
||||
args.push_back(value6);
|
||||
args.push_back(value7);
|
||||
args.push_back(value8);
|
||||
format(result, fmt, args);
|
||||
}
|
||||
|
||||
|
||||
void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9)
|
||||
{
|
||||
std::vector<Any> args;
|
||||
args.push_back(value1);
|
||||
args.push_back(value2);
|
||||
args.push_back(value3);
|
||||
args.push_back(value4);
|
||||
args.push_back(value5);
|
||||
args.push_back(value6);
|
||||
args.push_back(value7);
|
||||
args.push_back(value8);
|
||||
args.push_back(value9);
|
||||
format(result, fmt, args);
|
||||
}
|
||||
|
||||
|
||||
void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10)
|
||||
{
|
||||
std::vector<Any> args;
|
||||
args.push_back(value1);
|
||||
args.push_back(value2);
|
||||
args.push_back(value3);
|
||||
args.push_back(value4);
|
||||
args.push_back(value5);
|
||||
args.push_back(value6);
|
||||
args.push_back(value7);
|
||||
args.push_back(value8);
|
||||
args.push_back(value9);
|
||||
args.push_back(value10);
|
||||
format(result, fmt, args);
|
||||
}
|
||||
|
||||
|
||||
void format(std::string& result, const std::string& fmt, const std::vector<Any>& values)
|
||||
{
|
||||
std::string::const_iterator itFmt = fmt.begin();
|
||||
|
@ -401,6 +401,8 @@ Var Var::parse(const std::string& val, std::string::size_type& pos)
|
||||
return parseObject(val, pos);
|
||||
case '[':
|
||||
return parseArray(val, pos);
|
||||
case '"':
|
||||
return parseJSONString(val, pos);
|
||||
default:
|
||||
return parseString(val, pos);
|
||||
}
|
||||
@ -464,41 +466,79 @@ Var Var::parseArray(const std::string& val, std::string::size_type& pos)
|
||||
|
||||
std::string Var::parseString(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
static const std::string STR_STOP("\"");
|
||||
static const std::string OTHER_STOP("\n ,]}");
|
||||
|
||||
bool inString = false;
|
||||
//skip optional ' "
|
||||
if (val[pos] == '"')
|
||||
{
|
||||
inString = true;
|
||||
++pos;
|
||||
}
|
||||
|
||||
std::string::size_type stop = std::string::npos;
|
||||
if (inString)
|
||||
{
|
||||
stop = val.find_first_of(STR_STOP, pos);
|
||||
if (stop == std::string::npos)
|
||||
throw DataFormatException("Unterminated string");
|
||||
return parseJSONString(val, pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we stop at space, ',', ']' or '}' or end of string
|
||||
stop = val.find_first_of(OTHER_STOP, pos);
|
||||
if (stop == std::string::npos)
|
||||
stop = val.size();
|
||||
|
||||
std::string::size_type safeCheck = val.find_first_of(STR_STOP, pos);
|
||||
if (safeCheck != std::string::npos && safeCheck < stop)
|
||||
throw DataFormatException("Misplaced string termination char found");
|
||||
|
||||
std::string result;
|
||||
while (pos < val.size()
|
||||
&& !Poco::Ascii::isSpace(val[pos])
|
||||
&& val[pos] != ','
|
||||
&& val[pos] != ']'
|
||||
&& val[pos] != '}')
|
||||
{
|
||||
result += val[pos++];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
// stop now points to the last char to be not included
|
||||
std::string result = val.substr(pos, stop - pos);
|
||||
++stop; // point past '/"
|
||||
pos = stop;
|
||||
|
||||
std::string Var::parseJSONString(const std::string& val, std::string::size_type& pos)
|
||||
{
|
||||
poco_assert_dbg (val[pos] == '"');
|
||||
++pos;
|
||||
std::string result;
|
||||
bool done = false;
|
||||
while (pos < val.size() && !done)
|
||||
{
|
||||
switch (val[pos])
|
||||
{
|
||||
case '"':
|
||||
done = true;
|
||||
++pos;
|
||||
break;
|
||||
case '\\':
|
||||
if (pos < val.size())
|
||||
{
|
||||
++pos;
|
||||
switch (val[pos])
|
||||
{
|
||||
case 'b':
|
||||
result += '\b';
|
||||
break;
|
||||
case 'f':
|
||||
result += '\f';
|
||||
break;
|
||||
case 'n':
|
||||
result += '\n';
|
||||
break;
|
||||
case 'r':
|
||||
result += '\r';
|
||||
break;
|
||||
case 't':
|
||||
result += '\t';
|
||||
break;
|
||||
default:
|
||||
result += val[pos];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
result += val[pos];
|
||||
}
|
||||
++pos;
|
||||
break;
|
||||
default:
|
||||
result += val[pos++];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!done) throw Poco::DataFormatException("unterminated JSON string");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,43 @@ VarHolder::~VarHolder()
|
||||
namespace Impl {
|
||||
|
||||
|
||||
void escape(std::string& target, const std::string& source)
|
||||
{
|
||||
std::string::const_iterator it(source.begin());
|
||||
std::string::const_iterator end(source.end());
|
||||
for (; it != end; ++it)
|
||||
{
|
||||
switch (*it)
|
||||
{
|
||||
case '"':
|
||||
target += "\\\"";
|
||||
break;
|
||||
case '\\':
|
||||
target += "\\\\";
|
||||
break;
|
||||
case '\b':
|
||||
target += "\\b";
|
||||
break;
|
||||
case '\f':
|
||||
target += "\\f";
|
||||
break;
|
||||
case '\n':
|
||||
target += "\\n";
|
||||
break;
|
||||
case '\r':
|
||||
target += "\\r";
|
||||
break;
|
||||
case '\t':
|
||||
target += "\\t";
|
||||
break;
|
||||
default:
|
||||
target += *it;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool isJSONString(const Var& any)
|
||||
{
|
||||
return any.type() == typeid(std::string) ||
|
||||
@ -48,9 +85,9 @@ bool isJSONString(const Var& any)
|
||||
|
||||
void appendJSONString(std::string& val, const Var& any)
|
||||
{
|
||||
val.append(1, '"');
|
||||
val.append(any.convert<std::string>());
|
||||
val.append(1, '"');
|
||||
val += '"';
|
||||
escape(val, any.convert<std::string>());
|
||||
val += '"';
|
||||
}
|
||||
|
||||
|
||||
@ -62,13 +99,21 @@ void appendJSONKey(std::string& val, const Var& any)
|
||||
|
||||
void appendJSONValue(std::string& val, const Var& any)
|
||||
{
|
||||
if (any.isEmpty()) val.append("null");
|
||||
if (any.isEmpty())
|
||||
{
|
||||
val.append("null");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool isStr = isJSONString(any);
|
||||
if (isStr) val.append(1, '"');
|
||||
val.append(any.convert<std::string>());
|
||||
if (isStr) val.append(1, '"');
|
||||
if (isStr)
|
||||
{
|
||||
appendJSONString(val, any.convert<std::string>());
|
||||
}
|
||||
else
|
||||
{
|
||||
val.append(any.convert<std::string>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -199,6 +199,18 @@ void LoggerTest::testFormatAny()
|
||||
|
||||
root.error("%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6);
|
||||
assert (pChannel->getLastMessage().getText() == "123456");
|
||||
|
||||
root.error("%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7);
|
||||
assert(pChannel->getLastMessage().getText() == "1234567");
|
||||
|
||||
root.error("%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
assert(pChannel->getLastMessage().getText() == "12345678");
|
||||
|
||||
root.error("%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9);
|
||||
assert(pChannel->getLastMessage().getText() == "123456789");
|
||||
|
||||
root.error("%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
|
||||
assert(pChannel->getLastMessage().getText() == "12345678910");
|
||||
}
|
||||
|
||||
|
||||
|
@ -2089,6 +2089,20 @@ void VarTest::testArrayToString()
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testArrayToStringEscape()
|
||||
{
|
||||
std::string s1("\"quoted string\"");
|
||||
Poco::Int8 s2(23);
|
||||
std::vector<Var> s16;
|
||||
s16.push_back(s1);
|
||||
s16.push_back(s2);
|
||||
Var a1(s16);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected("[ \"\\\"quoted string\\\"\", 23 ]");
|
||||
assert (res == expected);
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testStructToString()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
@ -2103,6 +2117,18 @@ void VarTest::testStructToString()
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testStructToStringEscape()
|
||||
{
|
||||
DynamicStruct aStruct;
|
||||
aStruct["Value"] = "Value with \" and \n";
|
||||
Var a1(aStruct);
|
||||
std::string res = a1.convert<std::string>();
|
||||
std::string expected = "{ \"Value\" : \"Value with \\\" and \\n\" }";
|
||||
assert (res == expected);
|
||||
assert (aStruct.toString() == res);
|
||||
}
|
||||
|
||||
|
||||
void VarTest::testArrayOfStructsToString()
|
||||
{
|
||||
std::vector<Var> s16;
|
||||
@ -2592,7 +2618,9 @@ CppUnit::Test* VarTest::suite()
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructString);
|
||||
CppUnit_addTest(pSuite, VarTest, testDynamicStructInt);
|
||||
CppUnit_addTest(pSuite, VarTest, testArrayToString);
|
||||
CppUnit_addTest(pSuite, VarTest, testArrayToStringEscape);
|
||||
CppUnit_addTest(pSuite, VarTest, testStructToString);
|
||||
CppUnit_addTest(pSuite, VarTest, testStructToStringEscape);
|
||||
CppUnit_addTest(pSuite, VarTest, testArrayOfStructsToString);
|
||||
CppUnit_addTest(pSuite, VarTest, testStructWithArraysToString);
|
||||
CppUnit_addTest(pSuite, VarTest, testJSONDeserializeString);
|
||||
|
@ -59,7 +59,9 @@ public:
|
||||
void testDynamicStructString();
|
||||
void testDynamicStructInt();
|
||||
void testArrayToString();
|
||||
void testArrayToStringEscape();
|
||||
void testStructToString();
|
||||
void testStructToStringEscape();
|
||||
void testArrayOfStructsToString();
|
||||
void testStructWithArraysToString();
|
||||
void testJSONDeserializeString();
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
/// Restricts incoming and outgoing
|
||||
/// packets to the specified address.
|
||||
///
|
||||
/// Cannot be used together with bind().
|
||||
/// Calls to connect() cannot come before calls to bind().
|
||||
|
||||
void bind(const SocketAddress& address, bool reuseAddress = false);
|
||||
/// Bind a local address to the socket.
|
||||
@ -80,7 +80,7 @@ public:
|
||||
/// If reuseAddress is true, sets the SO_REUSEADDR
|
||||
/// socket option.
|
||||
///
|
||||
/// Cannot be used together with connect().
|
||||
/// Calls to connect cannot() come before calls to bind().
|
||||
|
||||
int sendBytes(const void* buffer, int length, int flags = 0);
|
||||
/// Sends the contents of the given buffer through
|
||||
|
@ -64,6 +64,20 @@ class Net_API HTTPClientSession: public HTTPSession
|
||||
/// set up a session through a proxy.
|
||||
{
|
||||
public:
|
||||
struct ProxyConfig
|
||||
/// HTTP proxy server configuration.
|
||||
{
|
||||
ProxyConfig():
|
||||
port(HTTP_PORT)
|
||||
{
|
||||
}
|
||||
|
||||
std::string host; /// Proxy server host name or IP address.
|
||||
Poco::UInt16 port; /// Proxy server TCP port.
|
||||
std::string username; /// Proxy server username.
|
||||
std::string password; /// Proxy server password.
|
||||
};
|
||||
|
||||
HTTPClientSession();
|
||||
/// Creates an unconnected HTTPClientSession.
|
||||
|
||||
@ -133,6 +147,25 @@ public:
|
||||
const std::string& getProxyPassword() const;
|
||||
/// Returns the password for proxy authentication.
|
||||
|
||||
void setProxyConfig(const ProxyConfig& config);
|
||||
/// Sets the proxy configuration.
|
||||
|
||||
const ProxyConfig& getProxyConfig() const;
|
||||
/// Returns the proxy configuration.
|
||||
|
||||
static void setGlobalProxyConfig(const ProxyConfig& config);
|
||||
/// Sets the global proxy configuration.
|
||||
///
|
||||
/// The global proxy configuration is used by all HTTPClientSession
|
||||
/// instances, unless a different proxy configuration is explicitly set.
|
||||
///
|
||||
/// Warning: Setting the global proxy configuration is not thread safe.
|
||||
/// The global proxy configuration should be set at start up, before
|
||||
/// the first HTTPClientSession instance is created.
|
||||
|
||||
static const ProxyConfig& getGlobalProxyConfig();
|
||||
/// Returns the global proxy configuration.
|
||||
|
||||
void setKeepAliveTimeout(const Poco::Timespan& timeout);
|
||||
/// Sets the connection timeout for HTTP connections.
|
||||
|
||||
@ -198,7 +231,7 @@ public:
|
||||
virtual bool secure() const;
|
||||
/// Return true iff the session uses SSL or TLS,
|
||||
/// or false otherwise.
|
||||
|
||||
|
||||
protected:
|
||||
enum
|
||||
{
|
||||
@ -237,10 +270,7 @@ protected:
|
||||
private:
|
||||
std::string _host;
|
||||
Poco::UInt16 _port;
|
||||
std::string _proxyHost;
|
||||
Poco::UInt16 _proxyPort;
|
||||
std::string _proxyUsername;
|
||||
std::string _proxyPassword;
|
||||
ProxyConfig _proxyConfig;
|
||||
Poco::Timespan _keepAliveTimeout;
|
||||
Poco::Timestamp _lastRequest;
|
||||
bool _reconnect;
|
||||
@ -248,6 +278,8 @@ private:
|
||||
bool _expectResponseBody;
|
||||
Poco::SharedPtr<std::ostream> _pRequestStream;
|
||||
Poco::SharedPtr<std::istream> _pResponseStream;
|
||||
|
||||
static ProxyConfig _globalProxyConfig;
|
||||
|
||||
HTTPClientSession(const HTTPClientSession&);
|
||||
HTTPClientSession& operator = (const HTTPClientSession&);
|
||||
@ -273,25 +305,37 @@ inline Poco::UInt16 HTTPClientSession::getPort() const
|
||||
|
||||
inline const std::string& HTTPClientSession::getProxyHost() const
|
||||
{
|
||||
return _proxyHost;
|
||||
return _proxyConfig.host;
|
||||
}
|
||||
|
||||
|
||||
inline Poco::UInt16 HTTPClientSession::getProxyPort() const
|
||||
{
|
||||
return _proxyPort;
|
||||
return _proxyConfig.port;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPClientSession::getProxyUsername() const
|
||||
{
|
||||
return _proxyUsername;
|
||||
return _proxyConfig.username;
|
||||
}
|
||||
|
||||
|
||||
inline const std::string& HTTPClientSession::getProxyPassword() const
|
||||
{
|
||||
return _proxyPassword;
|
||||
return _proxyConfig.password;
|
||||
}
|
||||
|
||||
|
||||
inline const HTTPClientSession::ProxyConfig& HTTPClientSession::getProxyConfig() const
|
||||
{
|
||||
return _proxyConfig;
|
||||
}
|
||||
|
||||
|
||||
inline const HTTPClientSession::ProxyConfig& HTTPClientSession::getGlobalProxyConfig()
|
||||
{
|
||||
return _globalProxyConfig;
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,7 +69,7 @@ public:
|
||||
/// Restricts incoming and outgoing
|
||||
/// packets to the specified address.
|
||||
///
|
||||
/// Cannot be used together with bind().
|
||||
/// Calls to connect() cannot come before calls to bind().
|
||||
|
||||
void bind(const SocketAddress& address, bool reuseAddress = false);
|
||||
/// Bind a local address to the socket.
|
||||
@ -80,7 +80,7 @@ public:
|
||||
/// If reuseAddress is true, sets the SO_REUSEADDR
|
||||
/// socket option.
|
||||
///
|
||||
/// Cannot be used together with connect().
|
||||
/// Calls to connect() cannot come before calls to bind().
|
||||
|
||||
int sendBytes(const void* buffer, int length, int flags = 0);
|
||||
/// Sends the contents of the given buffer through
|
||||
|
@ -37,9 +37,12 @@ namespace Poco {
|
||||
namespace Net {
|
||||
|
||||
|
||||
HTTPClientSession::ProxyConfig HTTPClientSession::_globalProxyConfig;
|
||||
|
||||
|
||||
HTTPClientSession::HTTPClientSession():
|
||||
_port(HTTPSession::HTTP_PORT),
|
||||
_proxyPort(HTTPSession::HTTP_PORT),
|
||||
_proxyConfig(_globalProxyConfig),
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
@ -51,7 +54,7 @@ HTTPClientSession::HTTPClientSession():
|
||||
HTTPClientSession::HTTPClientSession(const StreamSocket& socket):
|
||||
HTTPSession(socket),
|
||||
_port(HTTPSession::HTTP_PORT),
|
||||
_proxyPort(HTTPSession::HTTP_PORT),
|
||||
_proxyConfig(_globalProxyConfig),
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
@ -63,7 +66,7 @@ HTTPClientSession::HTTPClientSession(const StreamSocket& socket):
|
||||
HTTPClientSession::HTTPClientSession(const SocketAddress& address):
|
||||
_host(address.host().toString()),
|
||||
_port(address.port()),
|
||||
_proxyPort(HTTPSession::HTTP_PORT),
|
||||
_proxyConfig(_globalProxyConfig),
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
@ -75,7 +78,7 @@ HTTPClientSession::HTTPClientSession(const SocketAddress& address):
|
||||
HTTPClientSession::HTTPClientSession(const std::string& host, Poco::UInt16 port):
|
||||
_host(host),
|
||||
_port(port),
|
||||
_proxyPort(HTTPSession::HTTP_PORT),
|
||||
_proxyConfig(_globalProxyConfig),
|
||||
_keepAliveTimeout(DEFAULT_KEEP_ALIVE_TIMEOUT, 0),
|
||||
_reconnect(false),
|
||||
_mustReconnect(false),
|
||||
@ -111,8 +114,8 @@ void HTTPClientSession::setProxy(const std::string& host, Poco::UInt16 port)
|
||||
{
|
||||
if (!connected())
|
||||
{
|
||||
_proxyHost = host;
|
||||
_proxyPort = port;
|
||||
_proxyConfig.host = host;
|
||||
_proxyConfig.port = port;
|
||||
}
|
||||
else throw IllegalStateException("Cannot set the proxy host and port for an already connected session");
|
||||
}
|
||||
@ -121,7 +124,7 @@ void HTTPClientSession::setProxy(const std::string& host, Poco::UInt16 port)
|
||||
void HTTPClientSession::setProxyHost(const std::string& host)
|
||||
{
|
||||
if (!connected())
|
||||
_proxyHost = host;
|
||||
_proxyConfig.host = host;
|
||||
else
|
||||
throw IllegalStateException("Cannot set the proxy host for an already connected session");
|
||||
}
|
||||
@ -130,7 +133,7 @@ void HTTPClientSession::setProxyHost(const std::string& host)
|
||||
void HTTPClientSession::setProxyPort(Poco::UInt16 port)
|
||||
{
|
||||
if (!connected())
|
||||
_proxyPort = port;
|
||||
_proxyConfig.port = port;
|
||||
else
|
||||
throw IllegalStateException("Cannot set the proxy port number for an already connected session");
|
||||
}
|
||||
@ -138,23 +141,35 @@ void HTTPClientSession::setProxyPort(Poco::UInt16 port)
|
||||
|
||||
void HTTPClientSession::setProxyCredentials(const std::string& username, const std::string& password)
|
||||
{
|
||||
_proxyUsername = username;
|
||||
_proxyPassword = password;
|
||||
_proxyConfig.username = username;
|
||||
_proxyConfig.password = password;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::setProxyUsername(const std::string& username)
|
||||
{
|
||||
_proxyUsername = username;
|
||||
_proxyConfig.username = username;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::setProxyPassword(const std::string& password)
|
||||
{
|
||||
_proxyPassword = password;
|
||||
_proxyConfig.password = password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void HTTPClientSession::setProxyConfig(const ProxyConfig& config)
|
||||
{
|
||||
_proxyConfig = config;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::setGlobalProxyConfig(const ProxyConfig& config)
|
||||
{
|
||||
_globalProxyConfig = config;
|
||||
}
|
||||
|
||||
|
||||
void HTTPClientSession::setKeepAliveTimeout(const Poco::Timespan& timeout)
|
||||
{
|
||||
_keepAliveTimeout = timeout;
|
||||
@ -180,7 +195,7 @@ std::ostream& HTTPClientSession::sendRequest(HTTPRequest& request)
|
||||
request.setKeepAlive(false);
|
||||
if (!request.has(HTTPRequest::HOST))
|
||||
request.setHost(_host, _port);
|
||||
if (!_proxyHost.empty())
|
||||
if (!_proxyConfig.host.empty())
|
||||
{
|
||||
request.setURI(proxyRequestPrefix() + request.getURI());
|
||||
proxyAuthenticate(request);
|
||||
@ -312,14 +327,14 @@ int HTTPClientSession::write(const char* buffer, std::streamsize length)
|
||||
|
||||
void HTTPClientSession::reconnect()
|
||||
{
|
||||
if (_proxyHost.empty())
|
||||
if (_proxyConfig.host.empty())
|
||||
{
|
||||
SocketAddress addr(_host, _port);
|
||||
connect(addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
SocketAddress addr(_proxyHost, _proxyPort);
|
||||
SocketAddress addr(_proxyConfig.host, _proxyConfig.port);
|
||||
connect(addr);
|
||||
}
|
||||
}
|
||||
@ -354,9 +369,9 @@ void HTTPClientSession::proxyAuthenticate(HTTPRequest& request)
|
||||
|
||||
void HTTPClientSession::proxyAuthenticateImpl(HTTPRequest& request)
|
||||
{
|
||||
if (!_proxyUsername.empty())
|
||||
if (!_proxyConfig.username.empty())
|
||||
{
|
||||
HTTPBasicCredentials creds(_proxyUsername, _proxyPassword);
|
||||
HTTPBasicCredentials creds(_proxyConfig.username, _proxyConfig.password);
|
||||
creds.proxyAuthenticate(request);
|
||||
}
|
||||
}
|
||||
|
@ -87,10 +87,21 @@ std::istream* HTTPStreamFactory::open(const URI& uri)
|
||||
pSession = new HTTPClientSession(resolvedURI.getHost(), resolvedURI.getPort());
|
||||
|
||||
if (proxyUri.empty())
|
||||
pSession->setProxy(_proxyHost, _proxyPort);
|
||||
{
|
||||
if (!_proxyHost.empty())
|
||||
{
|
||||
pSession->setProxy(_proxyHost, _proxyPort);
|
||||
pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pSession->setProxy(proxyUri.getHost(), proxyUri.getPort());
|
||||
pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
if (!_proxyUsername.empty())
|
||||
{
|
||||
pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string path = resolvedURI.getPathAndQuery();
|
||||
@ -131,7 +142,8 @@ std::istream* HTTPStreamFactory::open(const URI& uri)
|
||||
// single request via the proxy. 305 responses MUST only be generated by origin servers.
|
||||
// only use for one single request!
|
||||
proxyUri.resolve(res.get("Location"));
|
||||
delete pSession; pSession = 0;
|
||||
delete pSession;
|
||||
pSession = 0;
|
||||
retry = true; // only allow useproxy once
|
||||
}
|
||||
else if (res.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED && !authorize)
|
||||
|
@ -89,11 +89,23 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
pSession = new HTTPSClientSession(resolvedURI.getHost(), resolvedURI.getPort());
|
||||
else
|
||||
pSession = new HTTPClientSession(resolvedURI.getHost(), resolvedURI.getPort());
|
||||
|
||||
if (proxyUri.empty())
|
||||
pSession->setProxy(_proxyHost, _proxyPort);
|
||||
{
|
||||
if (!_proxyHost.empty())
|
||||
{
|
||||
pSession->setProxy(_proxyHost, _proxyPort);
|
||||
pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pSession->setProxy(proxyUri.getHost(), proxyUri.getPort());
|
||||
pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
if (!_proxyUsername.empty())
|
||||
{
|
||||
pSession->setProxyCredentials(_proxyUsername, _proxyPassword);
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string path = resolvedURI.getPathAndQuery();
|
||||
if (path.empty()) path = "/";
|
||||
@ -136,7 +148,8 @@ std::istream* HTTPSStreamFactory::open(const URI& uri)
|
||||
// single request via the proxy. 305 responses MUST only be generated by origin servers.
|
||||
// only use for one single request!
|
||||
proxyUri.resolve(res.get("Location"));
|
||||
delete pSession; pSession = 0;
|
||||
delete pSession;
|
||||
pSession = 0;
|
||||
retry = true; // only allow useproxy once
|
||||
}
|
||||
else if (res.getStatus() == HTTPResponse::HTTP_UNAUTHORIZED && !authorize)
|
||||
|
202
PocoDoc/resources/js/CollapsibleLists.js
Normal file
202
PocoDoc/resources/js/CollapsibleLists.js
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
|
||||
CollapsibleLists.js
|
||||
|
||||
An object allowing lists to dynamically expand and collapse
|
||||
|
||||
Created by Stephen Morley - http://code.stephenmorley.org/ - and released under
|
||||
the terms of the CC0 1.0 Universal legal code:
|
||||
|
||||
http://creativecommons.org/publicdomain/zero/1.0/legalcode
|
||||
|
||||
Modified by Guenter Obiltschnig (added expansion via URI query string)
|
||||
|
||||
*/
|
||||
|
||||
// create the CollapsibleLists object
|
||||
var CollapsibleLists =
|
||||
new function(){
|
||||
|
||||
/* Makes all lists with the class 'collapsibleList' collapsible. The
|
||||
* parameter is:
|
||||
*
|
||||
* doNotRecurse - true if sub-lists should not be made collapsible
|
||||
*/
|
||||
this.apply = function(doNotRecurse){
|
||||
|
||||
// loop over the unordered lists
|
||||
var uls = document.getElementsByTagName('ul');
|
||||
for (var index = 0; index < uls.length; index ++){
|
||||
|
||||
// check whether this list should be made collapsible
|
||||
if (uls[index].className.match(/(^| )collapsibleList( |$)/)){
|
||||
|
||||
// make this list collapsible
|
||||
this.applyTo(uls[index], true);
|
||||
|
||||
// check whether sub-lists should also be made collapsible
|
||||
if (!doNotRecurse){
|
||||
|
||||
// add the collapsibleList class to the sub-lists
|
||||
var subUls = uls[index].getElementsByTagName('ul');
|
||||
for (var subIndex = 0; subIndex < subUls.length; subIndex ++){
|
||||
subUls[subIndex].className += ' collapsibleList';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var id = getParameterByName('expand');
|
||||
if (id){
|
||||
|
||||
var node = document.getElementById(id);
|
||||
if (node){
|
||||
|
||||
expand(node);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* Makes the specified list collapsible. The parameters are:
|
||||
*
|
||||
* node - the list element
|
||||
* doNotRecurse - true if sub-lists should not be made collapsible
|
||||
*/
|
||||
this.applyTo = function(node, doNotRecurse){
|
||||
|
||||
// loop over the list items within this node
|
||||
var lis = node.getElementsByTagName('li');
|
||||
for (var index = 0; index < lis.length; index ++){
|
||||
|
||||
// check whether this list item should be collapsible
|
||||
if (!doNotRecurse || node == lis[index].parentNode){
|
||||
|
||||
// prevent text from being selected unintentionally
|
||||
if (lis[index].addEventListener){
|
||||
lis[index].addEventListener(
|
||||
'mousedown', function (e){ e.preventDefault(); }, false);
|
||||
}else{
|
||||
lis[index].attachEvent(
|
||||
'onselectstart', function(){ event.returnValue = false; });
|
||||
}
|
||||
|
||||
// add the click listener
|
||||
if (lis[index].addEventListener){
|
||||
lis[index].addEventListener(
|
||||
'click', createClickListener(lis[index]), false);
|
||||
}else{
|
||||
lis[index].attachEvent(
|
||||
'onclick', createClickListener(lis[index]));
|
||||
}
|
||||
|
||||
// close the unordered lists within this list item
|
||||
toggle(lis[index]);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
/* Expands a node.
|
||||
*
|
||||
* node - the node containing the unordered list elements
|
||||
*/
|
||||
function expand(node){
|
||||
// loop over the unordered list elements with the node
|
||||
var uls = node.getElementsByTagName('ul');
|
||||
for (var index = 0; index < uls.length; index ++){
|
||||
|
||||
// find the parent list item of this unordered list
|
||||
var li = uls[index];
|
||||
while (li.nodeName != 'LI') li = li.parentNode;
|
||||
|
||||
// style the unordered list if it is directly within this node
|
||||
if (li == node) uls[index].style.display = 'block';
|
||||
}
|
||||
// remove the current class from the node
|
||||
node.className =
|
||||
node.className.replace(
|
||||
/(^| )collapsibleList(Open|Closed)( |$)/, '');
|
||||
|
||||
// if the node contains unordered lists, set its class
|
||||
if (uls.length > 0){
|
||||
node.className += ' collapsibleList' + (open ? 'Open' : 'Closed');
|
||||
}
|
||||
}
|
||||
|
||||
/* Returns a function that toggles the display status of any unordered
|
||||
* list elements within the specified node. The parameter is:
|
||||
*
|
||||
* node - the node containing the unordered list elements
|
||||
*/
|
||||
function createClickListener(node){
|
||||
|
||||
// return the function
|
||||
return function(e){
|
||||
|
||||
// ensure the event object is defined
|
||||
if (!e) e = window.event;
|
||||
|
||||
// find the list item containing the target of the event
|
||||
var li = (e.target ? e.target : e.srcElement);
|
||||
while (li.nodeName != 'LI') li = li.parentNode;
|
||||
|
||||
// toggle the state of the node if it was the target of the event
|
||||
if (li == node) toggle(node);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/* Opens or closes the unordered list elements directly within the
|
||||
* specified node. The parameter is:
|
||||
*
|
||||
* node - the node containing the unordered list elements
|
||||
*/
|
||||
function toggle(node){
|
||||
|
||||
// determine whether to open or close the unordered lists
|
||||
var open = node.className.match(/(^| )collapsibleListClosed( |$)/);
|
||||
|
||||
// loop over the unordered list elements with the node
|
||||
var uls = node.getElementsByTagName('ul');
|
||||
for (var index = 0; index < uls.length; index ++){
|
||||
|
||||
// find the parent list item of this unordered list
|
||||
var li = uls[index];
|
||||
while (li.nodeName != 'LI') li = li.parentNode;
|
||||
|
||||
// style the unordered list if it is directly within this node
|
||||
if (li == node) uls[index].style.display = (open ? 'block' : 'none');
|
||||
|
||||
}
|
||||
|
||||
// remove the current class from the node
|
||||
node.className =
|
||||
node.className.replace(
|
||||
/(^| )collapsibleList(Open|Closed)( |$)/, '');
|
||||
|
||||
// if the node contains unordered lists, set its class
|
||||
if (uls.length > 0){
|
||||
node.className += ' collapsibleList' + (open ? 'Open' : 'Closed');
|
||||
}
|
||||
}
|
||||
|
||||
/* Get a URL query string parameter.
|
||||
*
|
||||
* name - the parameter name
|
||||
*/
|
||||
function getParameterByName(name){
|
||||
|
||||
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
|
||||
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
|
||||
results = regex.exec(location.search);
|
||||
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
|
||||
}
|
||||
|
||||
}();
|
575
PocoDoc/resources/js/iframeResizer.contentWindow.js
Executable file
575
PocoDoc/resources/js/iframeResizer.contentWindow.js
Executable file
@ -0,0 +1,575 @@
|
||||
/*
|
||||
* File: iframeSizer.contentWindow.js
|
||||
* Desc: Include this file in any page being loaded into an iframe
|
||||
* to force the iframe to resize to the content size.
|
||||
* Requires: iframeResizer.js on host page.
|
||||
* Author: David J. Bradshaw - dave@bradshaw.net
|
||||
* Contributor: Jure Mav - jure.mav@gmail.com
|
||||
*/
|
||||
|
||||
;(function() {
|
||||
'use strict';
|
||||
|
||||
var
|
||||
autoResize = true,
|
||||
base = 10,
|
||||
bodyBackground = '',
|
||||
bodyMargin = 0,
|
||||
bodyMarginStr = '',
|
||||
bodyPadding = '',
|
||||
calculateWidth = false,
|
||||
doubleEventList = {'resize':1,'click':1},
|
||||
eventCancelTimer = 128,
|
||||
height = 1,
|
||||
firstRun = true,
|
||||
heightCalcModeDefault = 'offset',
|
||||
heightCalcMode = heightCalcModeDefault,
|
||||
initLock = true,
|
||||
initMsg = '',
|
||||
interval = 32,
|
||||
logging = false,
|
||||
msgID = '[iFrameSizer]', //Must match host page msg ID
|
||||
msgIdLen = msgID.length,
|
||||
myID = '',
|
||||
publicMethods = false,
|
||||
resetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1},
|
||||
targetOriginDefault = '*',
|
||||
target = window.parent,
|
||||
tolerance = 0,
|
||||
triggerLocked = false,
|
||||
triggerLockedTimer = null,
|
||||
width = 1;
|
||||
|
||||
|
||||
function addEventListener(el,evt,func){
|
||||
if ('addEventListener' in window){
|
||||
el.addEventListener(evt,func, false);
|
||||
} else if ('attachEvent' in window){ //IE
|
||||
el.attachEvent('on'+evt,func);
|
||||
}
|
||||
}
|
||||
|
||||
function formatLogMsg(msg){
|
||||
return msgID + '[' + myID + ']' + ' ' + msg;
|
||||
}
|
||||
|
||||
function log(msg){
|
||||
if (logging && ('object' === typeof window.console)){
|
||||
console.log(formatLogMsg(msg));
|
||||
}
|
||||
}
|
||||
|
||||
function warn(msg){
|
||||
if ('object' === typeof window.console){
|
||||
console.warn(formatLogMsg(msg));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function init(){
|
||||
log('Initialising iFrame');
|
||||
readData();
|
||||
setMargin();
|
||||
setBodyStyle('background',bodyBackground);
|
||||
setBodyStyle('padding',bodyPadding);
|
||||
injectClearFixIntoBodyElement();
|
||||
checkHeightMode();
|
||||
stopInfiniteResizingOfIFrame();
|
||||
setupPublicMethods();
|
||||
startEventListeners();
|
||||
sendSize('init','Init message from host page');
|
||||
}
|
||||
|
||||
function readData(){
|
||||
|
||||
var data = initMsg.substr(msgIdLen).split(':');
|
||||
|
||||
function strBool(str){
|
||||
return 'true' === str ? true : false;
|
||||
}
|
||||
|
||||
myID = data[0];
|
||||
bodyMargin = (undefined !== data[1]) ? Number(data[1]) : bodyMargin; //For V1 compatibility
|
||||
calculateWidth = (undefined !== data[2]) ? strBool(data[2]) : calculateWidth;
|
||||
logging = (undefined !== data[3]) ? strBool(data[3]) : logging;
|
||||
interval = (undefined !== data[4]) ? Number(data[4]) : interval;
|
||||
publicMethods = (undefined !== data[5]) ? strBool(data[5]) : publicMethods;
|
||||
autoResize = (undefined !== data[6]) ? strBool(data[6]) : autoResize;
|
||||
bodyMarginStr = data[7];
|
||||
heightCalcMode = (undefined !== data[8]) ? data[8] : heightCalcMode;
|
||||
bodyBackground = data[9];
|
||||
bodyPadding = data[10];
|
||||
tolerance = (undefined !== data[11]) ? Number(data[11]) : tolerance;
|
||||
}
|
||||
|
||||
function chkCSS(attr,value){
|
||||
if (-1 !== value.indexOf('-')){
|
||||
warn('Negative CSS value ignored for '+attr);
|
||||
value='';
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function setBodyStyle(attr,value){
|
||||
if ((undefined !== value) && ('' !== value) && ('null' !== value)){
|
||||
document.body.style[attr] = value;
|
||||
log('Body '+attr+' set to "'+value+'"');
|
||||
}
|
||||
}
|
||||
|
||||
function setMargin(){
|
||||
//If called via V1 script, convert bodyMargin from int to str
|
||||
if (undefined === bodyMarginStr){
|
||||
bodyMarginStr = bodyMargin+'px';
|
||||
}
|
||||
chkCSS('margin',bodyMarginStr);
|
||||
setBodyStyle('margin',bodyMarginStr);
|
||||
}
|
||||
|
||||
function stopInfiniteResizingOfIFrame(){
|
||||
document.documentElement.style.height = '';
|
||||
document.body.style.height = '';
|
||||
log('HTML & body height set to "auto"');
|
||||
}
|
||||
|
||||
function initWindowResizeListener(){
|
||||
addEventListener(window,'resize', function(){
|
||||
sendSize('resize','Window resized');
|
||||
});
|
||||
}
|
||||
|
||||
function initWindowClickListener(){
|
||||
addEventListener(window,'click', function(){
|
||||
sendSize('click','Window clicked');
|
||||
});
|
||||
}
|
||||
|
||||
function checkHeightMode(){
|
||||
if (heightCalcModeDefault !== heightCalcMode){
|
||||
if (!(heightCalcMode in getHeight)){
|
||||
warn(heightCalcMode + ' is not a valid option for heightCalculationMethod.');
|
||||
heightCalcMode='bodyScroll';
|
||||
}
|
||||
log('Height calculation method set to "'+heightCalcMode+'"');
|
||||
}
|
||||
}
|
||||
|
||||
function startEventListeners(){
|
||||
if ( true === autoResize ) {
|
||||
initWindowResizeListener();
|
||||
initWindowClickListener();
|
||||
setupMutationObserver();
|
||||
}
|
||||
else {
|
||||
log('Auto Resize disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function injectClearFixIntoBodyElement(){
|
||||
var clearFix = document.createElement('div');
|
||||
clearFix.style.clear = 'both';
|
||||
clearFix.style.display = 'block'; //Guard against this having been globally redefined in CSS.
|
||||
document.body.appendChild(clearFix);
|
||||
}
|
||||
|
||||
function setupPublicMethods(){
|
||||
if (publicMethods) {
|
||||
log('Enable public methods');
|
||||
|
||||
window.parentIFrame = {
|
||||
close: function closeF(){
|
||||
sendSize('close','parentIFrame.close()', 0, 0);
|
||||
},
|
||||
getId: function getIdF(){
|
||||
return myID;
|
||||
},
|
||||
reset: function resetF(){
|
||||
resetIFrame('parentIFrame.size');
|
||||
},
|
||||
scrollTo: function scrollToF(x,y){
|
||||
sendMsg(y,x,'scrollTo'); // X&Y reversed at sendMsg uses hieght/width
|
||||
},
|
||||
sendMessage: function sendMessageF(msg,targetOrigin){
|
||||
sendMsg(0,0,'message',msg,targetOrigin);
|
||||
},
|
||||
setHeightCalculationMethod: function setHeightCalculationMethodF(heightCalculationMethod){
|
||||
heightCalcMode = heightCalculationMethod;
|
||||
checkHeightMode();
|
||||
},
|
||||
setTargetOrigin: function setTargetOriginF(targetOrigin){
|
||||
log('Set targetOrigin: '+targetOrigin);
|
||||
targetOriginDefault = targetOrigin;
|
||||
},
|
||||
size: function sizeF(customHeight, customWidth){
|
||||
var valString = ''+(customHeight?customHeight:'')+(customWidth?','+customWidth:'');
|
||||
lockTrigger();
|
||||
sendSize('size','parentIFrame.size('+valString+')', customHeight, customWidth);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function initInterval(){
|
||||
if ( 0 !== interval ){
|
||||
log('setInterval: '+interval+'ms');
|
||||
setInterval(function(){
|
||||
sendSize('interval','setInterval: '+interval);
|
||||
},Math.abs(interval));
|
||||
}
|
||||
}
|
||||
|
||||
function setupInjectElementLoadListners(mutations){
|
||||
function addLoadListener(element){
|
||||
if (element.height === undefined || element.width === undefined || 0 === element.height || 0 === element.width){
|
||||
log('Attach listerner to '+element.src);
|
||||
addEventListener(element,'load', function imageLoaded(){
|
||||
sendSize('imageLoad','Image loaded');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
mutations.forEach(function (mutation) {
|
||||
if (mutation.type === 'attributes' && mutation.attributeName === 'src'){
|
||||
addLoadListener(mutation.target);
|
||||
} else if (mutation.type === 'childList'){
|
||||
var images = mutation.target.querySelectorAll('img');
|
||||
Array.prototype.forEach.call(images,function (image) {
|
||||
addLoadListener(image);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setupMutationObserver(){
|
||||
|
||||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
||||
|
||||
function createMutationObserver(){
|
||||
var
|
||||
target = document.querySelector('body'),
|
||||
|
||||
config = {
|
||||
attributes : true,
|
||||
attributeOldValue : false,
|
||||
characterData : true,
|
||||
characterDataOldValue : false,
|
||||
childList : true,
|
||||
subtree : true
|
||||
},
|
||||
|
||||
observer = new MutationObserver(function(mutations) {
|
||||
sendSize('mutationObserver','mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type);
|
||||
setupInjectElementLoadListners(mutations); //Deal with WebKit asyncing image loading when tags are injected into the page
|
||||
});
|
||||
|
||||
log('Enable MutationObserver');
|
||||
observer.observe(target, config);
|
||||
}
|
||||
|
||||
if (MutationObserver){
|
||||
if (0 > interval) {
|
||||
initInterval();
|
||||
} else {
|
||||
createMutationObserver();
|
||||
}
|
||||
}
|
||||
else {
|
||||
warn('MutationObserver not supported in this browser!');
|
||||
initInterval();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// document.documentElement.offsetHeight is not reliable, so
|
||||
// we have to jump through hoops to get a better value.
|
||||
function getBodyOffsetHeight(){
|
||||
function getComputedBodyStyle(prop) {
|
||||
function convertUnitsToPxForIE8(value) {
|
||||
var PIXEL = /^\d+(px)?$/i;
|
||||
|
||||
if (PIXEL.test(value)) {
|
||||
return parseInt(value,base);
|
||||
}
|
||||
|
||||
var
|
||||
style = el.style.left,
|
||||
runtimeStyle = el.runtimeStyle.left;
|
||||
|
||||
el.runtimeStyle.left = el.currentStyle.left;
|
||||
el.style.left = value || 0;
|
||||
value = el.style.pixelLeft;
|
||||
el.style.left = style;
|
||||
el.runtimeStyle.left = runtimeStyle;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
var
|
||||
el = document.body,
|
||||
retVal = 0;
|
||||
|
||||
if (('defaultView' in document) && ('getComputedStyle' in document.defaultView)) {
|
||||
retVal = document.defaultView.getComputedStyle(el, null);
|
||||
retVal = (null !== retVal) ? retVal[prop] : 0;
|
||||
} else {//IE8
|
||||
retVal = convertUnitsToPxForIE8(el.currentStyle[prop]);
|
||||
}
|
||||
|
||||
return parseInt(retVal,base);
|
||||
}
|
||||
|
||||
return document.body.offsetHeight +
|
||||
getComputedBodyStyle('marginTop') +
|
||||
getComputedBodyStyle('marginBottom');
|
||||
}
|
||||
|
||||
function getBodyScrollHeight(){
|
||||
return document.body.scrollHeight;
|
||||
}
|
||||
|
||||
function getDEOffsetHeight(){
|
||||
return document.documentElement.offsetHeight;
|
||||
}
|
||||
|
||||
function getDEScrollHeight(){
|
||||
return document.documentElement.scrollHeight;
|
||||
}
|
||||
|
||||
//From https://github.com/guardian/iframe-messenger
|
||||
function getLowestElementHeight() {
|
||||
var
|
||||
allElements = document.querySelectorAll('body *'),
|
||||
allElementsLength = allElements.length,
|
||||
maxBottomVal = 0,
|
||||
timer = new Date().getTime();
|
||||
|
||||
for (var i = 0; i < allElementsLength; i++) {
|
||||
if (allElements[i].getBoundingClientRect().bottom > maxBottomVal) {
|
||||
maxBottomVal = allElements[i].getBoundingClientRect().bottom;
|
||||
}
|
||||
}
|
||||
|
||||
timer = new Date().getTime() - timer;
|
||||
|
||||
log('Parsed '+allElementsLength+' HTML elements');
|
||||
log('LowestElement bottom position calculated in ' + timer + 'ms');
|
||||
|
||||
return maxBottomVal;
|
||||
}
|
||||
|
||||
function getAllHeights(){
|
||||
return [
|
||||
getBodyOffsetHeight(),
|
||||
getBodyScrollHeight(),
|
||||
getDEOffsetHeight(),
|
||||
getDEScrollHeight()
|
||||
];
|
||||
}
|
||||
|
||||
function getMaxHeight(){
|
||||
return Math.max.apply(null,getAllHeights());
|
||||
}
|
||||
|
||||
function getMinHeight(){
|
||||
return Math.min.apply(null,getAllHeights());
|
||||
}
|
||||
|
||||
function getBestHeight(){
|
||||
return Math.max(getBodyOffsetHeight(),getLowestElementHeight());
|
||||
}
|
||||
|
||||
var getHeight = {
|
||||
offset : getBodyOffsetHeight, //Backward compatability
|
||||
bodyOffset : getBodyOffsetHeight,
|
||||
bodyScroll : getBodyScrollHeight,
|
||||
documentElementOffset : getDEOffsetHeight,
|
||||
scroll : getDEScrollHeight, //Backward compatability
|
||||
documentElementScroll : getDEScrollHeight,
|
||||
max : getMaxHeight,
|
||||
min : getMinHeight,
|
||||
grow : getMaxHeight,
|
||||
lowestElement : getBestHeight
|
||||
};
|
||||
|
||||
function getWidth(){
|
||||
return Math.max(
|
||||
document.documentElement.scrollWidth,
|
||||
document.body.scrollWidth
|
||||
);
|
||||
}
|
||||
|
||||
function sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth){
|
||||
|
||||
var currentHeight,currentWidth;
|
||||
|
||||
function recordTrigger(){
|
||||
if (!(triggerEvent in {'reset':1,'resetPage':1,'init':1})){
|
||||
log( 'Trigger event: ' + triggerEventDesc );
|
||||
}
|
||||
}
|
||||
|
||||
function resizeIFrame(){
|
||||
height = currentHeight;
|
||||
width = currentWidth;
|
||||
|
||||
sendMsg(height,width,triggerEvent);
|
||||
}
|
||||
|
||||
function isDoubleFiredEvent(){
|
||||
return triggerLocked && (triggerEvent in doubleEventList);
|
||||
}
|
||||
|
||||
function isSizeChangeDetected(){
|
||||
function checkTolarance(a,b){
|
||||
var retVal = Math.abs(a-b) <= tolerance;
|
||||
return !retVal;
|
||||
}
|
||||
|
||||
currentHeight = (undefined !== customHeight) ? customHeight : getHeight[heightCalcMode]();
|
||||
currentWidth = (undefined !== customWidth ) ? customWidth : getWidth();
|
||||
|
||||
return checkTolarance(height,currentHeight) ||
|
||||
(calculateWidth && checkTolarance(width,currentWidth));
|
||||
|
||||
//return (height !== currentHeight) ||
|
||||
// (calculateWidth && width !== currentWidth);
|
||||
}
|
||||
|
||||
function isForceResizableEvent(){
|
||||
return !(triggerEvent in {'init':1,'interval':1,'size':1});
|
||||
}
|
||||
|
||||
function isForceResizableHeightCalcMode(){
|
||||
return (heightCalcMode in resetRequiredMethods);
|
||||
}
|
||||
|
||||
function logIgnored(){
|
||||
log('No change in size detected');
|
||||
}
|
||||
|
||||
function checkDownSizing(){
|
||||
if (isForceResizableEvent() && isForceResizableHeightCalcMode()){
|
||||
resetIFrame(triggerEventDesc);
|
||||
} else if (!(triggerEvent in {'interval':1})){
|
||||
recordTrigger();
|
||||
logIgnored();
|
||||
}
|
||||
}
|
||||
|
||||
if (!isDoubleFiredEvent()){
|
||||
if (isSizeChangeDetected()){
|
||||
recordTrigger();
|
||||
lockTrigger();
|
||||
resizeIFrame();
|
||||
} else {
|
||||
checkDownSizing();
|
||||
}
|
||||
} else {
|
||||
log('Trigger event cancelled: '+triggerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
function lockTrigger(){
|
||||
if (!triggerLocked){
|
||||
triggerLocked = true;
|
||||
log('Trigger event lock on');
|
||||
}
|
||||
clearTimeout(triggerLockedTimer);
|
||||
triggerLockedTimer = setTimeout(function(){
|
||||
triggerLocked = false;
|
||||
log('Trigger event lock off');
|
||||
log('--');
|
||||
},eventCancelTimer);
|
||||
}
|
||||
|
||||
function triggerReset(triggerEvent){
|
||||
height = getHeight[heightCalcMode]();
|
||||
width = getWidth();
|
||||
|
||||
sendMsg(height,width,triggerEvent);
|
||||
}
|
||||
|
||||
function resetIFrame(triggerEventDesc){
|
||||
var hcm = heightCalcMode;
|
||||
heightCalcMode = heightCalcModeDefault;
|
||||
|
||||
log('Reset trigger event: ' + triggerEventDesc);
|
||||
lockTrigger();
|
||||
triggerReset('reset');
|
||||
|
||||
heightCalcMode = hcm;
|
||||
}
|
||||
|
||||
function sendMsg(height,width,triggerEvent,msg,targetOrigin){
|
||||
function setTargetOrigin(){
|
||||
if (undefined === targetOrigin){
|
||||
targetOrigin = targetOriginDefault;
|
||||
} else {
|
||||
log('Message targetOrigin: '+targetOrigin);
|
||||
}
|
||||
}
|
||||
|
||||
function sendToParent(){
|
||||
var
|
||||
size = height + ':' + width,
|
||||
message = myID + ':' + size + ':' + triggerEvent + (undefined !== msg ? ':' + msg : '');
|
||||
|
||||
log('Sending message to host page (' + message + ')');
|
||||
target.postMessage( msgID + message, targetOrigin);
|
||||
}
|
||||
|
||||
setTargetOrigin();
|
||||
sendToParent();
|
||||
}
|
||||
|
||||
function receiver(event) {
|
||||
function isMessageForUs(){
|
||||
return msgID === (''+event.data).substr(0,msgIdLen); //''+ Protects against non-string messages
|
||||
}
|
||||
|
||||
function initFromParent(){
|
||||
initMsg = event.data;
|
||||
target = event.source;
|
||||
|
||||
init();
|
||||
firstRun = false;
|
||||
setTimeout(function(){ initLock = false;},eventCancelTimer);
|
||||
}
|
||||
|
||||
function resetFromParent(){
|
||||
if (!initLock){
|
||||
log('Page size reset by host page');
|
||||
triggerReset('resetPage');
|
||||
} else {
|
||||
log('Page reset ignored by init');
|
||||
}
|
||||
}
|
||||
|
||||
function getMessageType(){
|
||||
return event.data.split(']')[1];
|
||||
}
|
||||
|
||||
function isMiddleTier(){
|
||||
return ('iFrameResize' in window);
|
||||
}
|
||||
|
||||
function isInitMsg(){
|
||||
//test if this message is from a child below us. This is an ugly test, however, updating
|
||||
//the message format would break backwards compatibity.
|
||||
return event.data.split(':')[2] in {'true':1,'false':1};
|
||||
}
|
||||
|
||||
if (isMessageForUs()){
|
||||
if (firstRun && isInitMsg()){ //Check msg ID
|
||||
initFromParent();
|
||||
} else if ('reset' === getMessageType()){
|
||||
resetFromParent();
|
||||
} else if (event.data !== initMsg && !isMiddleTier()){
|
||||
warn('Unexpected message ('+event.data+')');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addEventListener(window, 'message', receiver);
|
||||
|
||||
})();
|
442
PocoDoc/resources/js/iframeResizer.js
Executable file
442
PocoDoc/resources/js/iframeResizer.js
Executable file
@ -0,0 +1,442 @@
|
||||
/*
|
||||
* File: iframeReizer.js
|
||||
* Desc: Force iframes to size to content.
|
||||
* Requires: iframeResizer.contentWindow.js to be loaded into the target frame.
|
||||
* Author: David J. Bradshaw - dave@bradshaw.net
|
||||
* Contributor: Jure Mav - jure.mav@gmail.com
|
||||
*/
|
||||
;(function() {
|
||||
'use strict';
|
||||
|
||||
var
|
||||
count = 0,
|
||||
firstRun = true,
|
||||
msgHeader = 'message',
|
||||
msgHeaderLen = msgHeader.length,
|
||||
msgId = '[iFrameSizer]', //Must match iframe msg ID
|
||||
msgIdLen = msgId.length,
|
||||
page = '', //:'+location.href, //Uncoment to debug nested iFrames
|
||||
pagePosition = null,
|
||||
requestAnimationFrame = window.requestAnimationFrame,
|
||||
resetRequiredMethods = {max:1,scroll:1,bodyScroll:1,documentElementScroll:1},
|
||||
settings = {},
|
||||
|
||||
defaults = {
|
||||
autoResize : true,
|
||||
bodyBackground : null,
|
||||
bodyMargin : null,
|
||||
bodyMarginV1 : 8,
|
||||
bodyPadding : null,
|
||||
checkOrigin : true,
|
||||
enablePublicMethods : false,
|
||||
heightCalculationMethod : 'offset',
|
||||
interval : 32,
|
||||
log : false,
|
||||
maxHeight : Infinity,
|
||||
maxWidth : Infinity,
|
||||
minHeight : 0,
|
||||
minWidth : 0,
|
||||
scrolling : false,
|
||||
sizeHeight : true,
|
||||
sizeWidth : false,
|
||||
tolerance : 0,
|
||||
closedCallback : function(){},
|
||||
initCallback : function(){},
|
||||
messageCallback : function(){},
|
||||
resizedCallback : function(){}
|
||||
};
|
||||
|
||||
function addEventListener(obj,evt,func){
|
||||
if ('addEventListener' in window){
|
||||
obj.addEventListener(evt,func, false);
|
||||
} else if ('attachEvent' in window){//IE
|
||||
obj.attachEvent('on'+evt,func);
|
||||
}
|
||||
}
|
||||
|
||||
function setupRequestAnimationFrame(){
|
||||
var
|
||||
vendors = ['moz', 'webkit', 'o', 'ms'],
|
||||
x;
|
||||
|
||||
// Remove vendor prefixing if prefixed and break early if not
|
||||
for (x = 0; x < vendors.length && !requestAnimationFrame; x += 1) {
|
||||
requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
|
||||
}
|
||||
|
||||
if (!(requestAnimationFrame)){
|
||||
log(' RequestAnimationFrame not supported');
|
||||
}
|
||||
}
|
||||
|
||||
function log(msg){
|
||||
if (settings.log && (typeof console === 'object')){
|
||||
console.log(msgId + '[Host page'+page+']' + msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function iFrameListener(event){
|
||||
function resizeIFrame(){
|
||||
function resize(){
|
||||
setSize(messageData);
|
||||
setPagePosition();
|
||||
settings.resizedCallback(messageData);
|
||||
}
|
||||
|
||||
syncResize(resize,messageData,'resetPage');
|
||||
}
|
||||
|
||||
function closeIFrame(iframe){
|
||||
var iframeID = iframe.id;
|
||||
|
||||
log(' Removing iFrame: '+iframeID);
|
||||
iframe.parentNode.removeChild(iframe);
|
||||
settings.closedCallback(iframeID);
|
||||
log(' --');
|
||||
}
|
||||
|
||||
function processMsg(){
|
||||
var data = msg.substr(msgIdLen).split(':');
|
||||
|
||||
return {
|
||||
iframe: document.getElementById(data[0]),
|
||||
id: data[0],
|
||||
height: data[1],
|
||||
width: data[2],
|
||||
type: data[3]
|
||||
};
|
||||
}
|
||||
|
||||
function ensureInRange(Dimension){
|
||||
var
|
||||
max = Number(settings['max'+Dimension]),
|
||||
min = Number(settings['min'+Dimension]),
|
||||
dimension = Dimension.toLowerCase(),
|
||||
size = Number(messageData[dimension]);
|
||||
|
||||
if (min>max){
|
||||
throw new Error('Value for min'+Dimension+' can not be greater than max'+Dimension);
|
||||
}
|
||||
|
||||
log(' Checking '+dimension+' is in range '+min+'-'+max);
|
||||
|
||||
if (size<min) {
|
||||
size=min;
|
||||
log(' Set '+dimension+' to min value');
|
||||
}
|
||||
|
||||
if (size>max) {
|
||||
size=max;
|
||||
log(' Set '+dimension+' to max value');
|
||||
}
|
||||
|
||||
messageData[dimension]=''+size;
|
||||
}
|
||||
|
||||
function isMessageFromIFrame(){
|
||||
|
||||
var
|
||||
origin = event.origin,
|
||||
remoteHost = messageData.iframe.src.split('/').slice(0,3).join('/');
|
||||
|
||||
if (settings.checkOrigin) {
|
||||
log(' Checking connection is from: '+remoteHost);
|
||||
|
||||
if ((''+origin !== 'null') && (origin !== remoteHost)) {
|
||||
throw new Error(
|
||||
'Unexpected message received from: ' + origin +
|
||||
' for ' + messageData.iframe.id +
|
||||
'. Message was: ' + event.data +
|
||||
'. This error can be disabled by adding the checkOrigin: false option.'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function isMessageForUs(){
|
||||
return msgId === ('' + msg).substr(0,msgIdLen); //''+Protects against non-string msg
|
||||
}
|
||||
|
||||
function isMessageFromMetaParent(){
|
||||
//test if this message is from a parent above us. This is an ugly test, however, updating
|
||||
//the message format would break backwards compatibity.
|
||||
var retCode = messageData.type in {'true':1,'false':1};
|
||||
|
||||
if (retCode){
|
||||
log(' Ignoring init message from meta parent page');
|
||||
}
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
function forwardMsgFromIFrame(){
|
||||
var msgBody = msg.substr(msg.indexOf(':')+msgHeaderLen+6); //6 === ':0:0:' + ':' (Ideas to name this magic number most welcome)
|
||||
|
||||
log(' MessageCallback passed: {iframe: '+ messageData.iframe.id + ', message: ' + msgBody + '}');
|
||||
settings.messageCallback({
|
||||
iframe: messageData.iframe,
|
||||
message: msgBody
|
||||
});
|
||||
log(' --');
|
||||
}
|
||||
|
||||
function checkIFrameExists(){
|
||||
if (null === messageData.iframe) {
|
||||
throw new Error('iFrame ('+messageData.id+') does not exist on ' + page);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function scrollRequestFromChild(){
|
||||
log(' Reposition requested from iFrame');
|
||||
pagePosition = {
|
||||
x: messageData.width,
|
||||
y: messageData.height
|
||||
};
|
||||
setPagePosition();
|
||||
}
|
||||
|
||||
function actionMsg(){
|
||||
switch(messageData.type){
|
||||
case 'close':
|
||||
closeIFrame(messageData.iframe);
|
||||
settings.resizedCallback(messageData); //To be removed.
|
||||
break;
|
||||
case 'message':
|
||||
forwardMsgFromIFrame();
|
||||
break;
|
||||
case 'scrollTo':
|
||||
scrollRequestFromChild();
|
||||
break;
|
||||
case 'reset':
|
||||
resetIFrame(messageData);
|
||||
break;
|
||||
case 'init':
|
||||
resizeIFrame();
|
||||
settings.initCallback(messageData.iframe);
|
||||
break;
|
||||
default:
|
||||
resizeIFrame();
|
||||
}
|
||||
}
|
||||
|
||||
var
|
||||
msg = event.data,
|
||||
messageData = {};
|
||||
|
||||
if (isMessageForUs()){
|
||||
log(' Received: '+msg);
|
||||
messageData = processMsg();
|
||||
ensureInRange('Height');
|
||||
ensureInRange('Width');
|
||||
|
||||
if ( !isMessageFromMetaParent() && checkIFrameExists() && isMessageFromIFrame() ){
|
||||
actionMsg();
|
||||
firstRun = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getPagePosition (){
|
||||
if(null === pagePosition){
|
||||
pagePosition = {
|
||||
x: (window.pageXOffset !== undefined) ? window.pageXOffset : document.documentElement.scrollLeft,
|
||||
y: (window.pageYOffset !== undefined) ? window.pageYOffset : document.documentElement.scrollTop
|
||||
};
|
||||
log(' Get position: '+pagePosition.x+','+pagePosition.y);
|
||||
}
|
||||
}
|
||||
|
||||
function setPagePosition(){
|
||||
if(null !== pagePosition){
|
||||
window.scrollTo(pagePosition.x,pagePosition.y);
|
||||
log(' Set position: '+pagePosition.x+','+pagePosition.y);
|
||||
pagePosition = null;
|
||||
}
|
||||
}
|
||||
|
||||
function resetIFrame(messageData){
|
||||
function reset(){
|
||||
setSize(messageData);
|
||||
trigger('reset','reset',messageData.iframe);
|
||||
}
|
||||
|
||||
log(' Size reset requested by '+('init'===messageData.type?'host page':'iFrame'));
|
||||
getPagePosition();
|
||||
syncResize(reset,messageData,'init');
|
||||
}
|
||||
|
||||
function setSize(messageData){
|
||||
function setDimension(dimension){
|
||||
messageData.iframe.style[dimension] = messageData[dimension] + 'px';
|
||||
log(
|
||||
' IFrame (' + messageData.iframe.id +
|
||||
') ' + dimension +
|
||||
' set to ' + messageData[dimension] + 'px'
|
||||
);
|
||||
}
|
||||
|
||||
if( settings.sizeHeight) { setDimension('height'); }
|
||||
if( settings.sizeWidth ) { setDimension('width'); }
|
||||
}
|
||||
|
||||
function syncResize(func,messageData,doNotSync){
|
||||
if(doNotSync!==messageData.type && requestAnimationFrame){
|
||||
log(' Requesting animation frame');
|
||||
requestAnimationFrame(func);
|
||||
} else {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
function trigger(calleeMsg,msg,iframe){
|
||||
log('[' + calleeMsg + '] Sending msg to iframe ('+msg+')');
|
||||
iframe.contentWindow.postMessage( msgId + msg, '*' );
|
||||
}
|
||||
|
||||
|
||||
function setupIFrame(){
|
||||
function setLimits(){
|
||||
function addStyle(style){
|
||||
if ((Infinity !== settings[style]) && (0 !== settings[style])){
|
||||
iframe.style[style] = settings[style] + 'px';
|
||||
log(' Set '+style+' = '+settings[style]+'px');
|
||||
}
|
||||
}
|
||||
|
||||
addStyle('maxHeight');
|
||||
addStyle('minHeight');
|
||||
addStyle('maxWidth');
|
||||
addStyle('minWidth');
|
||||
}
|
||||
|
||||
function ensureHasId(iframeID){
|
||||
if (''===iframeID){
|
||||
iframe.id = iframeID = 'iFrameResizer' + count++;
|
||||
log(' Added missing iframe ID: '+ iframeID +' (' + iframe.src + ')');
|
||||
}
|
||||
|
||||
return iframeID;
|
||||
}
|
||||
|
||||
function setScrolling(){
|
||||
log(' IFrame scrolling ' + (settings.scrolling ? 'enabled' : 'disabled') + ' for ' + iframeID);
|
||||
iframe.style.overflow = false === settings.scrolling ? 'hidden' : 'auto';
|
||||
iframe.scrolling = false === settings.scrolling ? 'no' : 'yes';
|
||||
}
|
||||
|
||||
//The V1 iFrame script expects an int, where as in V2 expects a CSS
|
||||
//string value such as '1px 3em', so if we have an int for V2, set V1=V2
|
||||
//and then convert V2 to a string PX value.
|
||||
function setupBodyMarginValues(){
|
||||
if (('number'===typeof(settings.bodyMargin)) || ('0'===settings.bodyMargin)){
|
||||
settings.bodyMarginV1 = settings.bodyMargin;
|
||||
settings.bodyMargin = '' + settings.bodyMargin + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
function createOutgoingMsg(){
|
||||
return iframeID +
|
||||
':' + settings.bodyMarginV1 +
|
||||
':' + settings.sizeWidth +
|
||||
':' + settings.log +
|
||||
':' + settings.interval +
|
||||
':' + settings.enablePublicMethods +
|
||||
':' + settings.autoResize +
|
||||
':' + settings.bodyMargin +
|
||||
':' + settings.heightCalculationMethod +
|
||||
':' + settings.bodyBackground +
|
||||
':' + settings.bodyPadding +
|
||||
':' + settings.tolerance;
|
||||
}
|
||||
|
||||
function init(msg){
|
||||
//We have to call trigger twice, as we can not be sure if all
|
||||
//iframes have completed loading when this code runs. The
|
||||
//event listener also catches the page changing in the iFrame.
|
||||
addEventListener(iframe,'load',function(){
|
||||
var fr = firstRun; // Reduce scope of var to function, because IE8's JS execution
|
||||
// context stack is borked and this value gets externally
|
||||
// changed midway through running this function.
|
||||
trigger('iFrame.onload',msg,iframe);
|
||||
if (!fr && settings.heightCalculationMethod in resetRequiredMethods){
|
||||
resetIFrame({
|
||||
iframe:iframe,
|
||||
height:0,
|
||||
width:0,
|
||||
type:'init'
|
||||
});
|
||||
}
|
||||
});
|
||||
trigger('init',msg,iframe);
|
||||
}
|
||||
|
||||
var
|
||||
/*jshint validthis:true */
|
||||
iframe = this,
|
||||
iframeID = ensureHasId(iframe.id);
|
||||
|
||||
setScrolling();
|
||||
setLimits();
|
||||
setupBodyMarginValues();
|
||||
init(createOutgoingMsg());
|
||||
}
|
||||
|
||||
function checkOptions(options){
|
||||
if ('object' !== typeof options){
|
||||
throw new TypeError('Options is not an object.');
|
||||
}
|
||||
}
|
||||
|
||||
function createNativePublicFunction(){
|
||||
function init(element){
|
||||
if('IFRAME' !== element.tagName.toUpperCase()) {
|
||||
throw new TypeError('Expected <IFRAME> tag, found <'+element.tagName+'>.');
|
||||
} else {
|
||||
setupIFrame.call(element);
|
||||
}
|
||||
}
|
||||
|
||||
function processOptions(options){
|
||||
options = options || {};
|
||||
|
||||
checkOptions(options);
|
||||
|
||||
for (var option in defaults) {
|
||||
if (defaults.hasOwnProperty(option)){
|
||||
settings[option] = options.hasOwnProperty(option) ? options[option] : defaults[option];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return function iFrameResizeF(options,selecter){
|
||||
processOptions(options);
|
||||
Array.prototype.forEach.call( document.querySelectorAll( selecter || 'iframe' ), init );
|
||||
};
|
||||
}
|
||||
|
||||
function createJQueryPublicMethod($){
|
||||
$.fn.iFrameResize = function $iFrameResizeF(options) {
|
||||
options = options || {};
|
||||
checkOptions(options);
|
||||
settings = $.extend( {}, defaults, options );
|
||||
return this.filter('iframe').each( setupIFrame ).end();
|
||||
};
|
||||
}
|
||||
|
||||
setupRequestAnimationFrame();
|
||||
addEventListener(window,'message',iFrameListener);
|
||||
|
||||
if (window.jQuery) { createJQueryPublicMethod(jQuery); }
|
||||
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
define(function (){ return createNativePublicFunction(); });
|
||||
} else {
|
||||
window.iFrameResize = createNativePublicFunction();
|
||||
}
|
||||
|
||||
})();
|
Loading…
Reference in New Issue
Block a user