Merge remote-tracking branch 'n/cst-next'

This commit is contained in:
Stefan Seyfried
2016-01-17 19:10:10 +01:00
11 changed files with 214 additions and 135 deletions

View File

@@ -76,7 +76,6 @@ license you like.
#ifndef JSON_AMALGATED_H_INCLUDED #ifndef JSON_AMALGATED_H_INCLUDED
# define JSON_AMALGATED_H_INCLUDED # define JSON_AMALGATED_H_INCLUDED
/// If defined, indicates that the source file is amalgated /// If defined, indicates that the source file is amalgated
@@ -87,16 +86,15 @@ license you like.
// Beginning of content of file: include/json/version.h // Beginning of content of file: include/json/version.h
// ////////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////////
// DO NOT EDIT. This file is generated by CMake from "version" // DO NOT EDIT. This file (and "version") is generated by CMake.
// and "version.h.in" files.
// Run CMake configure step to update it. // Run CMake configure step to update it.
#ifndef JSON_VERSION_H_INCLUDED #ifndef JSON_VERSION_H_INCLUDED
# define JSON_VERSION_H_INCLUDED # define JSON_VERSION_H_INCLUDED
# define JSONCPP_VERSION_STRING "0.10.2" # define JSONCPP_VERSION_STRING "0.10.5"
# define JSONCPP_VERSION_MAJOR 0 # define JSONCPP_VERSION_MAJOR 0
# define JSONCPP_VERSION_MINOR 10 # define JSONCPP_VERSION_MINOR 10
# define JSONCPP_VERSION_PATCH 2 # define JSONCPP_VERSION_PATCH 5
# define JSONCPP_VERSION_QUALIFIER # define JSONCPP_VERSION_QUALIFIER
# define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8)) # define JSONCPP_VERSION_HEXA ((JSONCPP_VERSION_MAJOR << 24) | (JSONCPP_VERSION_MINOR << 16) | (JSONCPP_VERSION_PATCH << 8))
@@ -393,21 +391,36 @@ namespace Json {
* *
* We use nothing but these internally. Of course, STL can throw others. * We use nothing but these internally. Of course, STL can throw others.
*/ */
class JSON_API Exception; class JSON_API Exception : public std::exception {
public:
Exception(std::string const& msg);
virtual ~Exception() throw();
virtual char const* what() const throw();
protected:
std::string const msg_;
};
/** Exceptions which the user cannot easily avoid. /** Exceptions which the user cannot easily avoid.
* *
* E.g. out-of-memory (when we use malloc), stack-overflow, malicious input * E.g. out-of-memory (when we use malloc), stack-overflow, malicious input
* *
* \remark derived from Json::Exception * \remark derived from Json::Exception
*/ */
class JSON_API RuntimeError; class JSON_API RuntimeError : public Exception {
public:
RuntimeError(std::string const& msg);
};
/** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros. /** Exceptions thrown by JSON_ASSERT/JSON_FAIL macros.
* *
* These are precondition-violations (user bugs) and internal errors (our bugs). * These are precondition-violations (user bugs) and internal errors (our bugs).
* *
* \remark derived from Json::Exception * \remark derived from Json::Exception
*/ */
class JSON_API LogicError; class JSON_API LogicError : public Exception {
public:
LogicError(std::string const& msg);
};
/// used internally /// used internally
void throwRuntimeError(std::string const& msg); void throwRuntimeError(std::string const& msg);
@@ -570,7 +583,7 @@ private:
void swap(CZString& other); void swap(CZString& other);
struct StringStorage { struct StringStorage {
DuplicationPolicy policy_: 2; unsigned policy_: 2;
unsigned length_: 30; // 1GB max unsigned length_: 30; // 1GB max
}; };
@@ -614,7 +627,7 @@ Json::Value obj_value(Json::objectValue); // {}
#endif // if defined(JSON_HAS_INT64) #endif // if defined(JSON_HAS_INT64)
Value(double value); Value(double value);
Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.) Value(const char* value); ///< Copy til first 0. (NULL causes to seg-fault.)
Value(const char* beginValue, const char* endValue); ///< Copy all, incl zeroes. Value(const char* begin, const char* end); ///< Copy all, incl zeroes.
/** \brief Constructs a value from a static string. /** \brief Constructs a value from a static string.
* Like other value string constructor but do not duplicate the string for * Like other value string constructor but do not duplicate the string for
@@ -665,7 +678,7 @@ Json::Value obj_value(Json::objectValue); // {}
* \return false if !string. (Seg-fault if str or end are NULL.) * \return false if !string. (Seg-fault if str or end are NULL.)
*/ */
bool getString( bool getString(
char const** str, char const** end) const; char const** begin, char const** end) const;
#ifdef JSON_USE_CPPTL #ifdef JSON_USE_CPPTL
CppTL::ConstString asConstString() const; CppTL::ConstString asConstString() const;
#endif #endif
@@ -794,8 +807,8 @@ Json::Value obj_value(Json::objectValue); // {}
Value get(const char* key, const Value& defaultValue) const; Value get(const char* key, const Value& defaultValue) const;
/// Return the member named key if it exist, defaultValue otherwise. /// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy /// \note deep copy
/// \param key may contain embedded nulls. /// \note key may contain embedded nulls.
Value get(const char* key, const char* end, const Value& defaultValue) const; Value get(const char* begin, const char* end, const Value& defaultValue) const;
/// Return the member named key if it exist, defaultValue otherwise. /// Return the member named key if it exist, defaultValue otherwise.
/// \note deep copy /// \note deep copy
/// \param key may contain embedded nulls. /// \param key may contain embedded nulls.
@@ -807,12 +820,12 @@ Json::Value obj_value(Json::objectValue); // {}
#endif #endif
/// Most general and efficient version of isMember()const, get()const, /// Most general and efficient version of isMember()const, get()const,
/// and operator[]const /// and operator[]const
/// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30 /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
Value const* find(char const* key, char const* end) const; Value const* find(char const* begin, char const* end) const;
/// Most general and efficient version of object-mutators. /// Most general and efficient version of object-mutators.
/// \note As stated elsewhere, behavior is undefined if (end-key) >= 2^30 /// \note As stated elsewhere, behavior is undefined if (end-begin) >= 2^30
/// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue. /// \return non-zero, but JSON_ASSERT if this is neither object nor nullValue.
Value const* demand(char const* key, char const* end); Value const* demand(char const* begin, char const* end);
/// \brief Remove and return the named member. /// \brief Remove and return the named member.
/// ///
/// Do nothing if it did not exist. /// Do nothing if it did not exist.
@@ -825,7 +838,7 @@ Json::Value obj_value(Json::objectValue); // {}
/// \param key may contain embedded nulls. /// \param key may contain embedded nulls.
/// \deprecated /// \deprecated
Value removeMember(const std::string& key); Value removeMember(const std::string& key);
/// Same as removeMember(const char* key, const char* end, Value* removed), /// Same as removeMember(const char* begin, const char* end, Value* removed),
/// but 'key' is null-terminated. /// but 'key' is null-terminated.
bool removeMember(const char* key, Value* removed); bool removeMember(const char* key, Value* removed);
/** \brief Remove the named map member. /** \brief Remove the named map member.
@@ -836,7 +849,7 @@ Json::Value obj_value(Json::objectValue); // {}
*/ */
bool removeMember(std::string const& key, Value* removed); bool removeMember(std::string const& key, Value* removed);
/// Same as removeMember(std::string const& key, Value* removed) /// Same as removeMember(std::string const& key, Value* removed)
bool removeMember(const char* key, const char* end, Value* removed); bool removeMember(const char* begin, const char* end, Value* removed);
/** \brief Remove the indexed array element. /** \brief Remove the indexed array element.
O(n) expensive operations. O(n) expensive operations.
@@ -852,7 +865,7 @@ Json::Value obj_value(Json::objectValue); // {}
/// \param key may contain embedded nulls. /// \param key may contain embedded nulls.
bool isMember(const std::string& key) const; bool isMember(const std::string& key) const;
/// Same as isMember(std::string const& key)const /// Same as isMember(std::string const& key)const
bool isMember(const char* key, const char* end) const; bool isMember(const char* begin, const char* end) const;
#ifdef JSON_USE_CPPTL #ifdef JSON_USE_CPPTL
/// Return true if the object has a member named key. /// Return true if the object has a member named key.
bool isMember(const CppTL::ConstString& key) const; bool isMember(const CppTL::ConstString& key) const;
@@ -1000,9 +1013,6 @@ public:
typedef int difference_type; typedef int difference_type;
typedef ValueIteratorBase SelfType; typedef ValueIteratorBase SelfType;
ValueIteratorBase();
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
bool operator==(const SelfType& other) const { return isEqual(other); } bool operator==(const SelfType& other) const { return isEqual(other); }
bool operator!=(const SelfType& other) const { return !isEqual(other); } bool operator!=(const SelfType& other) const { return !isEqual(other); }
@@ -1050,6 +1060,12 @@ private:
Value::ObjectValues::iterator current_; Value::ObjectValues::iterator current_;
// Indicates that iterator is for a null value. // Indicates that iterator is for a null value.
bool isNull_; bool isNull_;
public:
// For some reason, BORLAND needs these at the end, rather
// than earlier. No idea why.
ValueIteratorBase();
explicit ValueIteratorBase(const Value::ObjectValues::iterator& current);
}; };
/** \brief const iterator for object and array value. /** \brief const iterator for object and array value.
@@ -1486,13 +1502,13 @@ public:
/** Called by ctor, but you can use this to reset settings_. /** Called by ctor, but you can use this to reset settings_.
* \pre 'settings' != NULL (but Json::null is fine) * \pre 'settings' != NULL (but Json::null is fine)
* \remark Defaults: * \remark Defaults:
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode * \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults
*/ */
static void setDefaults(Json::Value* settings); static void setDefaults(Json::Value* settings);
/** Same as old Features::strictMode(). /** Same as old Features::strictMode().
* \pre 'settings' != NULL (but Json::null is fine) * \pre 'settings' != NULL (but Json::null is fine)
* \remark Defaults: * \remark Defaults:
* \snippet src/lib_json/json_reader.cpp CharReaderBuilderDefaults * \snippet src/lib_json/json_reader.cpp CharReaderBuilderStrictMode
*/ */
static void strictMode(Json::Value* settings); static void strictMode(Json::Value* settings);
}; };

View File

@@ -116,8 +116,8 @@ static inline std::string codePointToUTF8(unsigned int cp) {
} else if (cp <= 0xFFFF) { } else if (cp <= 0xFFFF) {
result.resize(3); result.resize(3);
result[2] = static_cast<char>(0x80 | (0x3f & cp)); result[2] = static_cast<char>(0x80 | (0x3f & cp));
result[1] = 0x80 | static_cast<char>((0x3f & (cp >> 6))); result[1] = static_cast<char>(0x80 | (0x3f & (cp >> 6)));
result[0] = 0xE0 | static_cast<char>((0xf & (cp >> 12))); result[0] = static_cast<char>(0xE0 | (0xf & (cp >> 12)));
} else if (cp <= 0x10FFFF) { } else if (cp <= 0x10FFFF) {
result.resize(4); result.resize(4);
result[3] = static_cast<char>(0x80 | (0x3f & cp)); result[3] = static_cast<char>(0x80 | (0x3f & cp));
@@ -129,7 +129,7 @@ static inline std::string codePointToUTF8(unsigned int cp) {
return result; return result;
} }
/// Returns true if ch is a control character (in range [0,32[). /// Returns true if ch is a control character (in range [1,31]).
static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; } static inline bool isControlCharacter(char ch) { return ch > 0 && ch <= 0x1F; }
enum { enum {
@@ -149,7 +149,7 @@ typedef char UIntToStringBuffer[uintToStringBufferSize];
static inline void uintToString(LargestUInt value, char*& current) { static inline void uintToString(LargestUInt value, char*& current) {
*--current = 0; *--current = 0;
do { do {
*--current = char(value % 10) + '0'; *--current = static_cast<signed char>(value % 10U + static_cast<unsigned>('0'));
value /= 10; value /= 10;
} while (value != 0); } while (value != 0);
} }
@@ -219,11 +219,7 @@ static int stackDepth_g = 0; // see readValue()
namespace Json { namespace Json {
#if __cplusplus >= 201103L
typedef std::unique_ptr<CharReader> CharReaderPtr;
#else
typedef std::auto_ptr<CharReader> CharReaderPtr; typedef std::auto_ptr<CharReader> CharReaderPtr;
#endif
// Implementation of class Features // Implementation of class Features
// //////////////////////////////// // ////////////////////////////////
@@ -748,33 +744,9 @@ bool Reader::decodeDouble(Token& token) {
bool Reader::decodeDouble(Token& token, Value& decoded) { bool Reader::decodeDouble(Token& token, Value& decoded) {
double value = 0; double value = 0;
const int bufferSize = 32;
int count;
int length = int(token.end_ - token.start_);
// Sanity check to avoid buffer overflow exploits.
if (length < 0) {
return addError("Unable to parse token length", token);
}
// Avoid using a string constant for the format control string given to
// sscanf, as this can cause hard to debug crashes on OS X. See here for more
// info:
//
// http://developer.apple.com/library/mac/#DOCUMENTATION/DeveloperTools/gcc-4.0.1/gcc/Incompatibilities.html
char format[] = "%lf";
if (length <= bufferSize) {
Char buffer[bufferSize + 1];
memcpy(buffer, token.start_, length);
buffer[length] = 0;
count = sscanf(buffer, format, &value);
} else {
std::string buffer(token.start_, token.end_); std::string buffer(token.start_, token.end_);
count = sscanf(buffer.c_str(), format, &value); std::istringstream is(buffer);
} if (!(is >> value))
if (count != 1)
return addError("'" + std::string(token.start_, token.end_) + return addError("'" + std::string(token.start_, token.end_) +
"' is not a number.", "' is not a number.",
token); token);
@@ -2128,26 +2100,26 @@ UInt ValueIteratorBase::index() const {
} }
std::string ValueIteratorBase::name() const { std::string ValueIteratorBase::name() const {
char const* mykey; char const* keey;
char const* end; char const* end;
mykey = memberName(&end); keey = memberName(&end);
if (!mykey) return std::string(); if (!keey) return std::string();
return std::string(mykey, end); return std::string(keey, end);
} }
char const* ValueIteratorBase::memberName() const { char const* ValueIteratorBase::memberName() const {
const char* myname = (*current_).first.data(); const char* cname = (*current_).first.data();
return myname ? myname : ""; return cname ? cname : "";
} }
char const* ValueIteratorBase::memberName(char const** end) const { char const* ValueIteratorBase::memberName(char const** end) const {
const char* myname = (*current_).first.data(); const char* cname = (*current_).first.data();
if (!myname) { if (!cname) {
*end = NULL; *end = NULL;
return NULL; return NULL;
} }
*end = myname + (*current_).first.length(); *end = cname + (*current_).first.length();
return myname; return cname;
} }
// ////////////////////////////////////////////////////////////////// // //////////////////////////////////////////////////////////////////
@@ -2320,7 +2292,7 @@ static inline char* duplicateAndPrefixStringValue(
JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U, JSON_ASSERT_MESSAGE(length <= (unsigned)Value::maxInt - sizeof(unsigned) - 1U,
"in Json::Value::duplicateAndPrefixStringValue(): " "in Json::Value::duplicateAndPrefixStringValue(): "
"length too big for prefixing"); "length too big for prefixing");
unsigned actualLength = length + sizeof(unsigned) + 1U; unsigned actualLength = length + static_cast<unsigned>(sizeof(unsigned)) + 1U;
char* newString = static_cast<char*>(malloc(actualLength)); char* newString = static_cast<char*>(malloc(actualLength));
if (newString == 0) { if (newString == 0) {
throwRuntimeError( throwRuntimeError(
@@ -2337,7 +2309,7 @@ inline static void decodePrefixedString(
unsigned* length, char const** value) unsigned* length, char const** value)
{ {
if (!isPrefixed) { if (!isPrefixed) {
*length = strlen(prefixed); *length = static_cast<unsigned>(strlen(prefixed));
*value = prefixed; *value = prefixed;
} else { } else {
*length = *reinterpret_cast<unsigned const*>(prefixed); *length = *reinterpret_cast<unsigned const*>(prefixed);
@@ -2364,23 +2336,6 @@ static inline void releaseStringValue(char* value) { free(value); }
namespace Json { namespace Json {
class JSON_API Exception : public std::exception {
public:
Exception(std::string const& msg);
virtual ~Exception() throw();
virtual char const* what() const throw();
protected:
std::string const msg_;
};
class JSON_API RuntimeError : public Exception {
public:
RuntimeError(std::string const& msg);
};
class JSON_API LogicError : public Exception {
public:
LogicError(std::string const& msg);
};
Exception::Exception(std::string const& msg) Exception::Exception(std::string const& msg)
: msg_(msg) : msg_(msg)
{} {}
@@ -2450,8 +2405,8 @@ Value::CZString::CZString(char const* str, unsigned ulength, DuplicationPolicy a
: cstr_(str) : cstr_(str)
{ {
// allocate != duplicate // allocate != duplicate
storage_.policy_ = allocate; storage_.policy_ = allocate & 0x3;
storage_.length_ = ulength; storage_.length_ = ulength & 0x3FFFFFFF;
} }
Value::CZString::CZString(const CZString& other) Value::CZString::CZString(const CZString& other)
@@ -2460,9 +2415,9 @@ Value::CZString::CZString(const CZString& other)
: other.cstr_) : other.cstr_)
{ {
storage_.policy_ = (other.cstr_ storage_.policy_ = (other.cstr_
? (other.storage_.policy_ == noDuplication ? (static_cast<DuplicationPolicy>(other.storage_.policy_) == noDuplication
? noDuplication : duplicate) ? noDuplication : duplicate)
: other.storage_.policy_); : static_cast<DuplicationPolicy>(other.storage_.policy_));
storage_.length_ = other.storage_.length_; storage_.length_ = other.storage_.length_;
} }
@@ -2691,7 +2646,7 @@ void Value::swapPayload(Value& other) {
std::swap(value_, other.value_); std::swap(value_, other.value_);
int temp2 = allocated_; int temp2 = allocated_;
allocated_ = other.allocated_; allocated_ = other.allocated_;
other.allocated_ = temp2; other.allocated_ = temp2 & 0x1;
} }
void Value::swap(Value& other) { void Value::swap(Value& other) {
@@ -2817,12 +2772,12 @@ const char* Value::asCString() const {
return this_str; return this_str;
} }
bool Value::getString(char const** str, char const** myend) const { bool Value::getString(char const** str, char const** cend) const {
if (type_ != stringValue) return false; if (type_ != stringValue) return false;
if (value_.string_ == 0) return false; if (value_.string_ == 0) return false;
unsigned length; unsigned length;
decodePrefixedString(this->allocated_, this->value_.string_, &length, str); decodePrefixedString(this->allocated_, this->value_.string_, &length, str);
*myend = *str + length; *cend = *str + length;
return true; return true;
} }
@@ -3021,7 +2976,8 @@ bool Value::asBool() const {
case uintValue: case uintValue:
return value_.uint_ ? true : false; return value_.uint_ ? true : false;
case realValue: case realValue:
return value_.real_ ? true : false; // This is kind of strange. Not recommended.
return (value_.real_ != 0.0) ? true : false;
default: default:
break; break;
} }
@@ -3197,15 +3153,15 @@ Value& Value::resolveReference(const char* key) {
} }
// @param key is not null-terminated. // @param key is not null-terminated.
Value& Value::resolveReference(char const* key, char const* myend) Value& Value::resolveReference(char const* key, char const* cend)
{ {
JSON_ASSERT_MESSAGE( JSON_ASSERT_MESSAGE(
type_ == nullValue || type_ == objectValue, type_ == nullValue || type_ == objectValue,
"in Json::Value::resolveReference(key, myend): requires objectValue"); "in Json::Value::resolveReference(key, end): requires objectValue");
if (type_ == nullValue) if (type_ == nullValue)
*this = Value(objectValue); *this = Value(objectValue);
CZString actualKey( CZString actualKey(
key, static_cast<unsigned>(myend-key), CZString::duplicateOnCopy); key, static_cast<unsigned>(cend-key), CZString::duplicateOnCopy);
ObjectValues::iterator it = value_.map_->lower_bound(actualKey); ObjectValues::iterator it = value_.map_->lower_bound(actualKey);
if (it != value_.map_->end() && (*it).first == actualKey) if (it != value_.map_->end() && (*it).first == actualKey)
return (*it).second; return (*it).second;
@@ -3223,13 +3179,13 @@ Value Value::get(ArrayIndex index, const Value& defaultValue) const {
bool Value::isValidIndex(ArrayIndex index) const { return index < size(); } bool Value::isValidIndex(ArrayIndex index) const { return index < size(); }
Value const* Value::find(char const* key, char const* myend) const Value const* Value::find(char const* key, char const* cend) const
{ {
JSON_ASSERT_MESSAGE( JSON_ASSERT_MESSAGE(
type_ == nullValue || type_ == objectValue, type_ == nullValue || type_ == objectValue,
"in Json::Value::find(key, myend, found): requires objectValue or nullValue"); "in Json::Value::find(key, end, found): requires objectValue or nullValue");
if (type_ == nullValue) return NULL; if (type_ == nullValue) return NULL;
CZString actualKey(key, static_cast<unsigned>(myend-key), CZString::noDuplication); CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
ObjectValues::const_iterator it = value_.map_->find(actualKey); ObjectValues::const_iterator it = value_.map_->find(actualKey);
if (it == value_.map_->end()) return NULL; if (it == value_.map_->end()) return NULL;
return &(*it).second; return &(*it).second;
@@ -3273,9 +3229,9 @@ Value const& Value::operator[](CppTL::ConstString const& key) const
Value& Value::append(const Value& value) { return (*this)[size()] = value; } Value& Value::append(const Value& value) { return (*this)[size()] = value; }
Value Value::get(char const* key, char const* myend, Value const& defaultValue) const Value Value::get(char const* key, char const* cend, Value const& defaultValue) const
{ {
Value const* found = find(key, myend); Value const* found = find(key, cend);
return !found ? defaultValue : *found; return !found ? defaultValue : *found;
} }
Value Value::get(char const* key, Value const& defaultValue) const Value Value::get(char const* key, Value const& defaultValue) const
@@ -3288,12 +3244,12 @@ Value Value::get(std::string const& key, Value const& defaultValue) const
} }
bool Value::removeMember(const char* key, const char* myend, Value* removed) bool Value::removeMember(const char* key, const char* cend, Value* removed)
{ {
if (type_ != objectValue) { if (type_ != objectValue) {
return false; return false;
} }
CZString actualKey(key, static_cast<unsigned>(myend-key), CZString::noDuplication); CZString actualKey(key, static_cast<unsigned>(cend-key), CZString::noDuplication);
ObjectValues::iterator it = value_.map_->find(actualKey); ObjectValues::iterator it = value_.map_->find(actualKey);
if (it == value_.map_->end()) if (it == value_.map_->end())
return false; return false;
@@ -3338,8 +3294,8 @@ bool Value::removeIndex(ArrayIndex index, Value* removed) {
ArrayIndex oldSize = size(); ArrayIndex oldSize = size();
// shift left all items left, into the place of the "removed" // shift left all items left, into the place of the "removed"
for (ArrayIndex i = index; i < (oldSize - 1); ++i){ for (ArrayIndex i = index; i < (oldSize - 1); ++i){
CZString mykey(i); CZString keey(i);
(*value_.map_)[mykey] = (*this)[i + 1]; (*value_.map_)[keey] = (*this)[i + 1];
} }
// erase the last one ("leftover") // erase the last one ("leftover")
CZString keyLast(oldSize - 1); CZString keyLast(oldSize - 1);
@@ -3355,9 +3311,9 @@ Value Value::get(const CppTL::ConstString& key,
} }
#endif #endif
bool Value::isMember(char const* key, char const* myend) const bool Value::isMember(char const* key, char const* cend) const
{ {
Value const* value = find(key, myend); Value const* value = find(key, cend);
return NULL != value; return NULL != value;
} }
bool Value::isMember(char const* key) const bool Value::isMember(char const* key) const
@@ -3786,10 +3742,18 @@ Value& Path::make(Value& root) const {
#if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below #if defined(_MSC_VER) && _MSC_VER < 1500 // VC++ 8.0 and below
#define snprintf _snprintf #define snprintf _snprintf
#elif defined(__ANDROID__)
#define snprintf snprintf
#elif __cplusplus >= 201103L #elif __cplusplus >= 201103L
#define snprintf std::snprintf #define snprintf std::snprintf
#endif #endif
#if defined(__BORLANDC__)
#include <float.h>
#define isfinite _finite
#define snprintf _snprintf
#endif
#if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0 #if defined(_MSC_VER) && _MSC_VER >= 1400 // VC++ 8.0
// Disable warning about strdup being deprecated. // Disable warning about strdup being deprecated.
#pragma warning(disable : 4996) #pragma warning(disable : 4996)
@@ -3797,11 +3761,7 @@ Value& Path::make(Value& root) const {
namespace Json { namespace Json {
#if __cplusplus >= 201103L
typedef std::unique_ptr<StreamWriter> StreamWriterPtr;
#else
typedef std::auto_ptr<StreamWriter> StreamWriterPtr; typedef std::auto_ptr<StreamWriter> StreamWriterPtr;
#endif
static bool containsControlCharacter(const char* str) { static bool containsControlCharacter(const char* str) {
while (*str) { while (*str) {
@@ -4096,7 +4056,7 @@ void FastWriter::writeValue(const Value& value) {
const std::string& name = *it; const std::string& name = *it;
if (it != members.begin()) if (it != members.begin())
document_ += ','; document_ += ',';
document_ += valueToQuotedStringN(name.data(), name.length()); document_ += valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length()));
document_ += yamlCompatiblityEnabled_ ? ": " : ":"; document_ += yamlCompatiblityEnabled_ ? ": " : ":";
writeValue(value[name]); writeValue(value[name]);
} }
@@ -4656,7 +4616,7 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
std::string const& name = *it; std::string const& name = *it;
Value const& childValue = value[name]; Value const& childValue = value[name];
writeCommentBeforeValue(childValue); writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedStringN(name.data(), name.length())); writeWithIndent(valueToQuotedStringN(name.data(), static_cast<unsigned>(name.length())));
*sout_ << colonSymbol_; *sout_ << colonSymbol_;
writeValue(childValue); writeValue(childValue);
if (++it == members.end()) { if (++it == members.end()) {

View File

@@ -4,4 +4,4 @@
* to luainstance.h changes * to luainstance.h changes
*/ */
#define LUA_API_VERSION_MAJOR 1 #define LUA_API_VERSION_MAJOR 1
#define LUA_API_VERSION_MINOR 35 #define LUA_API_VERSION_MINOR 37

View File

@@ -27,6 +27,7 @@
#include <global.h> #include <global.h>
#include <system/debug.h> #include <system/debug.h>
#include <gui/movieplayer.h> #include <gui/movieplayer.h>
#include <gui/widget/messagebox.h>
#include <zapit/zapit.h> #include <zapit/zapit.h>
#include <video.h> #include <video.h>
#include <neutrino.h> #include <neutrino.h>
@@ -58,6 +59,7 @@ void CLuaInstVideo::LuaVideoRegister(lua_State *L)
{ "ShowPicture", CLuaInstVideo::ShowPicture }, { "ShowPicture", CLuaInstVideo::ShowPicture },
{ "StopPicture", CLuaInstVideo::StopPicture }, { "StopPicture", CLuaInstVideo::StopPicture },
{ "PlayFile", CLuaInstVideo::PlayFile }, { "PlayFile", CLuaInstVideo::PlayFile },
{ "setInfoFunc", CLuaInstVideo::setInfoFunc },
{ "zapitStopPlayBack", CLuaInstVideo::zapitStopPlayBack }, { "zapitStopPlayBack", CLuaInstVideo::zapitStopPlayBack },
{ "channelRezap", CLuaInstVideo::channelRezap }, { "channelRezap", CLuaInstVideo::channelRezap },
{ "createChannelIDfromUrl", CLuaInstVideo::createChannelIDfromUrl }, { "createChannelIDfromUrl", CLuaInstVideo::createChannelIDfromUrl },
@@ -170,13 +172,58 @@ int CLuaInstVideo::PlayFile(lua_State *L)
std::string si1(info1); std::string si1(info1);
std::string si2(info2); std::string si2(info2);
std::string sf(fname); std::string sf(fname);
if (D != NULL && !D->infoFunc.empty())
CMoviePlayerGui::getInstance().setLuaInfoFunc(L, true);
CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2); CMoviePlayerGui::getInstance().SetFile(st, sf, si1, si2);
CMoviePlayerGui::getInstance().exec(NULL, "http_lua"); CMoviePlayerGui::getInstance().exec(NULL, "http_lua");
CMoviePlayerGui::getInstance().setLuaInfoFunc(L, false);
if (D != NULL && !D->infoFunc.empty())
D->infoFunc = "";
int ret = CMoviePlayerGui::getInstance().getKeyPressed(); int ret = CMoviePlayerGui::getInstance().getKeyPressed();
lua_pushinteger(L, ret); lua_pushinteger(L, ret);
return 1; return 1;
} }
int CLuaInstVideo::setInfoFunc(lua_State *L)
{
CLuaVideo *D = VideoCheckData(L, 1);
if (!D) return 0;
int numargs = lua_gettop(L);
if (numargs < 2) {
printf("CLuaInstVideo::%s: not enough arguments (%d, expected 1)\n", __func__, numargs-1);
return 0;
}
D->infoFunc = luaL_checkstring(L, 2);
return 0;
}
bool CLuaInstVideo::execLuaInfoFunc(lua_State *L, int xres, int yres, int aspectRatio, int framerate)
{
CLuaVideo *D = VideoCheckData(L, 1);
if (!D) return false;
lua_getglobal(L, D->infoFunc.c_str());
lua_pushinteger(L, (lua_Integer)xres);
lua_pushinteger(L, (lua_Integer)yres);
lua_pushinteger(L, (lua_Integer)aspectRatio);
lua_pushinteger(L, (lua_Integer)framerate);
int status = lua_pcall(L, 4, 0, 0);
if (status) {
char msg[1024];
lua_Debug ar;
lua_getstack(L, 1, &ar);
lua_getinfo(L, "Sl", &ar);
memset(msg, '\0', sizeof(msg));
snprintf(msg, sizeof(msg)-1, "[%s:%d] error running function '%s': %s", ar.short_src, ar.currentline, D->infoFunc.c_str(), lua_tostring(L, -1));
fprintf(stderr, "[CLuaInstVideo::%s:%d] %s\n", __func__, __LINE__, msg);
DisplayErrorMessage(msg);
return false;
}
return true;
}
int CLuaInstVideo::zapitStopPlayBack(lua_State *L) int CLuaInstVideo::zapitStopPlayBack(lua_State *L)
{ {
/* workaround for deprecated functions */ /* workaround for deprecated functions */

View File

@@ -24,7 +24,8 @@ class CLuaVideo
{ {
public: public:
bool singlePlay; bool singlePlay;
CLuaVideo() { singlePlay=false; }; std::string infoFunc;
CLuaVideo() { singlePlay=false; infoFunc=""; };
~CLuaVideo() {}; ~CLuaVideo() {};
}; };
@@ -36,6 +37,7 @@ class CLuaInstVideo
static CLuaInstVideo* getInstance(); static CLuaInstVideo* getInstance();
static void LuaVideoRegister(lua_State *L); static void LuaVideoRegister(lua_State *L);
static int channelRezap(lua_State *L); static int channelRezap(lua_State *L);
static bool execLuaInfoFunc(lua_State *L, int xres, int yres, int aspectRatio, int framerate);
/* deprecated functions */ /* deprecated functions */
static int setBlank_old(lua_State *L); static int setBlank_old(lua_State *L);
@@ -53,6 +55,7 @@ class CLuaInstVideo
static int ShowPicture(lua_State *L); static int ShowPicture(lua_State *L);
static int StopPicture(lua_State *L); static int StopPicture(lua_State *L);
static int PlayFile(lua_State *L); static int PlayFile(lua_State *L);
static int setInfoFunc(lua_State *L);
static int zapitStopPlayBack(lua_State *L); static int zapitStopPlayBack(lua_State *L);
static int createChannelIDfromUrl(lua_State *L); static int createChannelIDfromUrl(lua_State *L);
static int getNeutrinoMode(lua_State *L); static int getNeutrinoMode(lua_State *L);

View File

@@ -45,6 +45,7 @@
#include <gui/plugins.h> #include <gui/plugins.h>
#include <gui/videosettings.h> #include <gui/videosettings.h>
#include <gui/streaminfo2.h> #include <gui/streaminfo2.h>
#include <gui/lua/lua_video.h>
#include <gui/screensaver.h> #include <gui/screensaver.h>
#include <driver/screenshot.h> #include <driver/screenshot.h>
#include <driver/volume.h> #include <driver/volume.h>
@@ -206,6 +207,7 @@ void CMoviePlayerGui::Init(void)
filelist_it = filelist.end(); filelist_it = filelist.end();
keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL; keyPressed = CMoviePlayerGui::PLUGIN_PLAYSTATE_NORMAL;
isLuaPlay = false; isLuaPlay = false;
haveLuaInfoFunc = false;
blockedFromPlugin = false; blockedFromPlugin = false;
m_screensaver = false; m_screensaver = false;
m_idletime = time(NULL); m_idletime = time(NULL);
@@ -337,6 +339,7 @@ int CMoviePlayerGui::exec(CMenuTarget * parent, const std::string & actionKey)
isLuaPlay = true; isLuaPlay = true;
is_file_player = true; is_file_player = true;
PlayFile(); PlayFile();
haveLuaInfoFunc = false;
} }
else { else {
return menu_return::RETURN_REPAINT; return menu_return::RETURN_REPAINT;
@@ -1758,13 +1761,24 @@ void CMoviePlayerGui::handleMovieBrowser(neutrino_msg_t msg, int /*position*/)
cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */ cMovieInfo.saveMovieInfo(*p_movie_info); /* save immediately in xml file */
} }
} }
} else if (msg == NeutrinoMessages::SHOW_EPG && p_movie_info) { } else if (msg == NeutrinoMessages::SHOW_EPG && (p_movie_info || (isLuaPlay && haveLuaInfoFunc))) {
CTimeOSD::mode m_mode = FileTime.getMode(); CTimeOSD::mode m_mode = FileTime.getMode();
bool restore = FileTime.IsVisible(); bool restore = FileTime.IsVisible();
if (restore) if (restore)
FileTime.kill(); FileTime.kill();
InfoClock->enableInfoClock(false); InfoClock->enableInfoClock(false);
if (isLuaPlay && haveLuaInfoFunc) {
int xres = 0, yres = 0, aspectRatio = 0, framerate = -1;
if (!videoDecoder->getBlank()) {
videoDecoder->getPictureInfo(xres, yres, framerate);
if (yres == 1088)
yres = 1080;
aspectRatio = videoDecoder->getAspectRatio();
}
CLuaInstVideo::getInstance()->execLuaInfoFunc(luaState, xres, yres, aspectRatio, framerate);
}
else if (p_movie_info)
cMovieInfo.showMovieInfo(*p_movie_info); cMovieInfo.showMovieInfo(*p_movie_info);
InfoClock->enableInfoClock(true); InfoClock->enableInfoClock(true);

View File

@@ -53,6 +53,12 @@
#include <OpenThreads/Thread> #include <OpenThreads/Thread>
#include <OpenThreads/Condition> #include <OpenThreads/Condition>
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
}
class CMoviePlayerGui : public CMenuTarget class CMoviePlayerGui : public CMenuTarget
{ {
public: public:
@@ -91,6 +97,8 @@ class CMoviePlayerGui : public CMenuTarget
CMoviePlayerGui::state playstate; CMoviePlayerGui::state playstate;
int keyPressed; int keyPressed;
bool isLuaPlay; bool isLuaPlay;
bool haveLuaInfoFunc;
lua_State* luaState;
bool blockedFromPlugin; bool blockedFromPlugin;
int speed; int speed;
int startposition; int startposition;
@@ -230,6 +238,7 @@ class CMoviePlayerGui : public CMenuTarget
void restoreNeutrino(); void restoreNeutrino();
void setBlockedFromPlugin(bool b) { blockedFromPlugin = b; }; void setBlockedFromPlugin(bool b) { blockedFromPlugin = b; };
bool getBlockedFromPlugin() { return blockedFromPlugin; }; bool getBlockedFromPlugin() { return blockedFromPlugin; };
void setLuaInfoFunc(lua_State* L, bool func) { luaState = L; haveLuaInfoFunc = func; };
}; };
#endif #endif

View File

@@ -1308,6 +1308,15 @@ bool COsdSetup::changeNotify(const neutrino_locale_t OptionName, void * data)
} }
return false; return false;
} }
else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_SCREENSAVER_DELAY)) {
screensaverActivate.Activate(g_settings.screensaver_delay != 0);
screensaverOptActivate.Activate(g_settings.screensaver_delay != 0 && g_settings.screensaver_mode == 0);
return false;
}
else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_SCREENSAVER_MODE)) {
screensaverOptActivate.Activate(g_settings.screensaver_mode == 0);
return false;
}
else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_COLORMENU_OSD_PRESET)) { else if(ARE_LOCALES_EQUAL(OptionName, LOCALE_COLORMENU_OSD_PRESET)) {
int preset = * (int *) data; int preset = * (int *) data;
printf("preset %d (setting %d)\n", preset, g_settings.screen_preset); printf("preset %d (setting %d)\n", preset, g_settings.screen_preset);
@@ -1451,38 +1460,40 @@ const CMenuOptionChooser::keyval SCREENSAVER_MODE_OPTIONS[SCREENSAVER_MODE_OPTIO
void COsdSetup::showOsdScreensaverSetup(CMenuWidget *menu_screensaver) void COsdSetup::showOsdScreensaverSetup(CMenuWidget *menu_screensaver)
{ {
menu_screensaver->addIntroItems(LOCALE_SCREENSAVER_MENU); menu_screensaver->addIntroItems(LOCALE_SCREENSAVER_MENU);
screensaverNotifier = new COnOffNotifier();
screensaverActivate.Clear();
screensaverOptActivate.Clear();
// screensaver delay // screensaver delay
CMenuOptionNumberChooser* nc = new CMenuOptionNumberChooser(LOCALE_SCREENSAVER_DELAY, &g_settings.screensaver_delay, true, 0, 999, screensaverNotifier, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_SCREENSAVER_OFF); CMenuOptionNumberChooser* nc = new CMenuOptionNumberChooser(LOCALE_SCREENSAVER_DELAY, &g_settings.screensaver_delay, true, 0, 999, this, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_SCREENSAVER_OFF);
nc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE)); nc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_MINUTE));
nc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_DELAY); nc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_DELAY);
menu_screensaver->addItem(nc); menu_screensaver->addItem(nc);
// screensaver mode // screensaver mode
CMenuOptionChooser* oc = new CMenuOptionChooser(LOCALE_SCREENSAVER_MODE, &g_settings.screensaver_mode, SCREENSAVER_MODE_OPTIONS, SCREENSAVER_MODE_OPTION_COUNT, true); CMenuOptionChooser* oc = new CMenuOptionChooser(LOCALE_SCREENSAVER_MODE, &g_settings.screensaver_mode, SCREENSAVER_MODE_OPTIONS, SCREENSAVER_MODE_OPTION_COUNT, (g_settings.screensaver_delay != 0), this);
oc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_MODE); oc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_MODE);
menu_screensaver->addItem(oc); menu_screensaver->addItem(oc);
screensaverNotifier->addItem(oc); screensaverActivate.Add(oc);
// screensaver timeout // screensaver timeout
nc = new CMenuOptionNumberChooser(LOCALE_SCREENSAVER_TIMEOUT, &g_settings.screensaver_timeout, (g_settings.screensaver_delay != 0), 0, 60, NULL, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF); nc = new CMenuOptionNumberChooser(LOCALE_SCREENSAVER_TIMEOUT, &g_settings.screensaver_timeout, (g_settings.screensaver_delay != 0), 0, 60, NULL, CRCInput::RC_nokey, NULL, 0, 0, LOCALE_OPTIONS_OFF);
nc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_SECOND)); nc->setNumberFormat(std::string("%d ") + g_Locale->getText(LOCALE_UNIT_SHORT_SECOND));
nc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_TIMEOUT); nc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_TIMEOUT);
menu_screensaver->addItem(nc); menu_screensaver->addItem(nc);
screensaverNotifier->addItem(nc); screensaverActivate.Add(nc);
// screensaver_dir // screensaver_dir
CMenuForwarder *mf = new CMenuForwarder(LOCALE_SCREENSAVER_DIR, (g_settings.screensaver_delay != 0), g_settings.screensaver_dir, this, "screensaver_dir"); CMenuForwarder *mf = new CMenuForwarder(LOCALE_SCREENSAVER_DIR, (g_settings.screensaver_delay != 0 && g_settings.screensaver_mode == 0), g_settings.screensaver_dir, this, "screensaver_dir");
mf->setHint("", LOCALE_MENU_HINT_SCREENSAVER_DIR); mf->setHint("", LOCALE_MENU_HINT_SCREENSAVER_DIR);
menu_screensaver->addItem(mf); menu_screensaver->addItem(mf);
screensaverNotifier->addItem(mf); screensaverOptActivate.Add(mf);
// screensaver random mode // screensaver random mode
oc = new CMenuOptionChooser(LOCALE_SCREENSAVER_RANDOM, &g_settings.screensaver_random, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, true); oc = new CMenuOptionChooser(LOCALE_SCREENSAVER_RANDOM, &g_settings.screensaver_random, OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, (g_settings.screensaver_delay != 0 && g_settings.screensaver_mode == 0));
oc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_RANDOM); oc->setHint("", LOCALE_MENU_HINT_SCREENSAVER_RANDOM);
menu_screensaver->addItem(oc); menu_screensaver->addItem(oc);
screensaverNotifier->addItem(oc); screensaverOptActivate.Add(oc);
} }
void COsdSetup::paintWindowSize(int w, int h) void COsdSetup::paintWindowSize(int w, int h)

View File

@@ -58,6 +58,8 @@ class COsdSetup : public CMenuTarget, public CChangeObserver
COnOffNotifier* channellistNotifier; COnOffNotifier* channellistNotifier;
COnOffNotifier* infobarHddNotifier; COnOffNotifier* infobarHddNotifier;
CGenericMenuActivate casystemActivate; CGenericMenuActivate casystemActivate;
CGenericMenuActivate screensaverActivate;
CGenericMenuActivate screensaverOptActivate;
CGenericMenuActivate gradentHeadDirection, gradentHintDirection, gradentInfobarTopDirection, gradentInfobarBodyDirection, gradentInfobarFootDirection; CGenericMenuActivate gradentHeadDirection, gradentHintDirection, gradentInfobarTopDirection, gradentInfobarBodyDirection, gradentInfobarFootDirection;
int width; int width;
int is_wizard; int is_wizard;

View File

@@ -22,6 +22,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@@ -38,7 +41,7 @@
#include "screensaver.h" #include "screensaver.h"
#include <system/debug.h> #include <system/debug.h>
#include <gui/infoclock.h> #include <gui/infoclock.h>
#include <zapit/zapit.h>
#include <video.h> #include <video.h>
extern cVideo * videoDecoder; extern cVideo * videoDecoder;
@@ -54,6 +57,7 @@ CScreenSaver::CScreenSaver()
status_mute = CAudioMute::getInstance()->getStatus(); status_mute = CAudioMute::getInstance()->getStatus();
scr_clock = NULL; scr_clock = NULL;
clr.i_color = COL_DARK_GRAY; clr.i_color = COL_DARK_GRAY;
pip_channel_id = 0;
} }
CScreenSaver::~CScreenSaver() CScreenSaver::~CScreenSaver()
@@ -87,6 +91,12 @@ void CScreenSaver::Start()
if(!CInfoClock::getInstance()->isBlocked()) if(!CInfoClock::getInstance()->isBlocked())
CInfoClock::getInstance()->disableInfoClock(); CInfoClock::getInstance()->disableInfoClock();
#ifdef ENABLE_PIP
pip_channel_id = CZapit::getInstance()->GetPipChannelID();
if (pip_channel_id)
g_Zapit->stopPip();
#endif
m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling); m_viewer->SetScaling((CPictureViewer::ScalingMode)g_settings.picviewer_scaling);
m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY); m_viewer->SetVisible(g_settings.screen_StartX, g_settings.screen_EndX, g_settings.screen_StartY, g_settings.screen_EndY);
@@ -101,7 +111,7 @@ void CScreenSaver::Start()
if(!thrScreenSaver) if(!thrScreenSaver)
{ {
//printf("[%s] %s: starting thread\n", __FILE__, __FUNCTION__); //printf("[%s] %s: starting thread\n", __file__, __FUNCTION__);
pthread_create(&thrScreenSaver, NULL, ScreenSaverPrg, (void*) this); pthread_create(&thrScreenSaver, NULL, ScreenSaverPrg, (void*) this);
pthread_detach(thrScreenSaver); pthread_detach(thrScreenSaver);
} }
@@ -122,6 +132,13 @@ void CScreenSaver::Stop()
scr_clock = NULL; scr_clock = NULL;
} }
#ifdef ENABLE_PIP
if(pip_channel_id) {
CNeutrinoApp::getInstance()->StartPip(pip_channel_id);
pip_channel_id = 0;
}
#endif
m_frameBuffer->paintBackground(); //clear entire screen m_frameBuffer->paintBackground(); //clear entire screen
CAudioMute::getInstance()->enableMuteIcon(status_mute); CAudioMute::getInstance()->enableMuteIcon(status_mute);
@@ -273,12 +290,12 @@ void CScreenSaver::paint()
do { do {
clr.i_color = rand(); clr.i_color = rand();
brightness = (unsigned int)clr.uc_color.r * 19595 + (unsigned int)clr.uc_color.g * 38469 + (unsigned int)clr.uc_color.b * 7471; brightness = (unsigned int)clr.uc_color.r * 19595 + (unsigned int)clr.uc_color.g * 38469 + (unsigned int)clr.uc_color.b * 7471;
//printf("[%s] %s: brightness: %d\n", __FILE__, __FUNCTION__, brightness>> 16); //printf("[%s] %s: brightness: %d\n", __file__, __FUNCTION__, brightness>> 16);
} }
while(brightness >> 16 < 80); while(brightness >> 16 < 80);
clr.i_color &= 0x00FFFFFF; clr.i_color &= 0x00FFFFFF;
//printf("[%s] %s: clr.i_color: r %02x g %02x b %02x a %02x\n", __FILE__, __FUNCTION__, clr.uc_color.r, clr.uc_color.g, clr.uc_color.b, clr.uc_color.a); //printf("[%s] %s: clr.i_color: r %02x g %02x b %02x a %02x\n", __file__, __FUNCTION__, clr.uc_color.r, clr.uc_color.g, clr.uc_color.b, clr.uc_color.a);
} }
else else
clr.i_color = COL_DARK_GRAY; clr.i_color = COL_DARK_GRAY;

View File

@@ -40,7 +40,7 @@ class CScreenSaver : public sigc::trackable
static void* ScreenSaverPrg(void *arg); static void* ScreenSaverPrg(void *arg);
vector<string> v_bg_files; vector<string> v_bg_files;
unsigned int index; unsigned int index;
t_channel_id pip_channel_id;
bool status_mute; bool status_mute;
bool ReadDir(); bool ReadDir();