From 19218b5ce33796f556f73a442b7dfc2dfdc8a59e Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Tue, 10 Jan 2017 11:21:28 +0900 Subject: [PATCH 01/16] [version] 1.68 Change-Id: I03441f3e65af3ed06c87d65162c1f8670b640242 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 73399e1..d00b6d4 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.67 +Version: 1.68 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From b25f64b7fda7d4261e68ced971ffc87cf7684864 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Tue, 10 Jan 2017 09:22:57 +0100 Subject: [PATCH 02/16] [Convergance] Fix for swapDevice Change-Id: I42ddf08ec4d8343124db8c1d994b6ede499f6a8b Signed-off-by: Lukasz Bardeli --- src/convergence/convergence_device.cc | 11 +++++++++-- src/convergence/convergence_device.h | 3 ++- src/convergence/convergence_manager.cc | 3 +++ src/convergence/convergence_service.cc | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/convergence/convergence_device.cc b/src/convergence/convergence_device.cc index 34d3663..f617db7 100644 --- a/src/convergence/convergence_device.cc +++ b/src/convergence/convergence_device.cc @@ -154,7 +154,7 @@ void ConvergenceDevice::ForEachServiceCb(conv_service_h service_handle, s->Refresh(); } -void ConvergenceDevice::Refresh() { +void ConvergenceDevice::Refresh(conv_device_h device_handle) { ScopeLogger(); // Getting device properties from handle id_ = ExtractDevicePropery(CONV_DEVICE_ID); @@ -165,7 +165,14 @@ void ConvergenceDevice::Refresh() { id_.c_str(), name_.c_str(), type_.c_str()); // Extracting services - const int error = conv_device_foreach_service(device_handle_, ForEachServiceCb, this); + conv_device_h handle = nullptr; + if (device_handle) { + handle = device_handle; + } else { + handle = device_handle_; + } + + const int error = conv_device_foreach_service(handle, ForEachServiceCb, this); if (CONV_ERROR_NONE != error) { trace_conv_error(error, __LINE__, "conv_device_foreach_service"); } diff --git a/src/convergence/convergence_device.h b/src/convergence/convergence_device.h index e16e410..6496244 100644 --- a/src/convergence/convergence_device.h +++ b/src/convergence/convergence_device.h @@ -44,11 +44,12 @@ class ConvergenceDevice { public: - void Refresh(); + void Refresh(conv_device_h device_handle = nullptr); ConvergenceService *GetService(const int service_type) const; //picojson::object ToJson() const; picojson::value ToJson() const; //std::string get_device() const {return device_handle_; } + int ServiceCount() {return services_.size();}; public: ConvergenceService *RegisterLocalService(const int service_type); diff --git a/src/convergence/convergence_manager.cc b/src/convergence/convergence_manager.cc index c7f6784..11482af 100644 --- a/src/convergence/convergence_manager.cc +++ b/src/convergence/convergence_manager.cc @@ -115,6 +115,9 @@ ConvergenceDevice *ConvergenceManager::SwapDevice(const char *device_id, d->SetId(device_id); registered_devices_[device_id] = d; LoggerI("...registering the device [%s, %x]", device_id, device_handle); + // Assume that there are only two services + } else if(registered_devices_[device_id]->ServiceCount() < 2) { + registered_devices_[device_id]->Refresh(device_handle); } return registered_devices_[device_id]; } diff --git a/src/convergence/convergence_service.cc b/src/convergence/convergence_service.cc index 61d9d3b..4f9167e 100644 --- a/src/convergence/convergence_service.cc +++ b/src/convergence/convergence_service.cc @@ -150,7 +150,7 @@ void ConvergenceService::Refresh() { ScopeLogger(); conv_service_h service_handle = FindServiceHandle(); if (!service_handle) { - LoggerE("AAAAAA!!! Service not found"); + LoggerE("Service not found"); return; } -- 2.7.4 From 74d47d4292ca863ed21bfe93c3cbcaae3ecf2696 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Wed, 11 Jan 2017 11:06:58 +0900 Subject: [PATCH 03/16] [version] 1.69 Change-Id: Iac591a1c64772c65a0623193f10752264afc9dc5 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index d00b6d4..a8a6691 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.68 +Version: 1.69 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 78fc5627f05a957c03a561fbd22c5ea1bb4a8b6c Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Wed, 11 Jan 2017 14:43:19 +0100 Subject: [PATCH 04/16] [Convergance] fix for swapDevice2 Change-Id: I68f61357bfcdc9bcc174d885f5e82fc457757f3c Signed-off-by: Lukasz Bardeli --- src/convergence/convergence_device.cc | 11 ++--------- src/convergence/convergence_device.h | 2 +- src/convergence/convergence_manager.cc | 5 ++++- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/convergence/convergence_device.cc b/src/convergence/convergence_device.cc index f617db7..34d3663 100644 --- a/src/convergence/convergence_device.cc +++ b/src/convergence/convergence_device.cc @@ -154,7 +154,7 @@ void ConvergenceDevice::ForEachServiceCb(conv_service_h service_handle, s->Refresh(); } -void ConvergenceDevice::Refresh(conv_device_h device_handle) { +void ConvergenceDevice::Refresh() { ScopeLogger(); // Getting device properties from handle id_ = ExtractDevicePropery(CONV_DEVICE_ID); @@ -165,14 +165,7 @@ void ConvergenceDevice::Refresh(conv_device_h device_handle) { id_.c_str(), name_.c_str(), type_.c_str()); // Extracting services - conv_device_h handle = nullptr; - if (device_handle) { - handle = device_handle; - } else { - handle = device_handle_; - } - - const int error = conv_device_foreach_service(handle, ForEachServiceCb, this); + const int error = conv_device_foreach_service(device_handle_, ForEachServiceCb, this); if (CONV_ERROR_NONE != error) { trace_conv_error(error, __LINE__, "conv_device_foreach_service"); } diff --git a/src/convergence/convergence_device.h b/src/convergence/convergence_device.h index 6496244..505ae38 100644 --- a/src/convergence/convergence_device.h +++ b/src/convergence/convergence_device.h @@ -44,7 +44,7 @@ class ConvergenceDevice { public: - void Refresh(conv_device_h device_handle = nullptr); + void Refresh(); ConvergenceService *GetService(const int service_type) const; //picojson::object ToJson() const; picojson::value ToJson() const; diff --git a/src/convergence/convergence_manager.cc b/src/convergence/convergence_manager.cc index 11482af..3b14d6c 100644 --- a/src/convergence/convergence_manager.cc +++ b/src/convergence/convergence_manager.cc @@ -117,7 +117,10 @@ ConvergenceDevice *ConvergenceManager::SwapDevice(const char *device_id, LoggerI("...registering the device [%s, %x]", device_id, device_handle); // Assume that there are only two services } else if(registered_devices_[device_id]->ServiceCount() < 2) { - registered_devices_[device_id]->Refresh(device_handle); + registered_devices_.erase(device_id); + ConvergenceDevice *d = new ConvergenceDevice(device_handle, convergence_plugin_); + d->SetId(device_id); + registered_devices_[device_id] = d; } return registered_devices_[device_id]; } -- 2.7.4 From 6155969620dbec240d2fcea7d38c3f218e46232e Mon Sep 17 00:00:00 2001 From: Jakub Skowron Date: Fri, 13 Jan 2017 13:05:55 +0100 Subject: [PATCH 05/16] [Filesystem] Fix UTF-8 decoding in readAsText Correctly decode multibyte characters at buffer boundary. Change-Id: Ie6ccb680e8fb78d1bfffaa1b06cd600d78c3b675 Signed-off-by: Jakub Skowron --- src/filesystem/js/base64.js | 19 +++++++------------ src/filesystem/js/file.js | 10 ++++++---- 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/src/filesystem/js/base64.js b/src/filesystem/js/base64.js index 2324831..20a29b4 100755 --- a/src/filesystem/js/base64.js +++ b/src/filesystem/js/base64.js @@ -54,12 +54,7 @@ var Base64 = { return output; }, decodeString: function(data) { - data = this.decode(data); - var output = ''; - for (var i = 0; i < data.length; ++i) { - output += String.fromCharCode(data[i]); - } - return this._utf8_decode(output); + return this._utf8_decode(this.decode(data)); }, decode: function(data) { var output = []; @@ -118,26 +113,26 @@ var Base64 = { return utftext; }, - _utf8_decode: function(utftext) { + _utf8_decode: function(utfarray) { var str = ''; var i = 0, c = 0, c1 = 0, c2 = 0; - while (i < utftext.length) { + while (i < utfarray.length) { - c = utftext.charCodeAt(i); + c = utfarray[i]; if (c < 128) { str += String.fromCharCode(c); i++; } else if ((c > 191) && (c < 224)) { - c1 = utftext.charCodeAt(i + 1); + c1 = utfarray[i + 1]; str += String.fromCharCode(((c & 31) << 6) | (c1 & 63)); i += 2; } else { - c1 = utftext.charCodeAt(i + 1); - c2 = utftext.charCodeAt(i + 2); + c1 = utfarray[i + 1]; + c2 = utfarray[i + 2]; str += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63)); i += 3; } diff --git a/src/filesystem/js/file.js b/src/filesystem/js/file.js index 0c4a721..4b07da6 100644 --- a/src/filesystem/js/file.js +++ b/src/filesystem/js/file.js @@ -316,12 +316,12 @@ function readAsText() { var data = { location: commonFS_.toRealPath(this.fullPath), offset: 0, - length: 1024, + length: 65536, encoding: args.encoding }; function readFile() { - var result, encoded, str = ''; + var result, encoded, buffers = []; do { result = native_.callSync('File_readSync', data); @@ -333,13 +333,15 @@ function readAsText() { } encoded = native_.getResultObject(result); if (encoded.length) { - str += Base64.decodeString(encoded); + buffers.push( Base64.decode(encoded) ); data.offset += data.length; } } while (encoded.length); + var buffer = Array.prototype.concat.apply([], buffers); + setTimeout(function() { - native_.callIfPossible(args.onsuccess, str); + native_.callIfPossible(args.onsuccess, Base64._utf8_decode(buffer) ); }, 0); } -- 2.7.4 From 9778e1c74d499e5a46aa4ff84fa2599d593207db Mon Sep 17 00:00:00 2001 From: Szymon Jastrzebski Date: Fri, 13 Jan 2017 15:36:03 +0100 Subject: [PATCH 06/16] [Filesystem] Added decoding for UTF-8 4 bytes characters Change-Id: I78bfa0e205d62b7e7dc5a6b95cad8cf98a941ae1 Signed-off-by: Szymon Jastrzebski --- src/filesystem/js/base64.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/filesystem/js/base64.js b/src/filesystem/js/base64.js index 20a29b4..034ce33 100755 --- a/src/filesystem/js/base64.js +++ b/src/filesystem/js/base64.js @@ -115,7 +115,7 @@ var Base64 = { }, _utf8_decode: function(utfarray) { var str = ''; - var i = 0, c = 0, c1 = 0, c2 = 0; + var i = 0, c = 0, c1 = 0, c2 = 0, c3 = 0; while (i < utfarray.length) { @@ -130,13 +130,19 @@ var Base64 = { str += String.fromCharCode(((c & 31) << 6) | (c1 & 63)); i += 2; } - else { + else if((c > 223) && (c < 240)) { c1 = utfarray[i + 1]; c2 = utfarray[i + 2]; str += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63)); i += 3; } - + else {//support 4 bytes characters e.g. Emojis + c1 = utfarray[i + 1]; + c2 = utfarray[i + 2]; + c3 = utfarray[i + 3]; + str += String.fromCodePoint(((c & 7) << 18) | ((c1 & 63) << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 4; + } } return str; -- 2.7.4 From ab7b081f9095d09bb72e97a1c4aafcdeb2640624 Mon Sep 17 00:00:00 2001 From: Jakub Skowron Date: Wed, 18 Jan 2017 09:10:23 +0100 Subject: [PATCH 07/16] [Filesystem] Fix SMP support in UTF-8 encoding on write Support supplementary planes, including Emoji. [Verification] readASText() is working correctly for P170111-07658 issue. Change-Id: I6f75f397e167ea9c89b4298edcaa19352586c90d Signed-off-by: Jakub Skowron --- src/filesystem/js/base64.js | 42 +++++++++++++++++++----------------------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/filesystem/js/base64.js b/src/filesystem/js/base64.js index 034ce33..d2868f3 100755 --- a/src/filesystem/js/base64.js +++ b/src/filesystem/js/base64.js @@ -16,13 +16,8 @@ var Base64 = { _b64: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', - encodeString: function(data) { - data = this._utf8_encode(data); - var input = []; - for (var i = 0; i < data.length; ++i) { - input.push(data.charCodeAt(i)); - } - return this.encode(input); + encodeString: function(str) { + return this.encode(this._utf8_encode(str)); }, encode: function(data) { var output = ''; @@ -90,28 +85,29 @@ var Base64 = { }, _utf8_encode: function(str) { str = str.replace(/\r\n/g, '\n'); - var utftext = ''; - - for (var n = 0; n < str.length; n++) { + var utfarray = []; - var c = str.charCodeAt(n); + //TODO: use for( var c of str ) in future versions + for (var offset = 0; offset < str.length; offset++) { + var code = str.codePointAt(offset); - if (c < 128) { - utftext += String.fromCharCode(c); + if (code <= 0x7F) { + utfarray.push(code); } - else if ((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); + else if (code <= 0x7FF) { + utfarray.push( 0xC0 | (code >> 6), 0x80 | (code & 0x3F) ); + } + else if (code <= 0xFFFF) { + utfarray.push( 0xE0 | (code >> 12), 0x80 | ((code >> 6) & 0x3F), 0x80 | (code & 0x3F) ); } else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); + utfarray.push( 0xF0 | (code >> 18), 0x80 | ((code >> 12) & 0x3F), + 0x80 | ((code >> 6) & 0x3F), 0x80 | (code & 0x3F) ); + offset++; //there is a UTF16 surrogate pair in str, so jump two elements } - } - return utftext; + return utfarray; }, _utf8_decode: function(utfarray) { var str = ''; @@ -125,12 +121,12 @@ var Base64 = { str += String.fromCharCode(c); i++; } - else if ((c > 191) && (c < 224)) { + else if ((c >= 192) && (c < 224)) { c1 = utfarray[i + 1]; str += String.fromCharCode(((c & 31) << 6) | (c1 & 63)); i += 2; } - else if((c > 223) && (c < 240)) { + else if((c >= 224) && (c < 240)) { c1 = utfarray[i + 1]; c2 = utfarray[i + 2]; str += String.fromCharCode(((c & 15) << 12) | ((c1 & 63) << 6) | (c2 & 63)); -- 2.7.4 From 1c49245159cd3b4610359c9aba6ea74fc45b4e13 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Mon, 23 Jan 2017 13:42:53 +0900 Subject: [PATCH 08/16] [version] 1.70 Change-Id: I8f0d3b61894c9b13339668054d5b48207c460cc4 --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index a8a6691..85f1e2e 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.69 +Version: 1.70 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 9b1afdee572fdfdb0fe9c3952fda6bb813019e72 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 25 Jan 2017 10:29:57 +0100 Subject: [PATCH 09/16] [Common] Fixed spec file - capi-appfw-application removed [Verification] Code compiles without errors. Change-Id: I9cae8ba1eba46d7302bd661261a6498c20c856f7 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 85f1e2e..ddff270 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -401,7 +401,8 @@ BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-wifi-manager) BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(libpcrecpp) -BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-appfw-event) +BuildRequires: pkgconfig(capi-appfw-preference) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-appfw-package-manager) BuildRequires: pkgconfig(capi-content-media-content) -- 2.7.4 From c7e7f65c0c32bdb06ebe19eead06a84d5fe05745 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 1 Feb 2017 09:01:10 +0100 Subject: [PATCH 10/16] [version] 1.71 Change-Id: I8a3feba11e51c0cdec6ed27a0e58eb5ff86f68a4 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index ddff270..3a8b454 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.70 +Version: 1.71 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From 53772a42ef93494794260a4493b477ebac795889 Mon Sep 17 00:00:00 2001 From: Jakub Skowron Date: Fri, 3 Feb 2017 12:38:24 +0100 Subject: [PATCH 11/16] [Filesystem] Add filesystem header files to devel package Fix issue 'not found filesystem_provider.h' when building webapi-plugins-sec module Change-Id: I186a33c36976995f48cbe36ae73083c8f6ffbc7f Signed-off-by: Jakub Skowron --- packaging/webapi-plugins.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 3a8b454..2318acb 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -650,7 +650,9 @@ sed -i s,__LIB_DIR__,%{crosswalk_extensions_path},g packaging/%{name}.pc.in sed -i s,__INCLUDE_DIR__,%{_includedir}/%{name}/src,g packaging/%{name}.pc.in cp packaging/%{name}.pc.in %{buildroot}%{_libdir}/pkgconfig/%{name}.pc mkdir -p %{buildroot}%{_includedir}/%{name}/src/common +mkdir -p %{buildroot}%{_includedir}/%{name}/src/common/filesystem install -p -m 644 src/common/*.h %{buildroot}%{_includedir}/%{name}/src/common +install -p -m 644 src/common/filesystem/*.h %{buildroot}%{_includedir}/%{name}/src/common/filesystem install -p -m 644 src/common/*.gypi %{buildroot}%{_includedir}/%{name}/src/common install -p -m 644 src/common/XW_Extension.cc %{buildroot}%{_includedir}/%{name}/src/common mkdir -p %{buildroot}%{_includedir}/%{name}/tools -- 2.7.4 From bba5cfdb943043b90944bc9277c87f5e9f890423 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Mon, 6 Feb 2017 12:37:14 +0100 Subject: [PATCH 12/16] Revert "[Common] Fixed spec file - capi-appfw-application removed" [Feature] This change is not needed on tizen_3.0 branch, change is only related to tizen 4.0 implementaton. [Verification] Code compiles without errors This reverts commit 9b1afdee572fdfdb0fe9c3952fda6bb813019e72. Change-Id: Ifff995924131f4da70beb1cae07058feacee4e81 --- packaging/webapi-plugins.spec | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 2318acb..06e85a4 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -401,8 +401,7 @@ BuildRequires: pkgconfig(capi-network-bluetooth) BuildRequires: pkgconfig(capi-network-wifi-manager) BuildRequires: pkgconfig(tapi) BuildRequires: pkgconfig(libpcrecpp) -BuildRequires: pkgconfig(capi-appfw-event) -BuildRequires: pkgconfig(capi-appfw-preference) +BuildRequires: pkgconfig(capi-appfw-application) BuildRequires: pkgconfig(capi-appfw-app-manager) BuildRequires: pkgconfig(capi-appfw-package-manager) BuildRequires: pkgconfig(capi-content-media-content) -- 2.7.4 From f29774224955cecd7b12c97ff13adbb7308bc91c Mon Sep 17 00:00:00 2001 From: Jakub Skowron Date: Tue, 7 Feb 2017 19:39:54 +0100 Subject: [PATCH 13/16] Fix picojson number representation Previous implementation assumed default global locale. Failed when locale used other decimal point than '.' Change-Id: I1ffe2847c249cf666e720342e41ed068178cc459 Signed-off-by: Jakub Skowron --- src/common/picojson.h | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/common/picojson.h b/src/common/picojson.h index 6921b1f..eca7efc 100644 --- a/src/common/picojson.h +++ b/src/common/picojson.h @@ -36,6 +36,8 @@ #include #include #include +#include +#include #include #include #include @@ -264,10 +266,14 @@ namespace picojson { case null_type: return "null"; case boolean_type: return u_.boolean_ ? "true" : "false"; case number_type: { - char buf[256]; - double tmp; - SNPRINTF(buf, sizeof(buf), fabs(u_.number_) < (1ULL << 53) && modf(u_.number_, &tmp) == 0 ? "%.f" : "%.17g", u_.number_); - return buf; + std::stringstream num_str; + num_str.imbue( std::locale::classic() ); + double ignored; + if( std::modf(u_.number_, &ignored) != 0 || std::fabs(u_.number_) >= (1ULL << 53) ) { + num_str << std::scientific << std::setprecision(16); + } + num_str << u_.number_; + return num_str.str(); } case string_type: return *u_.string_; case array_type: return "array"; @@ -557,20 +563,23 @@ namespace picojson { } template inline bool _parse_number(double& out, input& in) { - std::string num_str; - while (1) { + std::stringstream num_str; + num_str.imbue( std::locale::classic() ); + + while (true) { int ch = in.getc(); if (('0' <= ch && ch <= '9') || ch == '+' || ch == '-' || ch == '.' || ch == 'e' || ch == 'E') { - num_str.push_back(ch); + num_str.put(ch); } else { in.ungetc(); break; } } - char* endp; - out = strtod(num_str.c_str(), &endp); - return endp == num_str.c_str() + num_str.size(); + + num_str >> out; + + return num_str && num_str.eof(); } template inline bool _parse(Context& ctx, input& in) { -- 2.7.4 From 522e3c12425e788746300d31d078933ef38b8795 Mon Sep 17 00:00:00 2001 From: Lukasz Bardeli Date: Wed, 8 Feb 2017 08:56:47 +0100 Subject: [PATCH 14/16] [Systeminfo] change statfs to storage_get_(internal/external)_memory_size [Verification] code compiles without error, TCT passrate 100% Change-Id: I41e0b078d4005528b0a6e2db411357b0052fc580 Signed-off-by: Lukasz Bardeli --- src/systeminfo/systeminfo_properties_manager.cc | 31 ++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/systeminfo/systeminfo_properties_manager.cc b/src/systeminfo/systeminfo_properties_manager.cc index 9d87daa..cfaa784 100644 --- a/src/systeminfo/systeminfo_properties_manager.cc +++ b/src/systeminfo/systeminfo_properties_manager.cc @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include "systeminfo/systeminfo_manager.h" #include "systeminfo/systeminfo_device_capability.h" @@ -1156,14 +1156,14 @@ PlatformResult SysteminfoPropertiesManager::ReportMemory(picojson::object* out) return PlatformResult(ErrorCode::NO_ERROR); } -static void CreateStorageInfo(const std::string& type, struct statfs& fs, picojson::object* out) { +static void CreateStorageInfo(const std::string& type, struct statvfs& fs, picojson::object* out) { LoggerD("Entered"); out->insert(std::make_pair("type", picojson::value(type))); out->insert(std::make_pair("capacity", picojson::value(std::to_string( - static_cast(fs.f_bsize) * + static_cast(fs.f_frsize) * static_cast(fs.f_blocks))))); out->insert(std::make_pair("availableCapacity", picojson::value(std::to_string( - static_cast(fs.f_bsize) * + static_cast(fs.f_frsize) * static_cast(fs.f_bavail))))); bool isRemovable = (type == kTypeInternal) ? false : true; out->insert(std::make_pair("isRemovable", picojson::value(isRemovable))); @@ -1186,7 +1186,7 @@ static std::string FromStorageTypeToStringType(common::StorageType type) { PlatformResult SysteminfoPropertiesManager::ReportStorage(picojson::object* out) { LoggerD("Entered"); - struct statfs fs; + struct statvfs fs; picojson::value result = picojson::value(picojson::array()); picojson::array& array = result.get(); @@ -1197,20 +1197,25 @@ PlatformResult SysteminfoPropertiesManager::ReportStorage(picojson::object* out) LoggerD("Storages found %d", storages.size()); for (auto storage : storages) { if (storage->state() == common::StorageState::kMounted) { - if (statfs(storage->path().c_str(), &fs) < 0) { - LoggerE("Storage unit %s not detected", storage->name().c_str()); - return PlatformResult(ErrorCode::UNKNOWN_ERR, "Storage unit not detected"); - } - array.push_back(picojson::value(picojson::object())); - picojson::object& external_obj = array.back().get(); - CreateStorageInfo(FromStorageTypeToStringType(storage->type()), fs, &external_obj); - //TODO change implementation to support all types of storages and not limited number if (common::StorageType::kInternal == storage->type()) { + if (storage_get_internal_memory_size(&fs) < 0) { + LoggerE("Storage unit %s not detected", storage->name().c_str()); + return PlatformResult(ErrorCode::UNKNOWN_ERR, "There are no storage units detected"); + } manager_.SetAvailableCapacityInternal(fs.f_bavail); } else if (common::StorageType::kMmc == storage->type()) { + if (storage_get_external_memory_size(&fs) < 0) { + LoggerE("Storage unit %s not detected", storage->name().c_str()); + return PlatformResult(ErrorCode::UNKNOWN_ERR, "MMC mounted, but not accessible"); + } manager_.SetAvailableCapacityMmc(fs.f_bavail); } + + array.push_back(picojson::value(picojson::object())); + picojson::object& external_obj = array.back().get(); + CreateStorageInfo(FromStorageTypeToStringType(storage->type()), fs, &external_obj); + } } -- 2.7.4 From 91b33fabb98f902f1f2c5a6735a45097dbc3d4d0 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 8 Feb 2017 09:07:44 +0100 Subject: [PATCH 15/16] [version] 1.72 Change-Id: Ib440400f64a3a234b15defed7b7e6debc944bf19 Signed-off-by: Piotr Kosko --- packaging/webapi-plugins.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 06e85a4..04b188c 100644 --- a/packaging/webapi-plugins.spec +++ b/packaging/webapi-plugins.spec @@ -10,7 +10,7 @@ %define crosswalk_extensions_path %{_libdir}/%{crosswalk_extensions} Name: webapi-plugins -Version: 1.71 +Version: 1.72 Release: 0 License: Apache-2.0 and BSD-3-Clause and MIT Group: Development/Libraries -- 2.7.4 From b6f5327bcf929741763e09155e15887ee60cadae Mon Sep 17 00:00:00 2001 From: Jakub Skowron Date: Wed, 8 Feb 2017 09:02:56 +0100 Subject: [PATCH 16/16] [Sound] Incorrect printf parameter in log %lf is declared, but pointer to double was passed Change-Id: I76dafaaa900a322d0e2987f35ab2fdb2f40f4f75 Signed-off-by: Jakub Skowron --- src/sound/sound_manager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sound/sound_manager.cc b/src/sound/sound_manager.cc index 9917c0e..b71dfb5 100644 --- a/src/sound/sound_manager.cc +++ b/src/sound/sound_manager.cc @@ -322,7 +322,7 @@ PlatformResult SoundManager::GetVolume(const picojson::object& args, } *volume = ConvertToSystemVolume(max_volume, value); - LoggerD("volume: %lf, maxVolume: %d, value: %d", volume, max_volume, value); + LoggerD("volume: %lf, maxVolume: %d, value: %d", *volume, max_volume, value); return PlatformResult(ErrorCode::NO_ERROR); } -- 2.7.4