From 1e19cccd8429fea5e00d8b8d56885b77b718e646 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Thu, 7 Jul 2016 19:40:29 +0900 Subject: [PATCH 01/16] [version] 1.12 Change-Id: I6f74a582c72e61ead241926fe2affb46d12b4179 --- 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 3557d8b..14d7984 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.11 +Version: 1.12 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries -- 2.7.4 From 0016441dc1f374f9f08aadf9ebe6ba84fd8f6b9b Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Fri, 8 Jul 2016 11:49:59 +0900 Subject: [PATCH 02/16] [application] remove useless code to check presence when send replycallback Change-Id: I491579a5786c7e657de93cca6c23bce7801a83f7 --- src/application/requested_application_control.cc | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/src/application/requested_application_control.cc b/src/application/requested_application_control.cc index 79bbf43..04adbc4 100755 --- a/src/application/requested_application_control.cc +++ b/src/application/requested_application_control.cc @@ -107,14 +107,6 @@ void RequestedApplicationControl::ReplyResult(const picojson::value& args, picoj return; } - // code to check caller liveness - result = VerifyCallerPresence(); - if (result.IsError()) { - LogAndReportError(result, out, - ("Failed VerifyCallerPresence()")); - return; - } - // create reply app_control_h reply; app_control_create(&reply); @@ -159,13 +151,6 @@ void RequestedApplicationControl::ReplyFailure(picojson::object* out) { return; } - // code to check caller liveness - result = VerifyCallerPresence(); - if (result.IsError()) { - LogAndReportError(result, out, ("Failed VerifyCallerPresence()")); - return; - } - // create reply app_control_h reply; app_control_create(&reply); -- 2.7.4 From d55dc5604b6a7821337f25b0a7b7fae61c91062c Mon Sep 17 00:00:00 2001 From: Andrzej Popowski Date: Fri, 8 Jul 2016 17:28:45 +0900 Subject: [PATCH 03/16] [Application] - Fixing undefined iconPath attribute issue TCT result: 99.47% (190/189/0/1/0) Change-Id: I79471656580973c1d22964e4c5caaed7270cf5af Signed-off-by: Andrzej Popowski --- src/application/application_utils.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/application/application_utils.cc b/src/application/application_utils.cc index 9cf23d5..1c39776 100644 --- a/src/application/application_utils.cc +++ b/src/application/application_utils.cc @@ -39,6 +39,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h ret = pkgmgrinfo_appinfo_get_appid(handle, &tmp_str); if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) { LoggerE("Failed to get appid: %d (%s)", ret, get_error_message(ret)); + app_info->insert(std::make_pair("id", picojson::value(""))); } else { app_info->insert(std::make_pair("id", picojson::value(tmp_str))); } @@ -57,6 +58,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h ret = pkgmgrinfo_appinfo_get_icon(handle, &tmp_str); if ((PMINFO_R_OK != ret) || (nullptr == tmp_str)) { LoggerE("Failed to get icon path: %d (%s)", ret, get_error_message(ret)); + app_info->insert(std::make_pair("iconPath", picojson::value(""))); } else { app_info->insert(std::make_pair("iconPath", picojson::value(tmp_str))); } @@ -67,6 +69,7 @@ void ApplicationUtils::CreateApplicationInformation(const pkgmgrinfo_appinfo_h h ret = pkgmgrinfo_appinfo_is_nodisplay(handle, &no_display); if (PMINFO_R_OK != ret) { LoggerE("Failed to get nodisplay: %d (%s)", ret, get_error_message(ret)); + app_info->insert(std::make_pair("show", picojson::value(false))); } else { app_info->insert(std::make_pair("show", picojson::value(!no_display))); } -- 2.7.4 From e70dd941d819ab7555a41fc2c6e9a30a9b8d4a5e Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Fri, 8 Jul 2016 17:58:42 +0900 Subject: [PATCH 04/16] [version] 1.13 Change-Id: I7e765b0c482c8296bfb403bd2e643bb6aab00b80 --- 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 14d7984..441ed80 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.12 +Version: 1.13 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries -- 2.7.4 From d4edef757216de89a5b237253f4876d6d1e5d649 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Fri, 8 Jul 2016 19:10:41 +0900 Subject: [PATCH 05/16] [version] 1.14 Change-Id: I249a6b07892ba8d348d249c49612ac9b5befd6dc --- 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 441ed80..b5ce1eb 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.13 +Version: 1.14 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries -- 2.7.4 From e2cbe720924344b0cd43000f1f1394a1df798e9e Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Fri, 8 Jul 2016 12:46:53 +0200 Subject: [PATCH 06/16] [Preference] Improved behaviour on removing key [Feature] Removing listener also when key was removed. [Verification] Code compiles without errors. TCT passrate is 100%. Change-Id: I4aa9c6f4ffea08b526dad26e39fe67c8fd076fb0 Signed-off-by: Piotr Kosko --- src/preference/preference_manager.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/preference/preference_manager.cc b/src/preference/preference_manager.cc index 2461f3f..e24be80 100644 --- a/src/preference/preference_manager.cc +++ b/src/preference/preference_manager.cc @@ -214,8 +214,14 @@ common::TizenResult PreferenceManager::GetValue(const std::string& key) { common::TizenResult PreferenceManager::Remove(const std::string& key) { ScopeLogger(); - int ret = preference_remove(key.c_str()); + // unsetting listener if it is registered for key to be removed + auto res = UnsetChangeListener(key); + if (!res) { + //only log an error - listener could not be set + LoggerD("unsetting listener for given key failed, ignore error"); + } + int ret = preference_remove(key.c_str()); if (ret == PREFERENCE_ERROR_NONE) { return common::TizenSuccess(); } else { @@ -227,8 +233,9 @@ common::TizenResult PreferenceManager::RemoveAll() { ScopeLogger(); int ret = preference_remove_all(); - if (ret == PREFERENCE_ERROR_NONE) { + //only clear vector (listeners are removed natively in preference_remove_all function) + key_listeners_.clear(); return common::TizenSuccess(); } else { return MakeErrResult(ret, "preference_remove_all function error"); -- 2.7.4 From 8d11ea4eebcddd7989ce2002a885a318e8a3b37e Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Fri, 8 Jul 2016 20:01:40 +0900 Subject: [PATCH 07/16] [version] 1.15 Change-Id: Ia8dbadfc1557f5265eefa097d06c4aa3bfede987 --- 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 b5ce1eb..495a605 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.14 +Version: 1.15 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries -- 2.7.4 From 0550028f26a3cbb6b42d778e86b00f4dfb06b638 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Mon, 11 Jul 2016 15:34:44 +0900 Subject: [PATCH 08/16] disable telephony feature due to beta release - this fix is related with capability TC ( NBS, callhistory ) Change-Id: I13016ab476e371704d7c867f3a5ab29d03a1f75e --- packaging/webapi-plugins.spec | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index 495a605..46638a6 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.15 +Version: 1.16 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries @@ -149,7 +149,11 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_sound_support 1 %define tizen_feature_system_info_support 1 %define tizen_feature_system_setting_support 1 +%if 0%{?tizen_is_emulator} +%define tizen_feature_telephony_support 0 +%else %define tizen_feature_telephony_support 1 +%endif %define tizen_feature_time_support 1 %define tizen_feature_web_setting_support 1 %define tizen_feature_widget_service_support 1 -- 2.7.4 From d7e21726c2e9f1a138682dda2815c80bf9e276b3 Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Wed, 13 Jul 2016 10:34:05 +0200 Subject: [PATCH 09/16] [Messaging] Fixed SVACE issues [Bug] Fixed issues 107586, 107587 [Verification] Code compiles without errors. Change-Id: I9ef9bea7b189174726dfc9d993df5234c88122a8 Signed-off-by: Piotr Kosko --- src/messaging/email_manager.cc | 2 +- src/messaging/message.cc | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/messaging/email_manager.cc b/src/messaging/email_manager.cc index cd275db..6fa77de 100755 --- a/src/messaging/email_manager.cc +++ b/src/messaging/email_manager.cc @@ -1433,7 +1433,7 @@ std::string EmailManager::getMessageStatus(int id) { MessageStatus status = MessageStatus::STATUS_UNDEFINED; int ret = email_get_mail_data(id, &mail); - if (EMAIL_ERROR_NONE != ret ) { + if (EMAIL_ERROR_NONE != ret || !mail) { LoggerD("Failed to get data %d (%s)", ret, get_error_message(ret)); return ""; } diff --git a/src/messaging/message.cc b/src/messaging/message.cc index 196bf07..3f77486 100755 --- a/src/messaging/message.cc +++ b/src/messaging/message.cc @@ -496,7 +496,10 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr message, } if(message->is_id_set()) { - email_get_mail_data(message->getId(), &mail_data); + int ret = email_get_mail_data(message->getId(), &mail_data); + if (EMAIL_ERROR_NONE != ret || !mail_data) { + return LogAndCreateResult(ErrorCode::UNKNOWN_ERR, "Failed to get mail data."); + } } else { mail_data = (email_mail_data_t*)malloc(sizeof(email_mail_data_t)); if (!mail_data) { @@ -505,7 +508,7 @@ PlatformResult Message::convertPlatformEmail(std::shared_ptr message, memset(mail_data, 0x00, sizeof(email_mail_data_t)); } - std::unique_ptr mail_data_ptr( + std::unique_ptr mail_data_ptr( mail_data, [](email_mail_data_t* mail) {email_free_mail_data(&mail, 1);}); if(!message->getFrom().empty()) { -- 2.7.4 From 0d2cf2c5b5c463b7cca026f097df2227a9ac04ba Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Wed, 13 Jul 2016 18:00:22 +0900 Subject: [PATCH 10/16] [version] 1.17 Change-Id: Iae85ae7fcf4bd11362b6ccb70802b4960ea8176f --- 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 46638a6..cc0668f 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.16 +Version: 1.17 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries -- 2.7.4 From 9ba5758fe819754c1bc077759af821790c95bf96 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Wed, 13 Jul 2016 18:20:58 +0900 Subject: [PATCH 11/16] [nfc] disable nfc module on emulator Change-Id: I74995e2d111e54a871b2c8fd45be9e04fb45389c --- packaging/webapi-plugins.spec | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index cc0668f..bc2e616 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.17 +Version: 1.18 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries @@ -128,13 +128,13 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_message_port_support 1 %define tizen_feature_messaging_support 1 -%if 0%{?tizen_is_emulator} -%define tizen_feature_nfc_emulation_support 0 -%define tizen_feature_nfc_support 1 -%else +#%if 0%{?tizen_is_emulator} +#%define tizen_feature_nfc_emulation_support 0 +#%define tizen_feature_nfc_support 1 +#%else %define tizen_feature_nfc_emulation_support 0 %define tizen_feature_nfc_support 0 -%endif +#%endif %define tizen_feature_notification_support 1 %define tizen_feature_package_support 1 %define tizen_feature_power_support 1 @@ -232,7 +232,11 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_message_port_support 1 %define tizen_feature_messaging_support 0 %define tizen_feature_nfc_emulation_support 0 +%if 0%{?tizen_is_emulator} +%define tizen_feature_nfc_support 0 +%else %define tizen_feature_nfc_support 1 +%endif %define tizen_feature_notification_support 1 %define tizen_feature_package_support 1 %define tizen_feature_power_support 1 -- 2.7.4 From d02364009b6f6f5310324eddf42807602dacc2af Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Thu, 14 Jul 2016 14:21:00 +0900 Subject: [PATCH 12/16] [wearable emulator] disable telephony feature Change-Id: I458735f8d864070867979ddde49db609b922081c --- packaging/webapi-plugins.spec | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/packaging/webapi-plugins.spec b/packaging/webapi-plugins.spec index bc2e616..a67a6fc 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.18 +Version: 1.19 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries @@ -251,11 +251,11 @@ Source0: %{name}-%{version}.tar.gz %define tizen_feature_sound_support 1 %define tizen_feature_system_info_support 1 %define tizen_feature_system_setting_support 1 -%if 0%{?tizen_is_emulator} -%define tizen_feature_telephony_support 1 -%else +#%if 0%{?tizen_is_emulator} +#%define tizen_feature_telephony_support 1 +#%else %define tizen_feature_telephony_support 0 -%endif +#%endif %define tizen_feature_time_support 1 %define tizen_feature_web_setting_support 0 %define tizen_feature_widget_service_support 1 -- 2.7.4 From 13db6c87bb0f779117559084955032a118b7067a Mon Sep 17 00:00:00 2001 From: Piotr Kosko Date: Fri, 15 Jul 2016 13:13:07 +0200 Subject: [PATCH 13/16] [Systeminfo] Fixed getPropertyValue issue [Bug] When getPropertyValue failed, async operation counter was not updated properly [Verification] Code compiles without errors TCT passrate 100%. Change-Id: I1490abf84d122eb34f236a54acdcee792f5659af Signed-off-by: Piotr Kosko --- src/systeminfo/systeminfo_manager.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/systeminfo/systeminfo_manager.cc b/src/systeminfo/systeminfo_manager.cc index c332383..e9272fe 100644 --- a/src/systeminfo/systeminfo_manager.cc +++ b/src/systeminfo/systeminfo_manager.cc @@ -630,13 +630,12 @@ void SysteminfoManager::GetPropertyValue(const picojson::value& args, picojson:: LoggerD("Getting"); picojson::value result = picojson::value(picojson::object()); PlatformResult ret = prop_manager_.GetPropertyValue(prop_id, false, &result); + async_op_->finish(); if (ret.IsError()) { LogAndReportError(ret,&(response->get())); return; } ReportSuccess(result, response->get()); - - async_op_->finish(); }; auto get_response = [this, callback_id](const std::shared_ptr& response) -> void { @@ -667,6 +666,7 @@ void SysteminfoManager::GetPropertyValueArray(const picojson::value& args, picoj picojson::value result = picojson::value(picojson::object()); PlatformResult ret = prop_manager_.GetPropertyValue(prop_id, true, &result); + async_op_->finish(); if (ret.IsError()) { LogAndReportError( ret, &(response->get()), @@ -674,8 +674,6 @@ void SysteminfoManager::GetPropertyValueArray(const picojson::value& args, picoj return; } ReportSuccess(result, response->get()); - - async_op_->finish(); }; auto get_response = [this, callback_id](const std::shared_ptr& response) -> void { -- 2.7.4 From 0d2602476e89c15764a7af5b5ccce858ff50f246 Mon Sep 17 00:00:00 2001 From: Hyunjin Park Date: Mon, 18 Jul 2016 10:15:56 +0900 Subject: [PATCH 14/16] [version] 1.20 Change-Id: Iac03a5112634484779229555d776871526594438 --- 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 a67a6fc..d00125b 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.19 +Version: 1.20 Release: 0 License: Apache-2.0 and BSD-2.0 and MIT Group: Development/Libraries -- 2.7.4 From 000e66db1e7c846d06fe61c016951d9cc31912c3 Mon Sep 17 00:00:00 2001 From: Tomasz Marciniak Date: Tue, 26 Jul 2016 08:08:36 +0200 Subject: [PATCH 15/16] [Widgetservice] NotFoundError separated from AbortError. [Verification] Code compiles. Change-Id: I291ad7deb001fe32284cff520a82746e673ea563 Signed-off-by: Tomasz Marciniak --- src/widgetservice/widgetservice_utils.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/widgetservice/widgetservice_utils.cc b/src/widgetservice/widgetservice_utils.cc index 7ba52e0..142cbbb 100644 --- a/src/widgetservice/widgetservice_utils.cc +++ b/src/widgetservice/widgetservice_utils.cc @@ -84,12 +84,13 @@ TizenResult WidgetServiceUtils::ConvertErrorCode(int error) { return common::NotSupportedError(error); case WIDGET_ERROR_CANCELED: return common::OperationCanceledError(error); + case WIDGET_ERROR_NOT_EXIST: + return common::NotFoundError(error); case WIDGET_ERROR_OUT_OF_MEMORY: case WIDGET_ERROR_FILE_NO_SPACE_ON_DEVICE: case WIDGET_ERROR_FAULT: case WIDGET_ERROR_ALREADY_EXIST: case WIDGET_ERROR_ALREADY_STARTED: - case WIDGET_ERROR_NOT_EXIST: default: return common::AbortError(error); } -- 2.7.4 From fdce93945c9998c69b5d18be4644b02e5fda24b0 Mon Sep 17 00:00:00 2001 From: Andrzej Popowski Date: Mon, 13 Jun 2016 14:48:20 +0200 Subject: [PATCH 16/16] [Content] - The function createThumbnail() implemented Change-Id: I0b3589ea25c87db9b5765f77d0b308dc7b25f9f8 Signed-off-by: Andrzej Popowski --- src/content/content_instance.cc | 23 ++++++++++++++-- src/content/content_instance.h | 1 + src/content/content_manager.cc | 60 +++++++++++++++++++++++++++++++++++++++++ src/content/content_manager.h | 13 ++++++--- src/content/js/manager.js | 26 ++++++++++++++++++ 5 files changed, 117 insertions(+), 6 deletions(-) diff --git a/src/content/content_instance.cc b/src/content/content_instance.cc index 659c4f1..9008f68 100755 --- a/src/content/content_instance.cc +++ b/src/content/content_instance.cc @@ -51,7 +51,7 @@ ContentInstance::ContentInstance() : using std::placeholders::_1; using std::placeholders::_2; - #define REGISTER_SYNC(c,x) \ +#define REGISTER_SYNC(c,x) \ RegisterSyncHandler(c, std::bind(&ContentInstance::x, this, _1, _2)); REGISTER_SYNC("ContentManager_find", ContentManagerFind); @@ -80,7 +80,10 @@ ContentInstance::ContentInstance() : REGISTER_SYNC("ContentPlaylist_getThumbnailUri", PlaylistGetThumbnailUri); REGISTER_SYNC("ContentPlaylist_setThumbnailUri", PlaylistSetThumbnailUri); REGISTER_SYNC("ContentPlaylist_getNumberOfTracks", PlaylistGetNumberOfTracks); - #undef REGISTER_SYNC + REGISTER_SYNC("ContentManager_createThumbnail", ContentManagerCreateThumbnail); +#undef REGISTER_SYNC + + ContentManager::getInstance()->setContentInstance(this); } ContentInstance::~ContentInstance() { @@ -93,6 +96,7 @@ ContentInstance::~ContentInstance() { delete listener_data_; listener_data_ = nullptr; } + ContentManager::getInstance()->setContentInstance(nullptr); } static gboolean CompletedCallback(const std::shared_ptr& user_data) { @@ -593,7 +597,22 @@ void ContentInstance::ContentManagerRemoveplaylist(const picojson::value& args, // implement it common::TaskQueue::GetInstance().Queue(WorkThread, CompletedCallback, cbData); +} + +void ContentInstance::ContentManagerCreateThumbnail(const picojson::value& args, picojson::object& out) { + LoggerD("entered"); + CHECK_PRIVILEGE_ACCESS(kPrivilegeContentWrite, &out); + common::PlatformResult result = common::PlatformResult(common::ErrorCode::NO_ERROR); + if(ContentManager::getInstance()->isConnected()) { + result = ContentManager::getInstance()->createThumbnail(args); + } else { + result = LogAndCreateResult(common::ErrorCode::UNKNOWN_ERR, "DB Connection is failed."); + } + if (!result) { + LogAndReportError(result, &out, ("Failed to create a thumbnail")); + common::Instance::PostMessage(this, picojson::value(out).serialize().c_str()); + } } void ContentInstance::ContentManagerPlaylistAdd(const picojson::value& args, picojson::object& out) { diff --git a/src/content/content_instance.h b/src/content/content_instance.h index 0025d2b..a631e62 100755 --- a/src/content/content_instance.h +++ b/src/content/content_instance.h @@ -84,6 +84,7 @@ class ContentInstance : public common::ParsedInstance { void ContentManagerPlaylistSetorder(const picojson::value& args, picojson::object& out); void ContentManagerPlaylistMove(const picojson::value& args, picojson::object& out); void ContentManagerAudioGetLyrics(const picojson::value& args, picojson::object& out); + void ContentManagerCreateThumbnail(const picojson::value& args, picojson::object& out); void PlaylistGetName(const picojson::value& args, picojson::object& out); void PlaylistSetName(const picojson::value& args, picojson::object& out); diff --git a/src/content/content_manager.cc b/src/content/content_manager.cc index 6aa319d..28140da 100644 --- a/src/content/content_manager.cc +++ b/src/content/content_manager.cc @@ -36,6 +36,7 @@ using namespace std; using namespace common; +using common::tools::ReportSuccess; using common::tools::ReportError; namespace extension { @@ -660,6 +661,31 @@ static bool playlist_content_member_cb(int playlist_member_id, media_info_h medi return true; } +void CreateThumbnailCallback(media_content_error_e err, const char* path, void* user_data) { + LoggerD("Enter"); + + if (!(ContentManager::getInstance()->getContentInstance())) { + // There is not instance already + LoggerD("There is not instance now"); + return; + } + + unsigned int callbackId = (unsigned int) user_data; + picojson::object out; + + out["callbackId"] = picojson::value(static_cast(callbackId)); + + if (MEDIA_CONTENT_ERROR_NONE == err) { + out["result"] = picojson::value(std::string(path)); + ReportSuccess(out); + } else { + PlatformResult result = ContentManager::getInstance()->convertError(err); + LogAndReportError(result, &out, ("Failed to create a thumbnail")); + } + common::Instance::PostMessage(ContentManager::getInstance()->getContentInstance(), + picojson::value(out).serialize().c_str()); +} + ContentManager::ContentManager() { LoggerD("ContentManager called"); @@ -668,6 +694,7 @@ ContentManager::ContentManager() { } else m_dbConnected = false; + m_contentInstance = nullptr; } ContentManager::~ContentManager() { @@ -685,6 +712,16 @@ ContentManager* ContentManager::getInstance() { return &instance; } +ContentInstance* ContentManager::getContentInstance() { + LoggerD("Enter"); + return m_contentInstance; +} + +void ContentManager::setContentInstance(ContentInstance* const content_instance) { + LoggerD("Enter"); + m_contentInstance = content_instance; +} + bool ContentManager::isConnected() { LoggerD("Enter"); return m_dbConnected; @@ -1596,6 +1633,29 @@ int ContentManager::getNumberOfTracks(int id, int* result) { return MEDIA_CONTENT_ERROR_NONE; } +common::PlatformResult ContentManager::createThumbnail(const picojson::value& args) { + LoggerD("Enter"); + + unsigned int callbackId = static_cast(args.get("callbackId").get()); + std::string id = args.get("id").get(); + + media_info_h media = NULL; + int ret = media_info_get_media_from_db(id.c_str(), &media); + if(MEDIA_CONTENT_ERROR_NONE != ret && nullptr == media) { + return LogAndCreateResult(ErrorCode::ABORT_ERR, "Getting media is failed.", + ("Getting media is failed: %d (%s)", ret, get_error_message(ret))); + } + + ret = media_info_create_thumbnail(media, CreateThumbnailCallback, (void*) callbackId); + media_info_destroy(media); + if(MEDIA_CONTENT_ERROR_NONE != ret) { + return LogAndCreateResult(ErrorCode::ABORT_ERR, "Creating thumbnail failed.", + ("Creating thumbnail failed: %d (%s)", ret, get_error_message(ret))); + } + + return PlatformResult(ErrorCode::NO_ERROR); +} + PlatformResult ContentManager::convertError(int err) { char* error_msg = get_error_message(err); switch (err) { diff --git a/src/content/content_manager.h b/src/content/content_manager.h index 36b52d5..60a177f 100644 --- a/src/content/content_manager.h +++ b/src/content/content_manager.h @@ -43,6 +43,8 @@ class ContentManager { virtual ~ContentManager(); bool isConnected(); static ContentManager* getInstance(); + ContentInstance* getContentInstance(); + void setContentInstance(ContentInstance* const content_instance); void getDirectories(const std::shared_ptr& user_data); void find(const std::shared_ptr& user_data); @@ -74,23 +76,26 @@ class ContentManager { void playlistRemovebatch(const std::shared_ptr& user_data); void playlistSetOrder(const std::shared_ptr& user_data); void playlistMove(const std::shared_ptr& user_data); - int getPlaylistName(int id, std::string* result); int setPlaylistName(int id, const std::string& name); - int getThumbnailUri(int id, std::string* result); - int setThumbnailUri(int id, const std::string& thb_uri); - int getNumberOfTracks(int id, int* result); //playlistSetOrder static common::PlatformResult convertError(int err); + +//thumbnail + int getThumbnailUri(int id, std::string* result); + int setThumbnailUri(int id, const std::string& thb_uri); + common::PlatformResult createThumbnail(const picojson::value& args); + private: //int setContent(media_info_h media, picojson::value content); ContentManager(); private: bool m_dbConnected; + ContentInstance* m_contentInstance; }; diff --git a/src/content/js/manager.js b/src/content/js/manager.js index 009156d..00ffadd 100755 --- a/src/content/js/manager.js +++ b/src/content/js/manager.js @@ -371,4 +371,30 @@ ContentManager.prototype.removePlaylist = function(id, successCallback, errorCal } }; +ContentManager.prototype.createThumbnail = function(content, successCallback, errorCallback) { + var args = validator_.validateArgs(arguments, [ + {name: 'content', type: types_.PLATFORM_OBJECT, values: Content}, + {name: 'successCallback', type: types_.FUNCTION}, + {name: 'errorCallback', type: types_.FUNCTION, optional: true, nullable: true} + ]); + + var data = { + id: args.content.id + }; + + var callback = function(result) { + if (native_.isFailure(result)) { + native_.callIfPossible(args.errorCallback, native_.getErrorObject(result)); + return; + } + args.successCallback(native_.getResultObject(result)); + }; + + var result = native_.call('ContentManager_createThumbnail', data, callback); + + if (native_.isFailure(result)) { + throw native_.getErrorObject(result); + } +}; + exports = new ContentManager(); -- 2.7.4