From eed22302c06a86cd84f65d0e2c4eccfb02395001 Mon Sep 17 00:00:00 2001 From: Jihoon Chung Date: Sat, 22 Jun 2013 21:13:16 +0900 Subject: [PATCH] [Release] wrt_0.8.225 Change-Id: Ie331d03b0d526c24f43f5cebf2c132c7675f8fe5 --- LICENSE => LICENSE.APLv2 | 0 LICENSE.Flora | 206 +++++++++++++++ packaging/wrt.spec | 5 +- src/api_new/ewk_context_manager.cpp | 85 ++++-- src/api_new/ewk_context_manager.h | 7 +- src/api_new/user_delegates.h | 5 +- src/domain/widget_data_types.cpp | 24 +- src/domain/widget_data_types.h | 17 +- src/view/common/application_launcher.cpp | 1 - src/view/common/message_support.h | 6 +- src/view/common/scheme_action_map.cpp | 152 +++++++++-- src/view/common/scheme_action_map_data.h | 2 + src/view/i_view_module.h | 3 + src/view/webkit/injected-bundle/CMakeLists.txt | 1 + .../injected_bundle_decryption_support.cpp | 4 +- .../injected_bundle_uri_handling.cpp | 2 +- .../injected_bundle_viewmodes_support.cpp | 231 +++++++++++++++++ .../injected_bundle_viewmodes_support.h | 46 ++++ .../webkit/injected-bundle/wrt-injected-bundle.cpp | 48 ++-- .../webkit/injected-bundle/wrt-injected-bundle.h | 3 +- src/view/webkit/view_logic.cpp | 239 ++++++++++++----- src/view/webkit/view_logic.h | 8 + src/view/webkit/view_logic_geolocation_support.cpp | 13 +- src/view/webkit/view_logic_message_support.cpp | 8 +- src/view/webkit/view_logic_message_support.h | 1 + src/view/webkit/view_logic_orientation_support.cpp | 77 ++---- src/view/webkit/view_logic_orientation_support.h | 18 +- src/wrt-client/CMakeLists.txt | 6 +- src/wrt-client/auto_rotation_support.cpp | 91 +++++++ src/wrt-client/auto_rotation_support.h | 34 +++ src/wrt-client/client_service_support.cpp | 159 ++++++++++++ src/wrt-client/client_service_support.h | 27 ++ src/wrt-client/splash_screen_support.cpp | 8 +- src/wrt-client/window_data.cpp | 157 +++++++---- src/wrt-client/window_data.h | 50 ++-- src/wrt-client/wrt-client.cpp | 288 ++++++++++++++------- src/wrt-client/wrt-client.h | 29 ++- src/wrt-launcher/CMakeLists.txt | 1 + src/wrt-launcher/wrt-launcher.cpp | 84 +++--- src/wrt-launchpad-daemon/include/app_sock.h | 5 + src/wrt-launchpad-daemon/include/launchpad_util.h | 4 +- src/wrt-launchpad-daemon/include/simple_util.h | 8 + src/wrt-launchpad-daemon/launchpad_src/launchpad.c | 4 +- src/wrt-launchpad-daemon/legacy/preload.h | 74 +----- .../legacy/preload_list_wrt.txt | 3 + tests/widgets/common/include/mock/MockViewModule.h | 3 + tests/widgets/common/src/mock/MockViewModule.cpp | 6 + 47 files changed, 1754 insertions(+), 499 deletions(-) rename LICENSE => LICENSE.APLv2 (100%) create mode 100644 LICENSE.Flora create mode 100644 src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.cpp create mode 100644 src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.h mode change 100755 => 100644 src/view/webkit/view_logic_geolocation_support.cpp create mode 100644 src/wrt-client/auto_rotation_support.cpp create mode 100644 src/wrt-client/auto_rotation_support.h create mode 100644 src/wrt-client/client_service_support.cpp create mode 100644 src/wrt-client/client_service_support.h diff --git a/LICENSE b/LICENSE.APLv2 similarity index 100% rename from LICENSE rename to LICENSE.APLv2 diff --git a/LICENSE.Flora b/LICENSE.Flora new file mode 100644 index 0000000..4a0af40 --- /dev/null +++ b/LICENSE.Flora @@ -0,0 +1,206 @@ +Flora License + +Version 1.1, April, 2013 + +http://floralicense.org/license/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, +and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by +the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and +all other entities that control, are controlled by, or are +under common control with that entity. For the purposes of +this definition, "control" means (i) the power, direct or indirect, +to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of +such entity. + +"You" (or "Your") shall mean an individual or Legal Entity +exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, +including but not limited to software source code, documentation source, +and configuration files. + +"Object" form shall mean any form resulting from mechanical +transformation or translation of a Source form, including but +not limited to compiled object code, generated documentation, +and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, +made available under the License, as indicated by a copyright notice +that is included in or attached to the work (an example is provided +in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, +that is based on (or derived from) the Work and for which the editorial +revisions, annotations, elaborations, or other modifications represent, +as a whole, an original work of authorship. For the purposes of this License, +Derivative Works shall not include works that remain separable from, +or merely link (or bind by name) to the interfaces of, the Work and +Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original +version of the Work and any modifications or additions to that Work or +Derivative Works thereof, that is intentionally submitted to Licensor +for inclusion in the Work by the copyright owner or by an individual or +Legal Entity authorized to submit on behalf of the copyright owner. +For the purposes of this definition, "submitted" means any form of +electronic, verbal, or written communication sent to the Licensor or +its representatives, including but not limited to communication on +electronic mailing lists, source code control systems, and issue +tracking systems that are managed by, or on behalf of, the Licensor +for the purpose of discussing and improving the Work, but excluding +communication that is conspicuously marked or otherwise designated +in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity +on behalf of whom a Contribution has been received by Licensor and +subsequently incorporated within the Work. + +"Tizen Certified Platform" shall mean a software platform that complies +with the standards set forth in the Tizen Compliance Specification +and passes the Tizen Compliance Tests as defined from time to time +by the Tizen Technical Steering Group and certified by the Tizen +Association or its designated agent. + +2. Grant of Copyright License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +copyright license to reproduce, prepare Derivative Works of, +publicly display, publicly perform, sublicense, and distribute the +Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of +this License, each Contributor hereby grants to You a perpetual, +worldwide, non-exclusive, no-charge, royalty-free, irrevocable +(except as stated in this section) patent license to make, have made, +use, offer to sell, sell, import, and otherwise transfer the Work +solely as incorporated into a Tizen Certified Platform, where such +license applies only to those patent claims licensable by such +Contributor that are necessarily infringed by their Contribution(s) +alone or by combination of their Contribution(s) with the Work solely +as incorporated into a Tizen Certified Platform to which such +Contribution(s) was submitted. If You institute patent litigation +against any entity (including a cross-claim or counterclaim +in a lawsuit) alleging that the Work or a Contribution incorporated +within the Work constitutes direct or contributory patent infringement, +then any patent licenses granted to You under this License for that +Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the +Work or Derivative Works thereof pursuant to the copyright license +above, in any medium, with or without modifications, and in Source or +Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works + a copy of this License; and + 2. You must cause any modified files to carry prominent notices stating + that You changed the files; and + 3. You must retain, in the Source form of any Derivative Works that + You distribute, all copyright, patent, trademark, and attribution + notices from the Source form of the Work, excluding those notices + that do not pertain to any part of the Derivative Works; and + 4. If the Work includes a "NOTICE" text file as part of its distribution, + then any Derivative Works that You distribute must include a readable + copy of the attribution notices contained within such NOTICE file, + excluding those notices that do not pertain to any part of + the Derivative Works, in at least one of the following places: + within a NOTICE text file distributed as part of the Derivative Works; + within the Source form or documentation, if provided along with the + Derivative Works; or, within a display generated by the Derivative Works, + if and wherever such third-party notices normally appear. + The contents of the NOTICE file are for informational purposes only + and do not modify the License. You may add Your own attribution notices + within Derivative Works that You distribute, alongside or as an addendum + to the NOTICE text from the Work, provided that such additional attribution + notices cannot be construed as modifying the License. You may add Your own + copyright statement to Your modifications and may provide additional or + different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works + as a whole, provided Your use, reproduction, and distribution of + the Work otherwise complies with the conditions stated in this License + and your own copyright statement or terms and conditions do not conflict + the conditions stated in the License including section 3. + +5. Submission of Contributions. Unless You explicitly state otherwise, +any Contribution intentionally submitted for inclusion in the Work +by You to the Licensor shall be under the terms and conditions of +this License, without any additional terms or conditions. +Notwithstanding the above, nothing herein shall supersede or modify +the terms of any separate license agreement you may have executed +with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade +names, trademarks, service marks, or product names of the Licensor, +except as required for reasonable and customary use in describing the +origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or +agreed to in writing, Licensor provides the Work (and each +Contributor provides its Contributions) on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +implied, including, without limitation, any warranties or conditions +of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +PARTICULAR PURPOSE. You are solely responsible for determining the +appropriateness of using or redistributing the Work and assume any +risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, +whether in tort (including negligence), contract, or otherwise, +unless required by applicable law (such as deliberate and grossly +negligent acts) or agreed to in writing, shall any Contributor be +liable to You for damages, including any direct, indirect, special, +incidental, or consequential damages of any character arising as a +result of this License or out of the use or inability to use the +Work (including but not limited to damages for loss of goodwill, +work stoppage, computer failure or malfunction, or any and all +other commercial damages or losses), even if such Contributor +has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing +the Work or Derivative Works thereof, You may choose to offer, +and charge a fee for, acceptance of support, warranty, indemnity, +or other liability obligations and/or rights consistent with this +License. However, in accepting such obligations, You may act only +on Your own behalf and on Your sole responsibility, not on behalf +of any other Contributor, and only if You agree to indemnify, +defend, and hold each Contributor harmless for any liability +incurred by, or claims asserted against, such Contributor by reason +of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Flora License to your work + +To apply the Flora License to your work, attach the following +boilerplate notice, with the fields enclosed by brackets "[]" +replaced with your own identifying information. (Don't include +the brackets!) The text should be enclosed in the appropriate +comment syntax for the file format. We also recommend that a +file or class name and description of purpose be included on the +same "printed page" as the copyright notice for easier +identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Flora License, Version 1.1 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://floralicense.org/license/ + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + diff --git a/packaging/wrt.spec b/packaging/wrt.spec index 0a4fd12..d9cedf0 100644 --- a/packaging/wrt.spec +++ b/packaging/wrt.spec @@ -1,7 +1,7 @@ #git:framework/web/wrt Name: wrt Summary: web runtime -Version: 0.8.215 +Version: 0.8.225 Release: 1 Group: Development/Libraries License: Apache License, Version 2.0 @@ -94,7 +94,8 @@ make %{?jobs:-j%jobs} %install mkdir -p %{buildroot}/usr/share/license -cp LICENSE %{buildroot}/usr/share/license/%{name} +cp LICENSE.APLv2 %{buildroot}/usr/share/license/%{name} +cp LICENSE.Flora %{buildroot}/usr/share/license/%{name} %make_install ## wrt-launchpad-daemon ####################################################### diff --git a/src/api_new/ewk_context_manager.cpp b/src/api_new/ewk_context_manager.cpp index d3f973a..7e9a049 100644 --- a/src/api_new/ewk_context_manager.cpp +++ b/src/api_new/ewk_context_manager.cpp @@ -95,18 +95,7 @@ bool EwkContextManager::initialize() ADD_PROFILING_POINT("WebProcess fork", "stop"); // proxy server setting - char *proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); - if (proxy && strlen(proxy) && strcmp(proxy, "0.0.0.0")) { - LogInfo("proxy address: " << proxy); - ewk_context_proxy_uri_set(m_ewkContext, proxy); - } else { - LogInfo("proxy address is empty"); - ewk_context_proxy_uri_set(m_ewkContext, NULL); - } - - if (proxy) { - free(proxy); - } + setNetworkProxy(); LogInfo("ewk_context_certificate_file_set() was called."); ewk_context_certificate_file_set(m_ewkContext, caCertPath.c_str()); @@ -190,6 +179,27 @@ void EwkContextManager::setCallbacks() vibrationClientStartCallback, vibrationClientStopCallback, this); + + vconf_notify_key_changed(VCONFKEY_NETWORK_PROXY, + vconfChangedCallback, + this); +} + +void EwkContextManager::unsetCallbacks() +{ + if (!m_initialized) { + return; + } + + ewk_context_message_from_injected_bundle_callback_set( + m_ewkContext, NULL, NULL); + ewk_context_did_start_download_callback_set( + m_ewkContext, NULL, NULL); + ewk_context_vibration_client_callbacks_set( + m_ewkContext, NULL, NULL, NULL); + + vconf_ignore_key_changed(VCONFKEY_NETWORK_PROXY, + vconfChangedCallback); } void EwkContextManager::setAutoFullscreenMode() @@ -250,21 +260,31 @@ void EwkContextManager::setCSPSupport() true); } -void EwkContextManager::unsetCallbacks() +void EwkContextManager::setNetworkProxy() { - if (!m_initialized) { + Assert(m_ewkContext); + + int networkState; + if (vconf_get_int(VCONFKEY_NETWORK_STATUS, + &networkState) != 0) + { + LogError("Fail to get network state"); + return; + } + if (networkState == VCONFKEY_NETWORK_OFF) { return; } - ewk_context_message_from_injected_bundle_callback_set( - m_ewkContext, NULL, NULL); - ewk_context_did_start_download_callback_set( - m_ewkContext, NULL, NULL); - ewk_context_vibration_client_callbacks_set( - m_ewkContext, NULL, NULL, NULL); + char* proxy = vconf_get_str(VCONFKEY_NETWORK_PROXY); + if (proxy && strlen(proxy) && strcmp(proxy, "0.0.0.0")) { + LogInfo("proxy address: " << proxy); + ewk_context_proxy_uri_set(m_ewkContext, proxy); + } else { + LogInfo("proxy address is empty"); + ewk_context_proxy_uri_set(m_ewkContext, NULL); + } } - void EwkContextManager::messageFromInjectedBundleCallback( const char* name, const char* body, @@ -275,7 +295,11 @@ void EwkContextManager::messageFromInjectedBundleCallback( LogDebug("did recive message: " << name); EwkContextManager* This = static_cast(clientInfo); - This->m_view->checkSyncMessageFromBundle(name, body, returnData); + if (returnData) { + This->m_view->checkSyncMessageFromBundle(name, body, returnData); + } else { + This->m_view->checkAsyncMessageFromBundle(name, body); + } } void EwkContextManager::didStartDownloadCallback(const char* downloadUrl, void* data) @@ -303,6 +327,23 @@ void EwkContextManager::vibrationClientStopCallback(void* data) This->m_view->activateVibration(false, 0); } +void EwkContextManager::vconfChangedCallback(keynode_t* keynode, void* data) +{ + LogDebug("enter"); + char* key = vconf_keynode_get_name(keynode); + + if (NULL == key) { + LogError("key is null"); + return; + } + std::string keyString = key; + Assert(data); + EwkContextManager* This = static_cast(data); + if (keyString == VCONFKEY_NETWORK_PROXY) { + This->setNetworkProxy(); + } +} + void EwkContextManager::handleLowMemory() { if (!m_ewkContext) { diff --git a/src/api_new/ewk_context_manager.h b/src/api_new/ewk_context_manager.h index 9aaff1f..444c0f7 100644 --- a/src/api_new/ewk_context_manager.h +++ b/src/api_new/ewk_context_manager.h @@ -24,7 +24,8 @@ #ifndef EWK_CONTEXT_MANAGER_H #define EWK_CONTEXT_MANAGER_H -#include +#include +#include namespace WRT { @@ -46,6 +47,7 @@ class EwkContextManager : public AbstractContextManager { void setAutoFullscreenMode(); void setBackgroundSupport(); void setCSPSupport(); + void setNetworkProxy(); // ewk context callback functions static void messageFromInjectedBundleCallback( @@ -57,6 +59,9 @@ class EwkContextManager : public AbstractContextManager { static void vibrationClientStartCallback(uint64_t time, void* data); static void vibrationClientStopCallback(void* data); + // vconf callback functions + static void vconfChangedCallback(keynode_t* keynode, void* data); + // members bool m_initialized; bool m_isInternalContext; diff --git a/src/api_new/user_delegates.h b/src/api_new/user_delegates.h index 5d2dc0c..5112ad7 100644 --- a/src/api_new/user_delegates.h +++ b/src/api_new/user_delegates.h @@ -46,6 +46,8 @@ typedef DPL::FastDelegate1 BufferUnsetCB; typedef DPL::FastDelegate1 BufferSetCB; typedef DPL::FastDelegate1 ToggleFullscreenCB; typedef DPL::FastDelegate1 EditorclientImeCB; +typedef DPL::FastDelegate1 OrientationCB; +typedef DPL::FastDelegate1 HWkeyCB; struct UserDelegates { ProgressStartedCB progressStarted; @@ -65,7 +67,8 @@ struct UserDelegates { BufferUnsetCB bufferUnset; BufferSetCB bufferSet; ToggleFullscreenCB toggleFullscreen; - EditorclientImeCB editorClientIme; + OrientationCB setOrientation; + HWkeyCB hwkey; }; typedef std::shared_ptr UserDelegatesPtr; diff --git a/src/domain/widget_data_types.cpp b/src/domain/widget_data_types.cpp index 3517792..87ebb73 100644 --- a/src/domain/widget_data_types.cpp +++ b/src/domain/widget_data_types.cpp @@ -99,7 +99,8 @@ WidgetSettingList::WidgetSettingList() : m_ContextMenu(ContextMenu_Enable), m_Encryption(Encryption_Disable), m_BackgroundSupport(BackgroundSupport_Disable), - m_ProgressbarPresence(ProgressBar_Disable) + m_ProgressbarPresence(ProgressBar_Disable), + m_HWkeyEvent(HWkeyEvent_Enable) {} WidgetSettingList::WidgetSettingList(WrtDB::WidgetSettings &widgetSettings) @@ -111,6 +112,7 @@ WidgetSettingList::WidgetSettingList(WrtDB::WidgetSettings &widgetSettings) m_Encryption = Encryption_Disable; m_BackgroundSupport = BackgroundSupport_Disable; m_ProgressbarPresence = ProgressBar_Disable; + m_HWkeyEvent = HWkeyEvent_Enable; FOREACH(it, widgetSettings) { @@ -203,6 +205,16 @@ WidgetSettingList::WidgetSettingList(WrtDB::WidgetSettings &widgetSettings) value << "]"); m_ProgressbarPresence = ProgressBar_Disable; } + } else if (name == SETTING_NAME_HWKEY_EVENT) { + if (value == SETTING_VALUE_HWKEY_EVENT_ENABLE) { + m_HWkeyEvent = HWkeyEvent_Enable; + } else if (value == SETTING_VALUE_HWKEY_EVENT_DISABLE) { + m_HWkeyEvent = HWkeyEvent_Disable; + } else { + LogError("Invalid hwkey-event value!! [" << + value << "]"); + m_HWkeyEvent = HWkeyEvent_Enable; + } } else { LogError("Invalid setting name!! [" << name << "]"); } @@ -277,6 +289,13 @@ WidgetSettingProgressBarPresence WidgetSettingList::getProgressBarPresence() con return m_ProgressbarPresence; } +WidgetSettingHWkeyEventPresence WidgetSettingList::getHWkeyEvent() const +{ + LogDebug("m_HWkeyEvent: " << m_HWkeyEvent); + + return m_HWkeyEvent; +} + bool WidgetSettingList::operator ==(const WidgetSettingList& other) const { return m_RotationLock == other.m_RotationLock && @@ -286,5 +305,6 @@ bool WidgetSettingList::operator ==(const WidgetSettingList& other) const m_Encryption == other.m_Encryption && m_BackgroundSupport == other.m_BackgroundSupport && m_UserAgent == other.m_UserAgent && - m_ProgressbarPresence == other.m_ProgressbarPresence; + m_ProgressbarPresence == other.m_ProgressbarPresence && + m_HWkeyEvent == other.m_HWkeyEvent; } diff --git a/src/domain/widget_data_types.h b/src/domain/widget_data_types.h index ca90140..9d8f654 100644 --- a/src/domain/widget_data_types.h +++ b/src/domain/widget_data_types.h @@ -110,6 +110,8 @@ static const DPL::String SETTING_NAME_USER_AGENT = L"user-agent"; static const DPL::String SETTING_NAME_PROGRESSBAR_PRESENCE = L"progressbar-presence"; +static const DPL::String SETTING_NAME_HWKEY_EVENT = + L"hwkey-event"; static const DPL::String SETTING_VALUE_ENABLE = L"enable"; static const DPL::String SETTING_VALUE_DISABLE = @@ -138,6 +140,10 @@ static const DPL::String SETTING_VALUE_PROGRESSBAR_PRESENCE_ENABLE = L"enable"; static const DPL::String SETTING_VALUE_PROGRESSBAR_PRESENCE_DISABLE = L"disable"; +static const DPL::String SETTING_VALUE_HWKEY_EVENT_ENABLE = + L"enable"; +static const DPL::String SETTING_VALUE_HWKEY_EVENT_DISABLE = + L"disable"; enum WidgetSettingScreenLock { @@ -182,6 +188,12 @@ enum WidgetSettingProgressBarPresence ProgressBar_Disable /* Default */ }; +enum WidgetSettingHWkeyEventPresence +{ + HWkeyEvent_Enable, /* Default */ + HWkeyEvent_Disable +}; + class WidgetSettingList { public: @@ -205,7 +217,9 @@ class WidgetSettingList std::string getUserAgent() const; - WidgetSettingProgressBarPresence getProgressBarPresence() const; + WidgetSettingProgressBarPresence getProgressBarPresence() const; + + WidgetSettingHWkeyEventPresence getHWkeyEvent() const; bool operator ==(const WidgetSettingList& other) const; @@ -217,6 +231,7 @@ class WidgetSettingList WidgetSettingEncryption m_Encryption; WidgetSettingBackgroundSupport m_BackgroundSupport; WidgetSettingProgressBarPresence m_ProgressbarPresence; + WidgetSettingHWkeyEventPresence m_HWkeyEvent; std::string m_UserAgent; }; typedef std::shared_ptr WidgetSettingListPtr; diff --git a/src/view/common/application_launcher.cpp b/src/view/common/application_launcher.cpp index 8dbb473..fc8f885 100644 --- a/src/view/common/application_launcher.cpp +++ b/src/view/common/application_launcher.cpp @@ -134,7 +134,6 @@ void ApplicationLauncher::OnEventReceived( return; } - LogDebug("Success launch " << SERVICE_OPERATION_DOWNLOAD); service_destroy(serviceHandle); return; } else if (PKG_NAME_VIDEO_PLAYER == pkgName) { diff --git a/src/view/common/message_support.h b/src/view/common/message_support.h index f657f0a..79b8e97 100644 --- a/src/view/common/message_support.h +++ b/src/view/common/message_support.h @@ -31,8 +31,9 @@ const char * const SHUTDOWN = "ToInjectedBundle::SHUTDOWN"; const char * const SET_CUSTOM_PROPERTIES = "ToInjectedBundle::SET_CUSTOM_PROPERTIES"; const char * const DISPATCH_JS_EVENT = "ToInjectedBundle::DISPATCH_JS_EVENT"; -const char * const SET_XWINDOW_HANDLE = - "ToInjectedBundle::SET_XWINDOW_HANDLE"; +const char * const SET_XWINDOW_HANDLE = "ToInjectedBundle::SET_XWINDOW_HANDLE"; +const char * const SET_VIEWMODES = "ToInjectedBundle::SET_VIEWMODES"; +const char * const SET_VIEWMODES_MSGBODY_EXIT = "exit"; } // namespace ToInectedBundle namespace ToUIProcess { @@ -44,6 +45,7 @@ const char * const SEND_WEBPROCESS_PID = "ToUIProcess::SEND_WEBPROCESS_PID"; namespace TizenScheme { const char * const GET_WINDOW_HANDLE = "tizen://getWindowHandle"; +const char * const CLEAR_ALL_COOKIES = "tizen://clearAllCookies"; } // namespace ToUIProcess } //namespace BundleMessages diff --git a/src/view/common/scheme_action_map.cpp b/src/view/common/scheme_action_map.cpp index fa661b7..ff81c5e 100644 --- a/src/view/common/scheme_action_map.cpp +++ b/src/view/common/scheme_action_map.cpp @@ -107,7 +107,8 @@ struct AppSvcConversion { */ struct ServiceOperation { const char* operation; - bool needUri; + const char* fakeUri; + const char* mime; std::list conversions; }; @@ -133,7 +134,8 @@ ServiceOperationMap initializeAppSvcOperations() // FILE, HTTP & HTTPS ServiceOperation viewOp; viewOp.operation = SERVICE_OPERATION_VIEW; - viewOp.needUri = true; + viewOp.fakeUri = NULL; + viewOp.mime = NULL; // no additional data ret.insert(std::make_pair(Scheme::FILE, viewOp)); ret.insert(std::make_pair(Scheme::HTTP, viewOp)); @@ -142,7 +144,8 @@ ServiceOperationMap initializeAppSvcOperations() // SMS ServiceOperation smsOp; smsOp.operation = SERVICE_OPERATION_COMPOSE; - smsOp.needUri = false; + smsOp.fakeUri = NULL; + smsOp.mime = "*/*"; smsOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_TO, REGEX_SMS)); smsOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_TEXT, REGEX_BODY)); ret.insert(std::make_pair(Scheme::SMS, smsOp)); @@ -150,7 +153,8 @@ ServiceOperationMap initializeAppSvcOperations() // SMSTO ServiceOperation smstoOp; smstoOp.operation = SERVICE_OPERATION_COMPOSE; - smstoOp.needUri = false; + smstoOp.fakeUri = "sms"; + smstoOp.mime = "*/*"; smstoOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_TO, REGEX_SMSTO)); smstoOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_TEXT, REGEX_BODY)); ret.insert(std::make_pair(Scheme::SMSTO, smstoOp)); @@ -159,7 +163,8 @@ ServiceOperationMap initializeAppSvcOperations() // MMSTO & MAILTO ServiceOperation sendOp; sendOp.operation = SERVICE_OPERATION_COMPOSE; - sendOp.needUri = true; + sendOp.fakeUri = NULL; + sendOp.mime = NULL; sendOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_TO, REGEX_MMSTO)); sendOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_TO, REGEX_MAILTO)); sendOp.conversions.push_back(AppSvcConversion(SERVICE_DATA_CC, REGEX_CC)); @@ -169,21 +174,123 @@ ServiceOperationMap initializeAppSvcOperations() AppSvcConversion(SERVICE_DATA_SUBJECT, REGEX_SUBJECT)); sendOp.conversions.push_back( AppSvcConversion(SERVICE_DATA_TEXT, REGEX_BODY)); - ret.insert(std::make_pair(Scheme::MMSTO, sendOp)); ret.insert(std::make_pair(Scheme::MAILTO, sendOp)); + sendOp.mime = "*/*"; + ret.insert(std::make_pair(Scheme::MMSTO, sendOp)); // TODO what about DATA? // TEL ServiceOperation telOp; telOp.operation = SERVICE_OPERATION_CALL; - telOp.needUri = true; + telOp.fakeUri = NULL; ret.insert(std::make_pair(Scheme::TEL, telOp)); return ret; } ServiceOperationMap g_serviceOperationMap = initializeAppSvcOperations(); + +void handleTizenServiceScheme(const char* uri) +{ + // Tizen Service + std::string parameter = std::string(uri); + std::string appId; + size_t start, end = 0; + + if (parameter.find("AppID=") != std::string::npos) { + start = parameter.find("AppID=") + strlen("AppID="); + end = parameter.find(";", start); + appId = parameter.substr(start, end-start); + } else { + LogError("parameter doesn't contain appID"); + return; + } + + service_h handle = NULL; + if (service_create(&handle) != SERVICE_ERROR_NONE) { + LogError("Fail to create service handle"); + return; + } + + if (service_set_app_id(handle, appId.c_str()) < 0) { + LogError("Fail to service_set_app_id"); + service_destroy(handle); + return; + } + + const char* KEY_KEY = "key="; + const char* KEY_VALUE = "value="; + + char* buf = strdup(parameter.c_str()); + const char* ptr = strtok(buf,";"); + while (ptr != NULL) { + std::string string = ptr; + ptr = strtok (NULL, ";"); + + size_t devide = string.find(','); + if (devide == std::string::npos) { + continue; + } + size_t keyPos = string.find(KEY_KEY); + if (keyPos == std::string::npos) { + continue; + } + size_t valuePos = string.find(KEY_VALUE); + if (valuePos == std::string::npos) { + continue; + } + + std::string key = + string.substr(keyPos + std::string(KEY_KEY).size(), + devide - (keyPos + std::string(KEY_KEY).size())); + std::string value = + string.substr(valuePos + std::string(KEY_VALUE).size()); + + if (service_add_extra_data(handle, key.c_str(), value.c_str())) { + LogError("service_add_extra_data is failed."); + service_destroy(handle); + free(buf); + return; + } + } + free(buf); + + CONTROLLER_POST_EVENT( + ApplicationLauncher, + ApplicationLauncherEvents::LaunchApplicationByAppService( + handle, + NULL, + NULL)); +} + +void handleUnknownScheme(const char* scheme, const char* uri) +{ + LogError("Invalid scheme: " << scheme); + // case of unknown scheme, send to app-control + // This is temporary soultion. "invalid" scheme should be handled by + // scheme map data + + if (!strcmp(scheme, "tizen-service")) { + handleTizenServiceScheme(uri); + return; + } else { + // create service + service_h serviceHandle = NULL; + if (SERVICE_ERROR_NONE != service_create(&serviceHandle)) { + service_set_operation(serviceHandle, SERVICE_OPERATION_VIEW); + service_set_uri(serviceHandle, uri); + CONTROLLER_POST_EVENT( + ApplicationLauncher, + ApplicationLauncherEvents::LaunchApplicationByAppService( + serviceHandle, + NULL, + NULL)); + } + } +} + + } // namespace namespace SchemeActionMap { @@ -209,22 +316,7 @@ bool HandleUri(const char* uri, Scheme::Type type = scheme.GetType(); if (type < Scheme::FILE || type >= Scheme::COUNT) { LogError("Invalid scheme: " << name); - // case of unknown scheme, send to app-control - // This is temporary soultion. "invalid" scheme should be handled by - // scheme map data - - // create service - service_h serviceHandle = NULL; - if (SERVICE_ERROR_NONE != service_create(&serviceHandle)) { - service_set_operation(serviceHandle, SERVICE_OPERATION_VIEW); - service_set_uri(serviceHandle, uri); - CONTROLLER_POST_EVENT( - ApplicationLauncher, - ApplicationLauncherEvents::LaunchApplicationByAppService( - serviceHandle, - NULL, - NULL)); - } + handleUnknownScheme(name.c_str(), uri); return false; } @@ -263,9 +355,21 @@ bool HandleUri(const char* uri, service_create(&serviceHandle); LogDebug("appsvc operation " << it->second.operation); service_set_operation(serviceHandle, it->second.operation); - if (it->second.needUri) { + if (it->second.fakeUri) { + size_t size = strlen(it->second.fakeUri) + strlen(uri) + 1; + char *newUri = new char[size]; + strcpy(newUri, it->second.fakeUri); + const char* uriArgs = strstr(uri, ":"); + strcpy(newUri + strlen(it->second.fakeUri), uriArgs); + service_set_uri(serviceHandle, newUri); + delete [] newUri; + } + else { service_set_uri(serviceHandle, uri); } + if (it->second.mime) { + service_set_mime(serviceHandle, it->second.mime); + } // this is safe as there are no other threads CURL* curl = curl_easy_init(); diff --git a/src/view/common/scheme_action_map_data.h b/src/view/common/scheme_action_map_data.h index 4571f4c..aabc65a 100644 --- a/src/view/common/scheme_action_map_data.h +++ b/src/view/common/scheme_action_map_data.h @@ -62,6 +62,7 @@ const UriAction g_tizenActionMap[Scheme::COUNT][SchemeActionMap::COUNT] = { // TOP_LEVEL FRAME_LEVEL NEW_WINDOW { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // FILE { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // SMS + { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // SMSTO { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MMSTO { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MAILTO { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // DATA @@ -80,6 +81,7 @@ const UriAction g_wacActionMap[Scheme::COUNT][SchemeActionMap::COUNT] = { // TOP_LEVEL FRAME_LEVEL NEW_WINDOW { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_APPSVC }, // FILE { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // SMS + { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // SMSTO { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MMSTO { URI_ACTION_APPSVC, URI_ACTION_APPSVC, URI_ACTION_APPSVC }, // MAILTO { URI_ACTION_WRT, URI_ACTION_WRT, URI_ACTION_WRT }, // DATA diff --git a/src/view/i_view_module.h b/src/view/i_view_module.h index 695140a..42b5128 100644 --- a/src/view/i_view_module.h +++ b/src/view/i_view_module.h @@ -54,6 +54,9 @@ class IViewModule const char* name, const char* body, char** returnData) = 0; + virtual void checkAsyncMessageFromBundle( + const char* name, + const char* body) = 0; virtual void downloadData(const char* url) = 0; virtual void activateVibration(bool on, uint64_t time) = 0; }; diff --git a/src/view/webkit/injected-bundle/CMakeLists.txt b/src/view/webkit/injected-bundle/CMakeLists.txt index 5e445a8..ce05e33 100644 --- a/src/view/webkit/injected-bundle/CMakeLists.txt +++ b/src/view/webkit/injected-bundle/CMakeLists.txt @@ -37,6 +37,7 @@ SET(INJECTED_BUNDLE_SOURCES ${PROJECT_SOURCE_DIR}/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp ${PROJECT_SOURCE_DIR}/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp ${PROJECT_SOURCE_DIR}/src/view/webkit/injected-bundle/injected_bundle_decryption_support.cpp + ${PROJECT_SOURCE_DIR}/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.cpp ${PROJECT_SOURCE_DIR}/src/view/webkit/injected-bundle/page_global_context_container.cpp ${PROJECT_SOURCE_DIR}/src/view/common/scheme.cpp ) diff --git a/src/view/webkit/injected-bundle/injected_bundle_decryption_support.cpp b/src/view/webkit/injected-bundle/injected_bundle_decryption_support.cpp index d0ef7fb..09680b2 100644 --- a/src/view/webkit/injected-bundle/injected_bundle_decryption_support.cpp +++ b/src/view/webkit/injected-bundle/injected_bundle_decryption_support.cpp @@ -59,6 +59,7 @@ class DecryptionSupportImplementation bool m_isEncrypted; std::set::iterator m_targetIt; bool m_isPreload; + WrtDB::TizenPkgId m_pkgId; std::string getFilePath(const std::string& url) @@ -108,7 +109,7 @@ class DecryptionSupportImplementation std::unique_ptr DecryptedString(new unsigned char[fileSize]); - std::string pkgid(DPL::ToUTF8String(m_appId)); + std::string pkgid(DPL::ToUTF8String(m_pkgId)); int writeCount = 0; do { @@ -177,6 +178,7 @@ class DecryptionSupportImplementation m_isEncrypted = true; LogDebug("encrypted application"); } + m_pkgId = dao.getTzPkgId(); std::string installedPath = DPL::ToUTF8String(*dao.getWidgetInstalledPath()); diff --git a/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp b/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp index 3fda48f..b2ea952 100644 --- a/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp +++ b/src/view/webkit/injected-bundle/injected_bundle_uri_handling.cpp @@ -84,7 +84,7 @@ bool wildcardCompare(std::string wildcardString, std::string target) pcrecpp::RE("\\|").GlobalReplace("\\\\|", &re); // replace wildcard character to regex type - pcrecpp::RE("\\\*").GlobalReplace(".*", &re); + pcrecpp::RE("\\*").GlobalReplace(".*", &re); return pcrecpp::RE(re).FullMatch(target); } diff --git a/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.cpp b/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.cpp new file mode 100644 index 0000000..0d94b13 --- /dev/null +++ b/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.cpp @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/* + * @file injected_bundle_viewmodes_support.cpp + * @author Jihoon Chung (jihoon.chung@samsung.com) + * @version 1.0 + */ + +#include "injected_bundle_viewmodes_support.h" + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace InjectedBundle { +namespace { +const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized"; +const std::string VIEWMODE_TYPE_FULLSCREEN = "fullscreen"; +const std::string VIEWMODE_TYPE_WINDOWED = "windowed"; + +typedef std::set SupportViewmodesSet; +SupportViewmodesSet g_supportViewmodes = {VIEWMODE_TYPE_MAXIMIZED, + VIEWMODE_TYPE_FULLSCREEN, + VIEWMODE_TYPE_WINDOWED}; +} + +//Implementation class +class ViewmodesSupportImplementation +{ + private: + typedef std::map ViewmodesMap; + typedef ViewmodesMap::iterator ViewmodesIt; + + bool m_initialized; + + WrtDB::TizenAppId m_appId; + WrtDB::WindowModeList m_modeList; + ViewmodesMap m_initialViewmodeMap; + ViewmodesMap m_currentViewmodeMap; + + bool isExisted(WKBundlePageRef page) + { + ViewmodesIt viewmodeIt = m_initialViewmodeMap.find(page); + if (viewmodeIt == m_initialViewmodeMap.end()) { + return false; + } + return true; + } + + std::string getChangedViewmode(void) + { + if (!m_currentViewmodeMap.empty()) { + ViewmodesIt curIt = m_currentViewmodeMap.begin(); + ViewmodesIt initIt = m_initialViewmodeMap.begin(); + if (curIt->second != initIt->second) { + return curIt->second; + } + } + return std::string(); + } + + bool isSupportViewmode(const std::string& mode) + { + if (g_supportViewmodes.find(mode) == g_supportViewmodes.end()) { + return false; + } + return true; + } + + public: + ViewmodesSupportImplementation(WrtDB::TizenAppId appId) : + m_initialized(false), + m_appId(appId) + { + WrtDB::WidgetDAOReadOnly dao(m_appId); + m_modeList = dao.getWindowModes(); + + m_initialized = true; + } + + void initialize(WKBundlePageRef page) + { + LogInfo("initialize"); + if (!m_initialized) { + Assert(false); + } + + if (isExisted(page)) { + LogError("This page is already initialized"); + return; + } + + // set initial viewmode from manifest + std::string initViewmode = VIEWMODE_TYPE_MAXIMIZED; + FOREACH(it, m_modeList) { + std::string mode = DPL::ToUTF8String(*it); + if (g_supportViewmodes.find(mode) != g_supportViewmodes.end()) { + initViewmode = mode; + } + } + m_initialViewmodeMap[page] = initViewmode; + + // In case of current viewmode of chrome is changed, + // set to changed viewmode + std::string currentViewmode = getChangedViewmode(); + if (currentViewmode.empty()) { + currentViewmode = initViewmode; + } + m_currentViewmodeMap[page] = currentViewmode; + + WKBundlePageSetViewMode(page, + WKStringCreateWithUTF8CString( + currentViewmode.c_str())); + } + + void deinitialize(WKBundlePageRef page) + { + LogInfo("deinitialize"); + if (!m_initialized) { + Assert(false); + } + m_initialViewmodeMap.erase(page); + m_currentViewmodeMap.erase(page); + } + + void setViewmodes(WKBundlePageRef page, const std::string& mode) + { + if (!m_initialized) { + Assert(false); + } + + m_currentViewmodeMap[page] = mode; + WKBundlePageSetViewMode(page, + WKStringCreateWithUTF8CString( + mode.c_str())); + } + + void enterViewmodesAllPages(const std::string& mode) + { + LogInfo("setViewmodesAllPages"); + if (!m_initialized) { + Assert(false); + } + if (!isSupportViewmode(mode)) { + LogError("Wrong viewmode : " << mode); + return; + } + + FOREACH(it, m_currentViewmodeMap) { + setViewmodes(it->first, mode); + } + } + + void exitViewmodes(WKBundlePageRef page) + { + if (!m_initialized) { + Assert(false); + } + + std::string mode = m_initialViewmodeMap[page]; + m_currentViewmodeMap[page] = mode; + WKBundlePageSetViewMode(page, + WKStringCreateWithUTF8CString( + mode.c_str())); + } + + void exitViewmodesAllPages(void) + { + LogInfo("exitViewmodesAllPages"); + if (!m_initialized) { + Assert(false); + } + + FOREACH(it, m_currentViewmodeMap) { + exitViewmodes(it->first); + } + } +}; + +ViewmodesSupport::ViewmodesSupport(WrtDB::TizenAppId appId) : + m_impl(new ViewmodesSupportImplementation(appId)) +{ +} + +ViewmodesSupport::~ViewmodesSupport() +{ +} + +void ViewmodesSupport::initialize(WKBundlePageRef page) +{ + m_impl->initialize(page); +} + +void ViewmodesSupport::deinitialize(WKBundlePageRef page) +{ + m_impl->deinitialize(page); +} + +void ViewmodesSupport::enterViewmodesAllPages(const std::string& mode) +{ + m_impl->enterViewmodesAllPages(mode); +} + +void ViewmodesSupport::exitViewmodesAllPages(void) +{ + m_impl->exitViewmodesAllPages(); +} +} // namespace InjectedBundle diff --git a/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.h b/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.h new file mode 100644 index 0000000..da1521b --- /dev/null +++ b/src/view/webkit/injected-bundle/injected_bundle_viewmodes_support.h @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file injected_bundle_viewmodes_support.h + * @author Jihoon Chung (jihoon.chung@samsung.com) + * @version 1.0 + */ +#ifndef INJECTED_BUNDLE_VIEWMODES_SUPPORT_H_ +#define INJECTED_BUNDLE_VIEWMODES_SUPPORT_H_ + +#include +#include + +#include + +namespace InjectedBundle { +class ViewmodesSupportImplementation; + +class ViewmodesSupport +{ + public: + ViewmodesSupport(WrtDB::TizenAppId appId); + virtual ~ViewmodesSupport(); + void initialize(WKBundlePageRef page); + void deinitialize(WKBundlePageRef page); + void enterViewmodesAllPages(const std::string& mode); + void exitViewmodesAllPages(void); + private: + std::unique_ptr m_impl; +}; +} // namespace InjectedBundle + +#endif // INJECTED_BUNDLE_VIEWMODES_SUPPORT_H_ \ No newline at end of file diff --git a/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp b/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp index 1928ccd..2726d5a 100644 --- a/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp +++ b/src/view/webkit/injected-bundle/wrt-injected-bundle.cpp @@ -72,6 +72,7 @@ // URI localization on WebProcess side #include "injected_bundle_uri_handling.h" #include "injected_bundle_decryption_support.h" +#include "injected_bundle_viewmodes_support.h" namespace { const char * const SCHEME_HTTP = "http"; @@ -82,8 +83,6 @@ const char * const SCHEME_BOX_SLASH = "box://"; const char * const BLANK_PAGE_URL = "about:blank"; const char * const HTML_MIME = "text/html"; const char * const PHP_MIME = "application/x-php"; -const char * const VIEWMODE_TYPE_FULLSCREEN = "fullscreen"; -const char * const VIEWMODE_TYPE_MAXIMIZED = "maximized"; const std::size_t FILE_BUF_MAX_SIZE = 1024; // bytes const std::size_t PLAIN_CHUNK_SIZE = 1008; // bytes const unsigned int UID_ROOT = 0; @@ -164,6 +163,7 @@ void Bundle::didCreatePage(WKBundlePageRef page) m_pagesList.push_back(page); m_pageGlobalContext.insertContextForPage(page, context); LogDebug("created Page : " << page << " created JSContext : " << context); + m_viewmodesSupport->initialize(page); WKBundlePageResourceLoadClient resourceLoadClient = { kWKBundlePageResourceLoadClientCurrentVersion, /* version */ @@ -235,6 +235,7 @@ void Bundle::willDestroyPage(WKBundlePageRef page) m_pagesList.remove(page); m_pageGlobalContext.removeContextForPage(page); m_pageContext[page].erase(context); + m_viewmodesSupport->deinitialize(page); PluginModule::unloadFrame(context); PluginModule::stop(context); @@ -485,6 +486,8 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) bypassCORSforWARPAccessList(dao); #endif m_decryptionSupport->initialize(m_widgetTizenId); + m_viewmodesSupport.reset( + new InjectedBundle::ViewmodesSupport(m_widgetTizenId)); m_initialized = true; } else { LogDebug("already initalized"); @@ -497,6 +500,18 @@ void Bundle::didReceiveMessage(WKStringRef messageName, WKTypeRef messageBody) toString(static_cast(messageBody)); LogDebug("set x window handle [" << msgString << "]"); IPCMessageSupport::setXwindowHandle(atoi(msgString.c_str())); + } else if (WKStringIsEqualToUTF8CString( + messageName, + Message::ToInjectedBundle::SET_VIEWMODES)) + { + std::string msgBody = + toString(static_cast(messageBody)); + LogDebug("set viewmode to [" << msgBody << "]"); + if (msgBody == Message::ToInjectedBundle::SET_VIEWMODES_MSGBODY_EXIT) { + m_viewmodesSupport->exitViewmodesAllPages(); + } else { + m_viewmodesSupport->enterViewmodesAllPages(msgBody); + } } } @@ -523,21 +538,6 @@ void Bundle::didStartProvisionalLoadForFrameCallback( LogDebug("didStartProvisionalLoadForFrameCallback called"); Bundle* This = static_cast(const_cast(clientInfo)); - // set viewmode - WrtDB::WidgetDAOReadOnly dao(This->m_widgetTizenId); - WrtDB::WindowModeList modeList = dao.getWindowModes(); - FOREACH(it, modeList) { - std::string viewMode = DPL::ToUTF8String(*it); - if (viewMode == VIEWMODE_TYPE_FULLSCREEN - || viewMode == VIEWMODE_TYPE_MAXIMIZED) - { - WKBundlePageSetViewMode( - page, - WKStringCreateWithUTF8CString(viewMode.c_str())); - break; - } - } - if (This->m_pageGlobalContext.find(page) == This->m_pageGlobalContext.end()) { return; } @@ -785,7 +785,7 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request) { if (logEnable){ LogDebug("external scheme return original WKURLRequestRef"); } WKRetain(request); - + return request; } else @@ -803,11 +803,11 @@ WKURLRequestRef Bundle::willSendRequestForFrame(WKURLRequestRef request) WKURLCreateWithUTF8CString(decryptString.c_str()); WKURLRequestRef req = WKURLRequestCreateWithWKURL(destUrl); WKRelease(destUrl); - + return req; } } - + WKURLRef newUrl = WKURLCreateWithUTF8CString(localizedUrl.c_str()); WKURLRequestRef req = WKURLRequestCreateWithWKURL(newUrl); WKRelease(newUrl); @@ -855,12 +855,10 @@ WKBundlePagePolicyAction Bundle::decidePolicyForAction( // Send information about blocked URI to UIProcess WKStringRef urlStr = WKStringCreateWithUTF8CString(blockedUrl.c_str()); - WKTypeRef retVal = NULL; WKStringRef blockMessage = WKStringCreateWithUTF8CString(Message::ToUIProcess::BLOCKED_URL); - WKBundlePostSynchronousMessage(m_bundle, blockMessage, urlStr, &retVal); + WKBundlePostMessage(m_bundle, blockMessage, urlStr); WKRelease(urlStr); - WKRelease(retVal); WKRelease(blockMessage); return WKBundlePagePolicyActionPassThrough; } @@ -972,13 +970,11 @@ void Bundle::sendWebProcessPid() std::stringstream strPid; strPid << getpid(); WKStringRef pidStr = WKStringCreateWithUTF8CString(strPid.str().c_str()); - WKTypeRef retVal = NULL; WKStringRef message = WKStringCreateWithUTF8CString( Message::ToUIProcess::SEND_WEBPROCESS_PID); - WKBundlePostSynchronousMessage(m_bundle, message, pidStr, &retVal); + WKBundlePostMessage(m_bundle, message, pidStr); WKRelease(pidStr); - WKRelease(retVal); WKRelease(message); } #endif diff --git a/src/view/webkit/injected-bundle/wrt-injected-bundle.h b/src/view/webkit/injected-bundle/wrt-injected-bundle.h index 223815c..41e4524 100644 --- a/src/view/webkit/injected-bundle/wrt-injected-bundle.h +++ b/src/view/webkit/injected-bundle/wrt-injected-bundle.h @@ -40,6 +40,7 @@ WK_EXPORT void WKBundleInitialize(WKBundleRef bundle, WKTypeRef); namespace InjectedBundle { class DecryptionSupport; +class ViewmodesSupport; } class Bundle @@ -86,6 +87,7 @@ class Bundle bool m_initialized; std::unique_ptr m_decryptionSupport; + std::unique_ptr m_viewmodesSupport; // WKBundlePageResourceLoadClient callback static WKURLRequestRef willSendRequestForFrameCallback( @@ -185,7 +187,6 @@ class Bundle #ifdef MULTIPROCESS_SERVICE_SUPPORT_INLINE void sendWebProcessPid(); #endif - #ifdef CORS_WHITELISTING_ENABLED void bypassCORSforWARPAccessList(WrtDB::WidgetDAOReadOnly &dao); #endif diff --git a/src/view/webkit/view_logic.cpp b/src/view/webkit/view_logic.cpp index 1215cd8..239025f 100644 --- a/src/view/webkit/view_logic.cpp +++ b/src/view/webkit/view_logic.cpp @@ -100,6 +100,7 @@ const char* const DEFAULT_CSP_POLICY = #endif // SCHEME const char * const SCHEME_BOX_SLASH = "box://"; +const double ORIENTATION_THRESHOLD = 0.5; } // anonymous namespace std::map(data); + + if (This->m_orientationThresholdTimer) { + LogDebug("previous orientationLock isn't finished"); + // Previous API call isn't finished. Keep angle and run it. + if (needLock == EINA_TRUE) { + // Screen.lockOrientation + This->m_deferredRotateAngle = orientation; + } else { + // Screen.unlockOrientation + This->m_deferredRotateAngle = + ViewModule::OrientationSupport::DEFERRED_ORIENTATION_UNLOCK; + } + return EINA_TRUE; + } + This->m_rotateAngle = orientation; if (needLock == EINA_TRUE) { // Screen.lockOrientation - ViewModule::OrientationSupport::setOrientation( - This->m_window, - obj, - orientation); + int w3cAngle = + ViewModule::OrientationSupport::getW3COrientationAngle(orientation); + int winAngle = + ViewModule::OrientationSupport::getWinOrientationAngle(orientation); + ViewModule::OrientationSupport::setEwkOrientation(obj, w3cAngle); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation(winAngle); + } } else { // Screen.unlockOrientation if (This->m_model->SettingList.Get().getRotationValue() == Screen_AutoRotation) { - elm_win_wm_rotation_preferred_rotation_set( - This->m_window, - OrientationAngle::Window::UNLOCK); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation(OrientationAngle::Window::UNLOCK); + } This->m_rotateAngle = 0; } } @@ -1416,6 +1457,9 @@ void ViewLogic::enterFullscreenCallback( LogInfo("enterFullscreenCallback called"); Assert(data); ViewLogic* This = static_cast(data); + ViewLogicMessageSupport::setViewmodes( + This->m_ewkContext, + "fullscreen"); if (!This->m_cbs->toggleFullscreen.empty()) { This->m_cbs->toggleFullscreen(true); } @@ -1428,6 +1472,9 @@ void ViewLogic::exitFullscreenCallback( LogInfo("exitFullscreenCallback called"); Assert(data); ViewLogic* This = static_cast(data); + ViewLogicMessageSupport::setViewmodes( + This->m_ewkContext, + Message::ToInjectedBundle::SET_VIEWMODES_MSGBODY_EXIT); if (!This->m_cbs->toggleFullscreen.empty()) { This->m_cbs->toggleFullscreen(false); } @@ -1464,10 +1511,6 @@ void ViewLogic::imeOpenedCallback( This->fireJavascriptEvent( static_cast(SoftKeyboardChangeCustomEvent), &args); - - if (!This->m_cbs->editorClientIme.empty()) { - This->m_cbs->editorClientIme(true); - } } void ViewLogic::imeClosedCallback( @@ -1485,9 +1528,6 @@ void ViewLogic::imeClosedCallback( This->fireJavascriptEvent( static_cast(SoftKeyboardChangeCustomEvent), &args); - if (!This->m_cbs->editorClientIme.empty()) { - This->m_cbs->editorClientIme(false); - } } void ViewLogic::usermediaPermissionRequestCallback( @@ -1925,7 +1965,6 @@ void ViewLogic::keyupCallback(void* data, Evas_Object* obj, void* eventInfo) { - LogInfo("keyupCallback"); Assert(data); ViewLogic* This = static_cast(data); @@ -1935,9 +1974,19 @@ void ViewLogic::keyupCallback(void* data, LogInfo("Key = [" << keyEvent->keyname << "]"); if (!strcmp(keyEvent->keyname, KEY_BACK)) { - DispatchEventSupport::dispatchHwKeyEvent(obj, "back"); + if (This->m_model->SettingList.Get().getHWkeyEvent() == + HWkeyEvent_Enable) + { + DispatchEventSupport::dispatchHwKeyEvent(obj, "back"); + } + This->m_cbs->hwkey("back"); } else if (!strcmp(keyEvent->keyname, KEY_MENU)) { - DispatchEventSupport::dispatchHwKeyEvent(obj, "menu"); + if (This->m_model->SettingList.Get().getHWkeyEvent() == + HWkeyEvent_Enable) + { + DispatchEventSupport::dispatchHwKeyEvent(obj, "menu"); + } + This->m_cbs->hwkey("menu"); } return; @@ -2071,7 +2120,7 @@ void ViewLogic::viewFrameRenderedCallback( Evas_Object* /*obj*/, void* /*eventInfo*/) { - LogInfo("enter"); + //LogInfo("enter"); } void ViewLogic::mediacontrolRotateHorizontal(void* data, @@ -2082,10 +2131,13 @@ void ViewLogic::mediacontrolRotateHorizontal(void* data, Assert(data); Assert(obj); ViewLogic* This = static_cast(data); - ViewModule::OrientationSupport::setOrientation( - This->m_window, + ViewModule::OrientationSupport::setEwkOrientation( obj, - ViewModule::OrientationSupport::Mode::LANDSCAPE_PRIMARY); + OrientationAngle::W3C::Landscape::PRIMARY); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation( + OrientationAngle::Window::Landscape::PRIMARY); + } } void ViewLogic::mediacontrolRotateVertical(void* data, @@ -2096,10 +2148,13 @@ void ViewLogic::mediacontrolRotateVertical(void* data, Assert(data); Assert(obj); ViewLogic* This = static_cast(data); - ViewModule::OrientationSupport::setOrientation( - This->m_window, + ViewModule::OrientationSupport::setEwkOrientation( obj, - ViewModule::OrientationSupport::Mode::PORTRAIT_PRIMARY); + OrientationAngle::W3C::Portrait::PRIMARY); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation( + OrientationAngle::Window::Portrait::PRIMARY); + } } void ViewLogic::mediacontrolRotateExit(void* data, @@ -2110,32 +2165,98 @@ void ViewLogic::mediacontrolRotateExit(void* data, Assert(data); Assert(obj); ViewLogic* This = static_cast(data); + + int w3cAngle = 0; + int winAngle = 0; if (This->m_rotateAngle == 0) { // application hasn't call orientation lock WidgetSettingScreenLock screenLock = This->m_model->SettingList.Get().getRotationValue(); if (screenLock == Screen_Portrait) { - ViewModule::OrientationSupport::setOrientation( - This->m_window, - obj, - ViewModule::OrientationSupport::Mode::PORTRAIT_PRIMARY); + w3cAngle = OrientationAngle::W3C::Portrait::PRIMARY; + winAngle = OrientationAngle::Window::Portrait::PRIMARY; } else if (screenLock == Screen_Landscape) { - ViewModule::OrientationSupport::setOrientation( - This->m_window, - obj, - ViewModule::OrientationSupport::Mode::LANDSCAPE_PRIMARY); + w3cAngle = OrientationAngle::W3C::Landscape::PRIMARY; + winAngle = OrientationAngle::Window::Landscape::PRIMARY; } else if (screenLock == Screen_AutoRotation) { - elm_win_wm_rotation_preferred_rotation_set( - This->m_window, - OrientationAngle::Window::UNLOCK); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation(OrientationAngle::Window::UNLOCK); + } + return; } } else { // Restore previous orientation - ViewModule::OrientationSupport::setOrientation( - This->m_window, - obj, - This->m_rotateAngle); + w3cAngle = + ViewModule::OrientationSupport::getW3COrientationAngle( + This->m_rotateAngle); + winAngle = + ViewModule::OrientationSupport::getWinOrientationAngle( + This->m_rotateAngle); + } + + ViewModule::OrientationSupport::setEwkOrientation(obj, w3cAngle); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation(winAngle); } + +} + +Eina_Bool ViewLogic::orientationThresholdTimerCallback(void* data) +{ + LogInfo("orientationThresholdTimerCallback"); + ViewLogic* This = static_cast(data); + + if (This->m_deferredRotateAngle == + ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY) + { + // There is no defered orientation API call + This->m_orientationThresholdTimer = NULL; + return ECORE_CALLBACK_CANCEL; + } + + if (This->m_deferredRotateAngle != This->m_rotateAngle) { + This->m_rotateAngle = This->m_deferredRotateAngle; + int w3cAngle = 0; + int winAngle = 0; + if (This->m_rotateAngle == 0) { + WidgetSettingScreenLock screenLock = + This->m_model->SettingList.Get().getRotationValue(); + if (screenLock == Screen_Portrait) { + w3cAngle = OrientationAngle::W3C::Portrait::PRIMARY; + winAngle = OrientationAngle::Window::Portrait::PRIMARY; + } else if (screenLock == Screen_Landscape) { + w3cAngle = OrientationAngle::W3C::Landscape::PRIMARY; + winAngle = OrientationAngle::Window::Landscape::PRIMARY; + } else if (screenLock == Screen_AutoRotation) { + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation(OrientationAngle::Window::UNLOCK); + } + This->m_orientationThresholdTimer = NULL; + return ECORE_CALLBACK_CANCEL; + } + } else { + // Restore previous orientation + w3cAngle = + ViewModule::OrientationSupport::getW3COrientationAngle( + This->m_rotateAngle); + winAngle = + ViewModule::OrientationSupport::getWinOrientationAngle( + This->m_rotateAngle); + } + + ViewModule::OrientationSupport::setEwkOrientation( + This->m_currentEwkView, + w3cAngle); + if (!This->m_cbs->setOrientation.empty()) { + This->m_cbs->setOrientation(winAngle); + } + This->m_deferredRotateAngle = + ViewModule::OrientationSupport::DEFERRED_ORIENTATION_EMPTY; + return ECORE_CALLBACK_RENEW; + } + + This->m_orientationThresholdTimer = NULL; + return ECORE_CALLBACK_CANCEL; } void ViewLogic::requestUrlBlocked(const std::string& blockedUrl) diff --git a/src/view/webkit/view_logic.h b/src/view/webkit/view_logic.h index 6da1ef4..bc9bd80 100644 --- a/src/view/webkit/view_logic.h +++ b/src/view/webkit/view_logic.h @@ -68,6 +68,9 @@ class ViewLogic : public ViewModule::IViewModule const char* name, const char* body, char** returnData); + void checkAsyncMessageFromBundle( + const char* name, + const char* body); void downloadData(const char* url); void activateVibration(bool on, uint64_t time); @@ -286,6 +289,9 @@ class ViewLogic : public ViewModule::IViewModule // idler callback static Eina_Bool windowCloseIdlerCallback(void *data); + // timer callback + static Eina_Bool orientationThresholdTimerCallback(void* data); + // security void requestUrlBlocked(const std::string& blockedUrl); @@ -312,6 +318,8 @@ class ViewLogic : public ViewModule::IViewModule bool m_isBackgroundReload; bool m_isBackgroundSupport; int m_rotateAngle; + int m_deferredRotateAngle; + Ecore_Timer* m_orientationThresholdTimer; std::unique_ptr m_schemeSupport; std::unique_ptr m_appsSupport; diff --git a/src/view/webkit/view_logic_geolocation_support.cpp b/src/view/webkit/view_logic_geolocation_support.cpp old mode 100755 new mode 100644 index 4b5a614..ea96943 --- a/src/view/webkit/view_logic_geolocation_support.cpp +++ b/src/view/webkit/view_logic_geolocation_support.cpp @@ -30,6 +30,7 @@ #include #include #include +#include namespace ViewModule { namespace GeolocationSupport { @@ -49,9 +50,19 @@ void askUserForGeolocationPermission( { LogDebug("askUserForGeolocationPermission called"); std::string body = WRT_BODY_PS_REQUESTS_YOUR_LOCATION; + std::string origin = DPL::ToUTF8String(data->m_originData.origin.host); + if (origin.empty()) { + char* name = NULL; + if (app_get_name(&name) == APP_ERROR_NONE) { + origin = name; + free(name); + } else { + origin = "application"; + } + } body.replace(body.find(WRT_PS), std::string(WRT_PS).size(), - DPL::ToUTF8String(data->m_originData.origin.host).c_str()); + origin.c_str()); Evas_Object* popup = createPopup(window, body.c_str(), WRT_BODY_REMEMBER_PREFERENCE, diff --git a/src/view/webkit/view_logic_message_support.cpp b/src/view/webkit/view_logic_message_support.cpp index 1f09283..df866f8 100644 --- a/src/view/webkit/view_logic_message_support.cpp +++ b/src/view/webkit/view_logic_message_support.cpp @@ -145,4 +145,10 @@ void setXwindowHandle(Ewk_Context* ewkContext, const unsigned int handle) ewk_context_message_post_to_injected_bundle(ewkContext, name, msg); } -} // namespace ViewLogicMessageSupport \ No newline at end of file + +void setViewmodes(Ewk_Context* ewkContext, const char* msg) +{ + const char* name = Message::ToInjectedBundle::SET_VIEWMODES; + ewk_context_message_post_to_injected_bundle(ewkContext, name, msg); +} +} // namespace ViewLogicMessageSupport diff --git a/src/view/webkit/view_logic_message_support.h b/src/view/webkit/view_logic_message_support.h index d5944da..ef979a7 100644 --- a/src/view/webkit/view_logic_message_support.h +++ b/src/view/webkit/view_logic_message_support.h @@ -45,6 +45,7 @@ void dispatchJavaScriptEvent( WrtPlugins::W3C::CustomEventType eventType, void* data); void setXwindowHandle(Ewk_Context* ewkContext, const unsigned int handle); +void setViewmodes(Ewk_Context* ewkContext, const char* msg); } // namespace ViewLogicMessageSupport #endif // VIEW_LOGIC_MESSAGE_SUPPORT_H_ \ No newline at end of file diff --git a/src/view/webkit/view_logic_orientation_support.cpp b/src/view/webkit/view_logic_orientation_support.cpp index d97d5a2..2a2169f 100644 --- a/src/view/webkit/view_logic_orientation_support.cpp +++ b/src/view/webkit/view_logic_orientation_support.cpp @@ -28,67 +28,46 @@ namespace ViewModule { -void OrientationSupport::setOrientation(Evas_Object* window, - Evas_Object* ewk, - Mode orientation) +int OrientationSupport::getWinOrientationAngle(int ewkOrientation) { - LogInfo("setOrientation called"); - if (orientation == Mode::PORTRAIT_PRIMARY) { - LogDebug("orientation is portrait-primary"); - elm_win_wm_rotation_preferred_rotation_set( - window, - OrientationAngle::Window::Portrait::PRIMARY); - ewk_view_orientation_send( - ewk, - OrientationAngle::W3C::Portrait::PRIMARY); - } else if (orientation == Mode::LANDSCAPE_PRIMARY) { - LogDebug("orientation is landscape-primary"); - elm_win_wm_rotation_preferred_rotation_set( - window, - OrientationAngle::Window::Landscape::PRIMARY); - ewk_view_orientation_send( - ewk, - OrientationAngle::W3C::Landscape::PRIMARY); - } else if (orientation == Mode::PORTRAIT_SECONDARY) { - LogDebug("orientation is portrait-secondary"); - elm_win_wm_rotation_preferred_rotation_set( - window, - OrientationAngle::Window::Portrait::SECONDARY); - ewk_view_orientation_send( - ewk, - OrientationAngle::W3C::Portrait::SECONDARY); - } else if (orientation == Mode::LANDSCAPE_SECONDARY) { - LogDebug("orientation is landscape-secondary"); - elm_win_wm_rotation_preferred_rotation_set( - window, - OrientationAngle::Window::Landscape::SECONDARY); - ewk_view_orientation_send( - ewk, - OrientationAngle::W3C::Landscape::SECONDARY); + int angle; + if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY) { + angle = OrientationAngle::Window::Portrait::PRIMARY; + } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) { + angle = OrientationAngle::Window::Landscape::PRIMARY; + } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) { + angle = OrientationAngle::Window::Portrait::SECONDARY; + } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) { + angle = OrientationAngle::Window::Landscape::SECONDARY; } else { LogDebug("Wrong orientation value is passed"); - return; + Assert(false); } + return angle; } -void OrientationSupport::setOrientation(Evas_Object* window, - Evas_Object* ewk, - int ewkOrientation) +int OrientationSupport::getW3COrientationAngle(int ewkOrientation) { - LogInfo("setOrientation called"); - Mode orientation; + int angle; if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_PRIMARY) { - orientation = Mode::PORTRAIT_PRIMARY; + angle = OrientationAngle::W3C::Portrait::PRIMARY; } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_PRIMARY) { - orientation = Mode::LANDSCAPE_PRIMARY; + angle = OrientationAngle::W3C::Landscape::PRIMARY; } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_PORTRAIT_SECONDARY) { - orientation = Mode::PORTRAIT_SECONDARY; + angle = OrientationAngle::W3C::Portrait::SECONDARY; } else if (ewkOrientation & EWK_SCREEN_ORIENTATION_LANDSCAPE_SECONDARY) { - orientation = Mode::LANDSCAPE_SECONDARY; + angle = OrientationAngle::W3C::Landscape::SECONDARY; } else { LogDebug("Wrong orientation value is passed"); - return; + Assert(false); } - setOrientation(window, ewk, orientation); + return angle; +} + +void OrientationSupport::setEwkOrientation(Evas_Object* ewk, + int angle) +{ + LogInfo("setOrientation called"); + ewk_view_orientation_send(ewk, angle); } -} // ViewModule \ No newline at end of file +} // ViewModule diff --git a/src/view/webkit/view_logic_orientation_support.h b/src/view/webkit/view_logic_orientation_support.h index 019729b..2512afc 100644 --- a/src/view/webkit/view_logic_orientation_support.h +++ b/src/view/webkit/view_logic_orientation_support.h @@ -26,18 +26,12 @@ namespace ViewModule { namespace OrientationSupport { -enum class Mode { -PORTRAIT_PRIMARY = 0, -LANDSCAPE_PRIMARY, -PORTRAIT_SECONDARY, -LANDSCAPE_SECONDARY -}; -void setOrientation(Evas_Object* window, - Evas_Object* ewk, - Mode orientation); -void setOrientation(Evas_Object* window, - Evas_Object* ewk, - int ewkOrientation); +const int DEFERRED_ORIENTATION_EMPTY = -1; +const int DEFERRED_ORIENTATION_UNLOCK = 0; + +int getWinOrientationAngle(int ewkOrientation); +int getW3COrientationAngle(int ewkOrientation); +void setEwkOrientation(Evas_Object* ewk, int angle); } // namespace OrientationSupport } // namespace ViewModule diff --git a/src/wrt-client/CMakeLists.txt b/src/wrt-client/CMakeLists.txt index 2e868a4..15f0fb9 100644 --- a/src/wrt-client/CMakeLists.txt +++ b/src/wrt-client/CMakeLists.txt @@ -17,16 +17,20 @@ SET(TARGET_WRT_CLIENT "wrt-client") SET(WRT_CLIENT_SRCS ${PROJECT_SOURCE_DIR}/src/wrt-client/window_data.cpp + ${PROJECT_SOURCE_DIR}/src/wrt-client/client_service_support.cpp ${PROJECT_SOURCE_DIR}/src/wrt-client/splash_screen_support.cpp ${PROJECT_SOURCE_DIR}/src/wrt-client/wrt-client.cpp + ${PROJECT_SOURCE_DIR}/src/wrt-client/auto_rotation_support.cpp ${PROJECT_SOURCE_DIR}/src/wrt-launchpad-daemon/src/process_pool.c ) PKG_CHECK_MODULES(CLIENT_DEP + appcore-efl + capi-appfw-application dpl-wrt-dao-ro wrt-plugin-js-overlay - appcore-efl wrt-popup-wrt-runner + appsvc REQUIRED ) diff --git a/src/wrt-client/auto_rotation_support.cpp b/src/wrt-client/auto_rotation_support.cpp new file mode 100644 index 0000000..2a6edd6 --- /dev/null +++ b/src/wrt-client/auto_rotation_support.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file auto_rotation_support.cpp + * @author Jihoon Chung (jihoon.chung@samsung.com) + * @version 1.0 + * @brief source file to support auto rotation of web application + */ + +#include "auto_rotation_support.h" + +#include +#include +#include +#include + +namespace { +const char* const WM_ROTATION_CHANGED_CALLBACK = "wm,rotation,changed"; +} + +void AutoRotationSupport::setOrientation(Evas_Object* window, Evas_Object* ewkView, SplashScreenSupport* splashScreen) +{ + LogInfo("setOrientation"); + int winAngle = elm_win_rotation_get(window); + + if (splashScreen && splashScreen->isShowing()) + { + splashScreen->resizeSplashScreen(); + } + + if (winAngle == OrientationAngle::Window::Portrait::PRIMARY) { + ewk_view_orientation_send( + ewkView, + OrientationAngle::W3C::Portrait::PRIMARY); + } else if (winAngle == OrientationAngle::Window::Portrait::SECONDARY) { + ewk_view_orientation_send( + ewkView, + OrientationAngle::W3C::Portrait::SECONDARY); + } else if (winAngle == OrientationAngle::Window::Landscape::PRIMARY) { + ewk_view_orientation_send( + ewkView, + OrientationAngle::W3C::Landscape::PRIMARY); + } else if (winAngle == OrientationAngle::Window::Landscape::SECONDARY) { + ewk_view_orientation_send( + ewkView, + OrientationAngle::W3C::Landscape::SECONDARY); + } else { + LogInfo("unknown angle is returned"); + } +} + +bool AutoRotationSupport::setAutoRotation(Evas_Object* window, Evas_Smart_Cb callback, const void *data) +{ + Assert(window); + + if (elm_win_wm_rotation_supported_get(window)) { + const int rots[4] = {OrientationAngle::Window::Portrait::PRIMARY, + OrientationAngle::Window::Portrait::SECONDARY, + OrientationAngle::Window::Landscape::PRIMARY, + OrientationAngle::Window::Landscape::SECONDARY}; + elm_win_wm_rotation_available_rotations_set(window, rots, 4); + evas_object_smart_callback_add(window, + WM_ROTATION_CHANGED_CALLBACK, + callback, + data); + return true; + } + return false; +} + +void AutoRotationSupport::unsetAutoRotation(Evas_Object* window, Evas_Smart_Cb callback) +{ + Assert(window); + evas_object_smart_callback_del(window, + WM_ROTATION_CHANGED_CALLBACK, + callback); +} + diff --git a/src/wrt-client/auto_rotation_support.h b/src/wrt-client/auto_rotation_support.h new file mode 100644 index 0000000..d8cc051 --- /dev/null +++ b/src/wrt-client/auto_rotation_support.h @@ -0,0 +1,34 @@ +/* + * Copyright 2013 Samsung Electronics Co., Ltd + * + * Licensed under the Flora License, Version 1.1 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://floralicense.org/license/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +/** + * @file auto_rotation_support.h + * @author Jihoon Chung (jihoon.chung@samsung.com) + * @version 1.0 + * @brief header file to support auto rotation of web application + */ +#ifndef AUTO_ROTATION_SUPPORT_H_ +#define AUTO_ROTATION_SUPPORT_H_ + +#include +#include + +namespace AutoRotationSupport { +bool setAutoRotation(Evas_Object* window, Evas_Smart_Cb callback, const void *data); +void unsetAutoRotation(Evas_Object* window, Evas_Smart_Cb callback); +void setOrientation(Evas_Object* window, Evas_Object* ewkView, SplashScreenSupport* splashScreen); +} // namespace AUTO_ROTATION_SUPPORT + +#endif // AUTO_ROTATION_SUPPORT_H_ diff --git a/src/wrt-client/client_service_support.cpp b/src/wrt-client/client_service_support.cpp new file mode 100644 index 0000000..d82b0c2 --- /dev/null +++ b/src/wrt-client/client_service_support.cpp @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "client_service_support.h" +#include +#include +#include +#include + +namespace ClientModule { +namespace { +class Exception +{ + public: + DECLARE_EXCEPTION_TYPE(DPL::Exception, Base) + DECLARE_EXCEPTION_TYPE(Base, ServiceHandleCreateError) + DECLARE_EXCEPTION_TYPE(Base, ServiceHandleSetError) +}; +bool isError(int error); + +bool isError(int error) { + if (SERVICE_ERROR_NONE == error) { + return false; + } else { + LogError("Service error [" << error << "]"); + return true; + } +} +} + +bool ServiceSupport::launchViewService(unsigned int windowHandle, + const std::string& url) +{ + if (url.empty() || url.size() == 0) { + LogError("Input url is invalid"); + return false; + } + + service_h serviceHandle = NULL; + Try { + int error = SERVICE_ERROR_NONE; + error = service_create(&serviceHandle); + if (isError(error)) { + Throw(Exception::ServiceHandleCreateError); + } + + error = service_set_operation(serviceHandle, SERVICE_OPERATION_VIEW); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_set_operation error"); + } + + error = service_set_uri(serviceHandle, url.c_str()); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_set_uri error"); + } + + if (windowHandle != 0) { + error = service_set_window(serviceHandle, windowHandle); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_set_window error"); + } + } + + error = service_send_launch_request(serviceHandle, NULL, NULL); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_send_launch_request error"); + } + service_destroy(serviceHandle); + } Catch(Exception::ServiceHandleCreateError) { + LogError("Fail to create service handle"); + return false; + } Catch(Exception::ServiceHandleSetError) { + LogError(_rethrown_exception.GetMessage()); + service_destroy(serviceHandle); + return false; + } Catch(DPL::Exception) { + LogError(_rethrown_exception.GetMessage()); + return false; + } + + return true; +} + +bool ServiceSupport::launchShareService(unsigned int windowHandle, + const std::string& url) +{ + if (url.empty() || url.size() == 0) { + LogError("Input url is invalid"); + return false; + } + + service_h serviceHandle = NULL; + Try { + int error = SERVICE_ERROR_NONE; + error = service_create(&serviceHandle); + if (isError(error)) { + Throw(Exception::ServiceHandleCreateError); + } + + error = service_set_operation(serviceHandle, + SERVICE_OPERATION_SHARE_TEXT); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_set_operation error"); + } + + if (windowHandle != 0) { + error = service_set_window(serviceHandle, windowHandle); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_set_window error"); + } + } + + error = service_add_extra_data(serviceHandle, + SERVICE_DATA_TEXT, + url.c_str()); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_add_extra_data error"); + } + + error = service_send_launch_request(serviceHandle, NULL, NULL); + if (isError(error)) { + ThrowMsg(Exception::ServiceHandleSetError, + "service_send_launch_request error"); + } + service_destroy(serviceHandle); + } Catch(Exception::ServiceHandleCreateError) { + LogError("Fail to create service handle"); + return false; + } Catch(Exception::ServiceHandleSetError) { + LogError(_rethrown_exception.GetMessage()); + service_destroy(serviceHandle); + return false; + } Catch(DPL::Exception) { + LogError(_rethrown_exception.GetMessage()); + return false; + } + return true; +} + +} // ClientModule diff --git a/src/wrt-client/client_service_support.h b/src/wrt-client/client_service_support.h new file mode 100644 index 0000000..2255c18 --- /dev/null +++ b/src/wrt-client/client_service_support.h @@ -0,0 +1,27 @@ +/* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef CLIENT_SERVICE_SUPPORT_H_ +#define CLIENT_SERVICE_SUPPORT_H_ + +#include + +namespace ClientModule { +namespace ServiceSupport { +bool launchViewService(unsigned int windowHandle, const std::string& url); +bool launchShareService(unsigned int windowHandle, const std::string& url); +} // ServiceSupport +} // ClientModule +#endif // CLIENT_SERVICE_SUPPORT_H_ diff --git a/src/wrt-client/splash_screen_support.cpp b/src/wrt-client/splash_screen_support.cpp index d770c69..2b0cfcb 100644 --- a/src/wrt-client/splash_screen_support.cpp +++ b/src/wrt-client/splash_screen_support.cpp @@ -37,12 +37,12 @@ SplashScreenSupport::SplashScreenSupport(Evas_Object* parent, const char* image_ m_parent(parent), m_splashScreen(NULL), m_splashScreenBg(NULL), - m_initialized(false), - m_isShowing(false), m_timer(NULL), - m_indicator(indicator), m_deviceWidth(0), - m_deviceHeight(0) + m_deviceHeight(0), + m_initialized(false), + m_isShowing(false), + m_indicator(indicator) { LogDebug("enter"); diff --git a/src/wrt-client/window_data.cpp b/src/wrt-client/window_data.cpp index 6cdaf98..acac622 100644 --- a/src/wrt-client/window_data.cpp +++ b/src/wrt-client/window_data.cpp @@ -23,6 +23,7 @@ #include #include +#include namespace { char const* const PLATFORM_EDJ_PATH = "/usr/share/edje/wrt/Platform.edj"; @@ -45,12 +46,18 @@ char const* const NOINDICATOR = "noindicator"; char const* const INTERNAL_LAYOUT = "internal_layout"; char const* const FLOATBACKWARD_BUTTON_STYLE = "wrt/backward"; const std::string DESKTOP_PROFILE("desktop"); -const int PROGRESS_H = 7; +const int PROGRESS_H = 10; } // anonymous namespace WindowData::WindowData(unsigned long pid, bool manualInit) : m_win(NULL), - m_naviframeBackButton(NULL), + m_user_layout(NULL), + m_conformant(NULL), + m_platform_layout(NULL), + m_navigation(NULL), + m_floatBackButton(NULL), + m_progressbar(NULL), + m_ctxpopup(NULL), m_initialized(false) { m_win = createWindow(pid); @@ -85,7 +92,6 @@ void WindowData::init() evas_object_show(m_platform_layout); m_navigation = createNavigationBar(m_platform_layout); evas_object_show(m_navigation); - m_naviframeBackButton = createNaviframeBackbutton(m_navigation); m_user_layout = createUserLayout(m_navigation); evas_object_show(m_user_layout); m_progressbar = createProgressBar(m_win, m_user_layout); @@ -116,22 +122,6 @@ void WindowData::toggleIndicator(bool fullscreen) } } -void WindowData::toggleToolbar(bool enable) -{ - LogDebug("toolbar = " << (enable ? "enable" : "disable")); - Elm_Object_Item* naviIt = elm_naviframe_top_item_get(m_navigation); - if (enable) { - elm_object_item_signal_emit(naviIt, ELM_STATE_TOOLBAR_INSTANT_OPEN, ""); - } else { - elm_object_item_signal_emit(naviIt, ELM_STATE_TOOLBAR_INSTANT_CLOSE, ""); - } -} - -bool WindowData::isFullscreen() -{ - return m_fullscreen; -} - void WindowData::setViewMode( bool fullscreen, bool backbutton) @@ -140,14 +130,16 @@ void WindowData::setViewMode( LogDebug("fullscreen: " << fullscreen); LogDebug("backbutton: " << backbutton); - m_fullscreen = fullscreen; - - toggleIndicator(m_fullscreen); + toggleIndicator(fullscreen); +} - if (backbutton) { - // This code will be deprecated by naviframe back button - // createFloatBackButton(); - } +void WindowData::setOrientation(int angle) +{ + LogDebug("setOrientation"); + Assert(m_win); + elm_win_wm_rotation_preferred_rotation_set( + m_win, + angle); } void WindowData::createFloatBackButton() @@ -231,14 +223,6 @@ Evas_Object* WindowData::createNavigationBar(Evas_Object* parent) return navigation; } -Evas_Object* WindowData::createNaviframeBackbutton(Evas_Object* parent) -{ - Assert(parent != NULL && "Parent for naviframe backbutton is null"); - Evas_Object* object = elm_button_add(parent); - elm_object_style_set(object, "naviframe/end_btn/default"); - return object; -} - Evas_Object* WindowData::createUserLayout(Evas_Object* parent) { Assert(parent != NULL && "Parent for User Layout is null"); @@ -255,7 +239,7 @@ Evas_Object* WindowData::createUserLayout(Evas_Object* parent) /* const char *title_label */ NULL, /* Evas_Object *prev_btn */ - m_naviframeBackButton, + NULL, /* Evas_Object *next_btn */ NULL, /* Evas_Object *content */ @@ -278,6 +262,42 @@ Evas_Object* WindowData::createProgressBar(Evas_Object* window, Evas_Object* par return progressbar; } +Evas_Object* WindowData::createCtxPopup(Evas_Object* parent) +{ + Assert(parent != NULL && "Parent is null"); + if (m_ctxpopupItemDataList.empty()) { + LogError("menu data is empty"); + return NULL; + } + + Evas_Object* object = elm_ctxpopup_add(parent); + FOREACH(it, m_ctxpopupItemDataList) { + Evas_Object* icon = NULL; + if (!it->iconPath.empty()) { + // create icon + } + elm_ctxpopup_item_append(object, + it->text.c_str(), + icon, + ctxpopupItemCallback, + this); + } + + Elm_Object_Item* naviIt = elm_naviframe_top_item_get(parent); + Evas_Object* moreButton = + elm_object_item_part_content_get(naviIt, "toolbar_more_btn"); + if (moreButton) { + Evas_Coord x, y, w, h; + evas_object_geometry_get(moreButton, &x, &y, &w, &h); + evas_object_move(object, x+w/2, y+h/2); + } + evas_object_smart_callback_add(object, + "dismissed", + ctxpopupDismissedCallback, + this); + return object; +} + void WindowData::setDesktopIcon() { // set window icon @@ -288,15 +308,6 @@ void WindowData::setDesktopIcon() elm_win_icon_object_set(m_win, icon); } -void WindowData::addNaviframeItemPopCallback( - NaviframePopCallbackType callback, - void* data) -{ - Assert(m_navigation != NULL && "m_navigation is null"); - Elm_Object_Item* naviIt = elm_naviframe_top_item_get(m_navigation); - elm_naviframe_item_pop_cb_set(naviIt, callback, data); -} - void WindowData::addFloatBackButtonCallback( const char* event, CallbackType callback, @@ -346,15 +357,7 @@ void WindowData::emitSignalForUserLayout( void WindowData::toggleFullscreen(bool fullscreen) { LogDebug(__PRETTY_FUNCTION__); - - if (m_fullscreen == fullscreen) { - // window is in fullscreen mode and fullscreen mode is requested, or - // window is not in fullscreen and a request is made to exit fullscreen - // In these two situations we don't have to do anything here. - return; - } toggleIndicator(fullscreen); - m_fullscreen = fullscreen; } void WindowData::winProfileChangedCallback(void *data, @@ -374,6 +377,20 @@ void WindowData::winProfileChangedCallback(void *data, } } +void WindowData::showCtxpopup(void) +{ + m_ctxpopup = createCtxPopup(m_navigation); + if (!m_ctxpopup) { + return; + } + evas_object_show(m_ctxpopup); +} + +void WindowData::setCtxpopupItemData(CtxpopupItemDataList data) +{ + m_ctxpopupItemDataList = data; +} + void WindowData::updateProgress(double value) { int x, y, w, h; @@ -382,3 +399,39 @@ void WindowData::updateProgress(double value) static_cast(w * value), static_cast(PROGRESS_H * elm_config_scale_get())); } + +void WindowData::ctxpopupItemCallback(void* data, + Evas_Object* obj, + void* eventInfo) +{ + LogDebug("ctxpopupItemCallback"); + Assert(data); + WindowData* This = static_cast(data); + + Assert(eventInfo); + Elm_Object_Item* it = static_cast(eventInfo); + const char* text = elm_object_item_text_get(it); + LogDebug("text " << text); + + FOREACH(it, This->m_ctxpopupItemDataList) { + if (it->text == text) { + it->function(); + break; + } + } + Assert(obj); + elm_ctxpopup_dismiss(obj); +} + +void WindowData::ctxpopupDismissedCallback(void* data, + Evas_Object* obj, + void* /*eventInfo*/) +{ + LogDebug("ctxpopupDismissedCallback"); + Assert(obj); + evas_object_del(obj); + + Assert(data); + WindowData* This = static_cast(data); + This->m_ctxpopup = NULL; +} diff --git a/src/wrt-client/window_data.h b/src/wrt-client/window_data.h index 0c1008b..a45c8a3 100644 --- a/src/wrt-client/window_data.h +++ b/src/wrt-client/window_data.h @@ -24,9 +24,10 @@ #define WINDOW_INITIALIZE_H_ #include +#include -#include #include +#include #include /* @@ -50,19 +51,22 @@ class WindowData : private DPL::Noncopyable typedef Eina_Bool (*NaviframePopCallbackType)( void* data, Elm_Object_Item* it); - struct EventWithFunction - { - CallbackType function; - std::string eventName; - EventWithFunction(CallbackType a_function, - const char * a_eventName) : - function(a_function), - eventName(a_eventName) + public: + typedef DPL::FastDelegate0 CtxpopupCallbackType; + struct CtxpopupItemData { + std::string text; + std::string iconPath; + CtxpopupCallbackType function; + CtxpopupItemData(std::string t, + std::string p, + CtxpopupCallbackType f) : + text(t), + iconPath(p), + function(f) {} }; - typedef std::vector EventWithFunctionVector; + typedef std::list CtxpopupItemDataList; - public: Evas_Object* m_win; Evas_Object* m_user_layout; @@ -72,9 +76,6 @@ class WindowData : private DPL::Noncopyable void init(); void setEvasObjectForLayout(Evas_Object* evas_object); void unsetEvasObjectForLayout(); - void addNaviframeItemPopCallback( - NaviframePopCallbackType callback, - void* data); void addFloatBackButtonCallback( const char* event, CallbackType callback, @@ -92,41 +93,46 @@ class WindowData : private DPL::Noncopyable void emitSignalForUserLayout( const char* emission, const char* source); - void setViewMode( bool fullscreen, bool backbutton); - + void setOrientation(int angle); void toggleFullscreen(bool fullscreen); - void toggleToolbar(bool enable); - bool isFullscreen(); static void winProfileChangedCallback(void *data, Evas_Object * obj, void *event_info); + void showCtxpopup(void); + void setCtxpopupItemData(CtxpopupItemDataList data); void updateProgress(double value); protected: Evas_Object* m_conformant; Evas_Object* m_platform_layout; Evas_Object* m_navigation; - Evas_Object* m_naviframeBackButton; Evas_Object* m_floatBackButton; Evas_Object* m_progressbar; - bool m_fullscreen; + Evas_Object* m_ctxpopup; bool m_initialized; + CtxpopupItemDataList m_ctxpopupItemDataList; Evas_Object* createWindow(unsigned long pid); Evas_Object* createConformant(Evas_Object* parent); Evas_Object* createPlatformLayout(Evas_Object* parent); Evas_Object* createNavigationBar(Evas_Object* parent); - Evas_Object* createNaviframeBackbutton(Evas_Object* parent); Evas_Object* createUserLayout(Evas_Object* parent); Evas_Object* createProgressBar(Evas_Object* window, Evas_Object* parent); + Evas_Object* createCtxPopup(Evas_Object* parent); void alignProgressPosition(); void toggleIndicator(bool fullscreen); void createFloatBackButton(); void setDesktopIcon(); -}; + static void ctxpopupItemCallback(void* data, + Evas_Object* obj, + void* eventInfo); + static void ctxpopupDismissedCallback(void* data, + Evas_Object* obj, + void* eventInfo); + }; #endif /* WINDOW_INITIALIZE_H_ */ diff --git a/src/wrt-client/wrt-client.cpp b/src/wrt-client/wrt-client.cpp index 36f415a..7429412 100644 --- a/src/wrt-client/wrt-client.cpp +++ b/src/wrt-client/wrt-client.cpp @@ -35,10 +35,15 @@ #include #include #include +#include "auto_rotation_support.h" #include "process_pool.h" #include "menu_db_util.h" #include "launchpad_util.h" +#include + +#include "client_service_support.h" + //W3C PACKAGING enviroment variable name #define W3C_DEBUG_ENV_VARIABLE "DEBUG_LOAD_FINISH" @@ -49,6 +54,7 @@ const char *EDJE_SHOW_PROGRESS_SIGNAL = "show,progress,signal"; const char *EDJE_HIDE_PROGRESS_SIGNAL = "hide,progress,signal"; const std::string VIEWMODE_TYPE_FULLSCREEN = "fullscreen"; const std::string VIEWMODE_TYPE_MAXIMIZED = "maximized"; +const std::string VIEWMODE_TYPE_WINDOWED = "windowed"; char const* const ELM_SWALLOW_CONTENT = "elm.swallow.content"; const char* const BUNDLE_PATH = "/usr/lib/libwrt-injected-bundle.so"; const char* const caCertPath = "/opt/usr/share/certs/ca-certificate.crt"; @@ -78,7 +84,8 @@ WrtClient::WrtClient(int argc, char **argv) : m_debuggerPort(0), m_returnStatus(ReturnStatus::Succeeded), m_widgetState(WidgetState::WidgetState_Stopped), - m_fullscreen(false) + m_initialViewMode(VIEWMODE_TYPE_MAXIMIZED), + m_currentViewMode(VIEWMODE_TYPE_MAXIMIZED) { Touch(); LogDebug("App Created"); @@ -386,7 +393,15 @@ void WrtClient::loadFinishCallback(Evas_Object* webview) } else { sv.sival_int = -1; } - sigqueue(m_sdkLauncherPid, SIGRTMIN, sv); + + bundle* request = NULL; + appsvc_create_result_bundle( + ApplicationDataSingleton::Instance().getBundle(), + &request); + char port[10] = {0,}; + sprintf(port, "%d", debug->portnum); + appsvc_add_data(request, "port", port); + appsvc_send_result(request, APPSVC_RES_OK); } ApplicationDataSingleton::Instance().freeBundle(); @@ -398,7 +413,9 @@ void WrtClient::loadFinishCallback(Evas_Object* webview) void WrtClient::progressStartedCallback() { - if (m_settingList->getProgressBarPresence() == ProgressBar_Enable) { + if (m_settingList->getProgressBarPresence() == ProgressBar_Enable || + m_currentViewMode == VIEWMODE_TYPE_WINDOWED) + { m_windowData->emitSignalForUserLayout(EDJE_SHOW_PROGRESS_SIGNAL, ""); m_windowData->updateProgress(0); } @@ -406,12 +423,18 @@ void WrtClient::progressStartedCallback() void WrtClient::loadProgressCallback(Evas_Object* /*webview*/, double value) { - m_windowData->updateProgress(value); + if (m_settingList->getProgressBarPresence() == ProgressBar_Enable || + m_currentViewMode == VIEWMODE_TYPE_WINDOWED) + { + m_windowData->updateProgress(value); + } } void WrtClient::progressFinishCallback() { - if (m_settingList->getProgressBarPresence() == ProgressBar_Enable) { + if (m_settingList->getProgressBarPresence() == ProgressBar_Enable || + m_currentViewMode == VIEWMODE_TYPE_WINDOWED) + { m_windowData->emitSignalForUserLayout(EDJE_HIDE_PROGRESS_SIGNAL, ""); } } @@ -437,25 +460,13 @@ void WrtClient::toggleFullscreenCallback(bool fullscreen) LogError("toggleFullscreen"); if (fullscreen) { + // enter fullscreen m_windowData->toggleFullscreen(true); - if (m_settingList->getBackButtonPresence() == BackButton_Enable) { - m_windowData->toggleToolbar(false); - } + m_currentViewMode = VIEWMODE_TYPE_FULLSCREEN; } else { + // exit fullscreen m_windowData->toggleFullscreen(false); - if (m_settingList->getBackButtonPresence() == BackButton_Enable) { - m_windowData->toggleToolbar(true); - } - } -} - -void WrtClient::imeChangedCallback(bool open) -{ - LogError("imeChangedCallback"); - if (m_settingList->getBackButtonPresence() == BackButton_Enable && - m_windowData->isFullscreen()) - { - m_windowData->toggleToolbar(open); + m_currentViewMode = m_initialViewMode; } } @@ -501,6 +512,7 @@ void WrtClient::launchStep() *defloc); } + setInitialViewMode(); PrepareExternalStorageSingleton::Instance().Initialize(m_dao->getTizenPkgId()); /* remove language change callback */ @@ -519,7 +531,8 @@ void WrtClient::launchStep() ADD_PROFILING_POINT("CreateWindow", "stop"); // rotate window to initial value - setOrientationWindow(); + setWindowInitialOrientation(); + setCtxpopupItem(); WRT::UserDelegatesPtr cbs(new WRT::UserDelegates); @@ -529,8 +542,8 @@ void WrtClient::launchStep() { m_splashScreen.reset(new SplashScreenSupport(m_windowData->m_win, (DPL::ToUTF8String(*splashImgSrc)).c_str(), - !isFullscreen(), - (m_settingList->getRotationValue() == Screen_Landscape))); + m_currentViewMode != VIEWMODE_TYPE_FULLSCREEN, + m_settingList->getRotationValue() == Screen_Landscape)); m_splashScreen->startSplashScreen(); } ADD_PROFILING_POINT("Create splash screen", "stop"); @@ -544,13 +557,11 @@ void WrtClient::launchStep() return; } // send rotate information to ewk - setOrientationEwk(); + setEwkInitialOrientation(); //you can't show window with splash screen before PrepareView //ewk_view_add_with_context() in viewLogic breaks window m_windowData->init(); - m_windowData->toggleToolbar( - m_settingList->getBackButtonPresence() == BackButton_Enable); WrtDB::WidgetLocalizedInfo localizedInfo = W3CFileLocalization::getLocalizedInfo(m_dao); @@ -564,7 +575,6 @@ void WrtClient::launchStep() evas_object_show(m_windowData->m_win); initializeWindowModes(); - connectElmCallback(); m_widgetState = WidgetState_Authorizing; if (!m_widget->CheckBeforeLaunch()) { @@ -585,7 +595,8 @@ void WrtClient::launchStep() cbs->webkitExit = DPL::MakeDelegate(this, &WrtClient::webkitExitCallback); cbs->webCrash = DPL::MakeDelegate(this, &WrtClient::webCrashCallback); cbs->toggleFullscreen = DPL::MakeDelegate(this, &WrtClient::toggleFullscreenCallback); - cbs->editorClientIme = DPL::MakeDelegate(this, &WrtClient::imeChangedCallback); + cbs->setOrientation = DPL::MakeDelegate(this, &WrtClient::setWindowOrientation); + cbs->hwkey = DPL::MakeDelegate(this, &WrtClient::hwkeyCallback); m_widget->SetUserDelegates(cbs); m_widget->Show(); @@ -594,43 +605,13 @@ void WrtClient::launchStep() ADD_PROFILING_POINT("launchStep", "stop"); } -bool WrtClient::isFullscreen() -{ - static bool first = true; - - if (first) - { - Assert(m_dao); - - first = false; - WrtDB::WindowModeList windowModes = m_dao->getWindowModes(); - - FOREACH(it, windowModes) - { - std::string viewMode = DPL::ToUTF8String(*it); - if (viewMode == VIEWMODE_TYPE_FULLSCREEN) - { - m_fullscreen = true; - break; - } - else if (viewMode == VIEWMODE_TYPE_MAXIMIZED) - { - break; - } - } - } - - return m_fullscreen; -} - void WrtClient::initializeWindowModes() { Assert(m_windowData); - - bool fullscreen = isFullscreen(); - bool backbutton = (m_settingList->getBackButtonPresence() == BackButton_Enable); - - m_windowData->setViewMode(fullscreen, + bool backbutton = + (m_settingList->getBackButtonPresence() == BackButton_Enable || + m_currentViewMode == VIEWMODE_TYPE_WINDOWED); + m_windowData->setViewMode(m_currentViewMode == VIEWMODE_TYPE_FULLSCREEN, backbutton); } @@ -646,7 +627,7 @@ void WrtClient::backButtonCallback(void* data, } Eina_Bool WrtClient::naviframeBackButtonCallback(void* data, - Elm_Object_Item* it) + Elm_Object_Item* /*it*/) { LogInfo("BackButtonCallback"); Assert(data); @@ -667,42 +648,80 @@ int WrtClient::appcoreLowMemoryCallback(void* /*data*/) return 0; } -void WrtClient::setOrientationWindow(void) +void WrtClient::setInitialViewMode(void) +{ + Assert(m_dao); + WrtDB::WindowModeList windowModes = m_dao->getWindowModes(); + FOREACH(it, windowModes) { + std::string viewMode = DPL::ToUTF8String(*it); + switch(viewMode[0]) { + case 'f': + if (viewMode == VIEWMODE_TYPE_FULLSCREEN) { + m_initialViewMode = viewMode; + m_currentViewMode = m_initialViewMode; + break; + } + break; + case 'm': + if (viewMode == VIEWMODE_TYPE_MAXIMIZED) { + m_initialViewMode = viewMode; + m_currentViewMode = m_initialViewMode; + break; + } + break; + case 'w': + if (viewMode == VIEWMODE_TYPE_WINDOWED) { + m_initialViewMode = viewMode; + m_currentViewMode = m_initialViewMode; + break; + } + break; + default: + break; + } + } +} + +void WrtClient::setWindowInitialOrientation(void) { Assert(m_windowData); Assert(m_dao); WidgetSettingScreenLock rotationValue = m_settingList->getRotationValue(); if (rotationValue == Screen_Portrait) { - elm_win_wm_rotation_preferred_rotation_set( - m_windowData->m_win, - OrientationAngle::Window::Portrait::PRIMARY); + setWindowOrientation(OrientationAngle::Window::Portrait::PRIMARY); } else if (rotationValue == Screen_Landscape) { - elm_win_wm_rotation_preferred_rotation_set( - m_windowData->m_win, - OrientationAngle::Window::Landscape::PRIMARY); + setWindowOrientation(OrientationAngle::Window::Landscape::PRIMARY); } else if (rotationValue == Screen_AutoRotation) { - LogInfo("Nothing to do"); + if (!AutoRotationSupport::setAutoRotation(m_windowData->m_win, + autoRotationCallback, + this)) + { + LogError("Fail to set auto rotation"); + } } else { - elm_win_wm_rotation_preferred_rotation_set( - m_windowData->m_win, - OrientationAngle::W3C::Portrait::PRIMARY); + setWindowOrientation(OrientationAngle::Window::Portrait::PRIMARY); } } -void WrtClient::unsetOrientationWindow(void) +void WrtClient::setWindowOrientation(int angle) +{ + Assert(m_windowData); + m_windowData->setOrientation(angle); +} + +void WrtClient::unsetWindowOrientation(void) { Assert(m_windowData); Assert(m_dao); WidgetSettingScreenLock rotationValue = m_settingList->getRotationValue(); if (rotationValue == Screen_AutoRotation) { - LogInfo("Nothing to do"); + AutoRotationSupport::unsetAutoRotation(m_windowData->m_win, autoRotationCallback); } } - -void WrtClient::setOrientationEwk(void) +void WrtClient::setEwkInitialOrientation(void) { Assert(m_widget); Assert(m_dao); @@ -727,15 +746,89 @@ void WrtClient::setOrientationEwk(void) } } -void WrtClient::connectElmCallback() +void WrtClient::setCtxpopupItem(void) { - Assert(m_windowData); - Assert(m_dao); + WindowData::CtxpopupItemDataList data; + + // 1. share + WindowData::CtxpopupCallbackType shareCallback = + DPL::MakeDelegate(this, &WrtClient::ctxpopupShare); + WindowData::CtxpopupItemData shareData("Share", + std::string(), + shareCallback); + + // 2. reload + WindowData::CtxpopupCallbackType reloadCallback = + DPL::MakeDelegate(this, &WrtClient::ctxpopupReload); + WindowData::CtxpopupItemData reloadData("Reload", + std::string(), + reloadCallback); + + // 3. Open in browser + WindowData::CtxpopupCallbackType launchBrowserCallback = + DPL::MakeDelegate(this, &WrtClient::ctxpopupLaunchBrowser); + WindowData::CtxpopupItemData launchBrowserData("Open in browser", + std::string(), + launchBrowserCallback); + data.push_back(shareData); + data.push_back(reloadData); + data.push_back(launchBrowserData); + m_windowData->setCtxpopupItemData(data); +} - if (m_settingList->getBackButtonPresence() == BackButton_Enable) { - m_windowData->addNaviframeItemPopCallback( - WrtClient::naviframeBackButtonCallback, - this); +void WrtClient::ctxpopupShare(void) +{ + LogDebug("share"); + const char* url = ewk_view_url_get(m_widget->GetCurrentWebview()); + if (!url) { + LogError("url is empty"); + return; + } + if (ClientModule::ServiceSupport::launchShareService( + elm_win_xwindow_get(m_windowData->m_win), + url)) + { + LogInfo("success"); + } else { + LogInfo("fail"); + } +} + +void WrtClient::ctxpopupReload(void) +{ + LogDebug("reload"); + ewk_view_reload(m_widget->GetCurrentWebview()); +} + +void WrtClient::ctxpopupLaunchBrowser(void) +{ + LogDebug("launchBrowser"); + const char* url = ewk_view_url_get(m_widget->GetCurrentWebview()); + if (!url) { + LogError("url is empty"); + return; + } + if (ClientModule::ServiceSupport::launchViewService( + elm_win_xwindow_get(m_windowData->m_win), + url)) + { + LogInfo("success"); + } else { + LogInfo("fail"); + } +} + +void WrtClient::hwkeyCallback(const std::string& key) +{ + if (m_settingList->getBackButtonPresence() == BackButton_Enable + || m_currentViewMode == VIEWMODE_TYPE_WINDOWED) + { + if (key == "back") { + m_widget->Backward(); + } else if (key == "menu") { + // UX isn't confirmed + // m_windowData->showCtxpopup(); + } } } @@ -770,7 +863,7 @@ void WrtClient::shutdownStep() m_widget->Hide(); // AutoRotation use m_widget pointer internally. // It must be unset before m_widget is released. - unsetOrientationWindow(); + unsetWindowOrientation(); m_widget.reset(); ewk_context_delete(s_preparedEwkContext); PrepareExternalStorageSingleton::Instance().Deinitialize(); @@ -783,6 +876,27 @@ void WrtClient::shutdownStep() Quit(); } +void WrtClient::autoRotationCallback(void* data, Evas_Object* obj, void* /*event*/) +{ + LogInfo("entered"); + + Assert(data); + Assert(obj); + + WrtClient* This = static_cast(data); + + This->autoRotationSetOrientation(obj); +} + +void WrtClient::autoRotationSetOrientation(Evas_Object* obj) +{ + LogInfo("entered"); + Assert(obj); + + AutoRotationSupport::setOrientation(obj, m_widget->GetCurrentWebview(), + (m_splashScreen) ? m_splashScreen.get(): NULL); +} + int WrtClient::languageChangedCallback(void *data) { LogDebug("Language Changed"); diff --git a/src/wrt-client/wrt-client.h b/src/wrt-client/wrt-client.h index 11f02c8..871edde 100644 --- a/src/wrt-client/wrt-client.h +++ b/src/wrt-client/wrt-client.h @@ -56,6 +56,7 @@ class WrtClient : ReturnStatus::Type getReturnStatus() const; virtual void Quit(); static std::string getTizenIdFromArgument(int argc, char **argv); + void autoRotationSetOrientation(Evas_Object* obj); protected: virtual void OnStop(); @@ -72,9 +73,7 @@ class WrtClient : bool checkArgument(); void setSdkLauncherDebugData(); bool checkDebugMode(SDKDebugData* debugData); - void connectElmCallback(); void initializeWindowModes(); - bool isFullscreen(); // Events virtual void OnEventReceived(const NextStepEvent& event); @@ -85,15 +84,27 @@ class WrtClient : void* event_info); static Eina_Bool naviframeBackButtonCallback(void* data, Elm_Object_Item* it); - - // Low Memory Callback static int appcoreLowMemoryCallback(void* data); static int languageChangedCallback(void *data); + static void autoRotationCallback(void* data, Evas_Object* obj, void* event); + + //view-mode + void setInitialViewMode(); //orientation - void setOrientationWindow(); - void unsetOrientationWindow(); - void setOrientationEwk(); + void setWindowOrientation(int angle); + void setWindowInitialOrientation(); + void unsetWindowOrientation(); + void setEwkInitialOrientation(); + + //ctxpopup + void setCtxpopupItem(); + void ctxpopupShare(); + void ctxpopupReload(); + void ctxpopupLaunchBrowser(); + + // hwkey + void hwkeyCallback(const std::string& key); // launching steps void initStep(); @@ -106,7 +117,6 @@ class WrtClient : void webkitExitCallback(); void webCrashCallback(); void toggleFullscreenCallback(bool fullscreen); - void imeChangedCallback(bool open); void setLayout(Evas_Object* newBuffer); void unsetLayout(Evas_Object* currentBuffer); @@ -127,7 +137,8 @@ class WrtClient : WidgetState m_widgetState; std::unique_ptr m_windowData; std::unique_ptr m_splashScreen; - bool m_fullscreen; + std::string m_initialViewMode; + std::string m_currentViewMode; }; #endif // WRT_CLIENT_H diff --git a/src/wrt-launcher/CMakeLists.txt b/src/wrt-launcher/CMakeLists.txt index e8805ca..721e217 100644 --- a/src/wrt-launcher/CMakeLists.txt +++ b/src/wrt-launcher/CMakeLists.txt @@ -26,6 +26,7 @@ PKG_CHECK_MODULES(LAUNCHER_PKGS dpl-wrt-dao-ro capi-appfw-app-manager capi-appfw-application + appsvc REQUIRED ) diff --git a/src/wrt-launcher/wrt-launcher.cpp b/src/wrt-launcher/wrt-launcher.cpp index b97a30b..edfa038 100644 --- a/src/wrt-launcher/wrt-launcher.cpp +++ b/src/wrt-launcher/wrt-launcher.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #define TIMEOUT_DEFAULT 10 #define ROOT_DEFAULT_UID 0 @@ -198,7 +199,37 @@ static void print_help(FILE *stream, int /*exit_code*/) ); } -static void sighandler(int signo, siginfo_t *si, void *data); +extern "C" int service_to_bundle(service_h service, bundle** data); + +static void serviceReplyCallback(service_h /*request*/, + service_h reply, + service_result_e /*result*/, + void* data) +{ + Ecore_Timer* serviceTimer = static_cast(data); + if (serviceTimer != NULL) { + ecore_timer_del(serviceTimer); + } + + bundle* b = NULL; + service_to_bundle(reply, &b); + const char* port = appsvc_get_data(b, "port"); + if (port != NULL && strlen(port) > 0) { + printf("port: %s\n", port); + printf("result: %s\n", "launched"); + } else { + printf("result: %s\n", "failed"); + } + ecore_main_loop_quit(); + return; +} + +static Eina_Bool timerCallback(void* /*data*/) +{ + printf("result: %s\n", "failed"); + ecore_main_loop_quit(); + return EINA_FALSE; +} int main(int argc, char* argv[]) { @@ -211,9 +242,9 @@ int main(int argc, char* argv[]) char pid[6] = ""; char op = '\0'; bool isDebugMode = false; - struct sigaction sigact; bool dispHelp = false; bool dispList = false; + Ecore_Timer* serviceTimer = NULL; service_h serviceHandle = NULL; int ret = SERVICE_ERROR_NONE; @@ -395,18 +426,7 @@ int main(int argc, char* argv[]) if (op == 's') { /* check if this is request for debug mode, or not */ - if (true == isDebugMode) { - /* wait for return from the widget */ - sigemptyset(&sigact.sa_mask); - sigact.sa_flags = SA_SIGINFO; - sigact.sa_restorer = NULL; - sigact.sa_sigaction = sighandler; - - if (sigaction(SIGRTMIN, &sigact, 0) == 1) { - printf("result: %s\n", "failed"); - return -1; - } - } else { + if (true != isDebugMode) { // case of "-d" option, service_create is already allocated // create service ret = service_create(&serviceHandle); @@ -440,8 +460,15 @@ int main(int argc, char* argv[]) return -1; } + if (true == isDebugMode) { + ecore_init(); + serviceTimer = ecore_timer_add(timeout, timerCallback, NULL); + } + //launch service - ret = service_send_launch_request(serviceHandle, NULL, NULL); + ret = service_send_launch_request(serviceHandle, + serviceReplyCallback, + serviceTimer); if (SERVICE_ERROR_NONE != ret) { printf("result: %s\n", "failed"); service_destroy(serviceHandle); @@ -455,10 +482,8 @@ int main(int argc, char* argv[]) } if (true == isDebugMode) { - // wait RTS signal from widget by 5 second - sleep(timeout); - printf("result: %s\n", "failed"); - return -1; + ecore_main_loop_begin(); + return 0; } // This text should be showed for IDE printf("result: %s\n", "launched"); @@ -521,24 +546,3 @@ int main(int argc, char* argv[]) UNHANDLED_EXCEPTION_HANDLER_END } -static void sighandler(int signo, siginfo_t *si, void* /*data*/) -{ - /* check if this signal is type of RTS */ - if (si->si_code == SI_QUEUE) { - //int port; - //printf("RTS pid : %d\n", si->si_pid); - //port = (int) si->si_value.sival_ptr; - //printf("RTS debug port : %d\n", port); - // This sival_int is wrt's status (like WRT_SUCCESS..) - // enum WRT_SUCCESS is 0 - if (si->si_value.sival_int > 0) { - printf("port: %d\n", (int)si->si_value.sival_int); - printf("result: %s\n", "launched"); - } else { - printf("result: %s\n", "failed"); - } - } else { - printf("Not RT signal : %d\n", signo); - } - exit(0); -} diff --git a/src/wrt-launchpad-daemon/include/app_sock.h b/src/wrt-launchpad-daemon/include/app_sock.h index 4787d87..c9ca402 100644 --- a/src/wrt-launchpad-daemon/include/app_sock.h +++ b/src/wrt-launchpad-daemon/include/app_sock.h @@ -18,10 +18,15 @@ #define __APP_PKT_H_ #include +#ifndef __USE_GNU #define __USE_GNU +#endif #include #include +// forward declare +struct ucred; + enum app_cmd { APP_START, APP_OPEN, diff --git a/src/wrt-launchpad-daemon/include/launchpad_util.h b/src/wrt-launchpad-daemon/include/launchpad_util.h index 43edb5d..7df4776 100644 --- a/src/wrt-launchpad-daemon/include/launchpad_util.h +++ b/src/wrt-launchpad-daemon/include/launchpad_util.h @@ -350,7 +350,7 @@ _static_ void __wrt_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* } pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME); - _D("pkg name : %s", pkg_name); + SECURE_LOGD("pkg name : %s", pkg_name); menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb); if (menu_info == NULL) { @@ -372,7 +372,7 @@ _static_ void __wrt_launchpad_main_loop(app_pkt_t* pkt, char* out_app_path, int* __modify_bundle(kb, /*cr.pid - unused parameter*/ 0, menu_info, pkt->cmd); pkg_name = _get_pkgname(menu_info); - _D("pkg name : %s", pkg_name); + SECURE_LOGD("pkg name : %s", pkg_name); __wrt_prepare_exec(pkg_name, app_path, menu_info, kb); diff --git a/src/wrt-launchpad-daemon/include/simple_util.h b/src/wrt-launchpad-daemon/include/simple_util.h index 06d0ccf..c29bd6a 100644 --- a/src/wrt-launchpad-daemon/include/simple_util.h +++ b/src/wrt-launchpad-daemon/include/simple_util.h @@ -39,6 +39,14 @@ #define _E(fmt, arg ...) LOGE(fmt,##arg) #define _D(fmt, arg ...) LOGD(fmt,##arg) +#ifndef SECURE_LOGD +#define SECURE_LOGD(fmt, arg...) LOGD(fmt,##arg) +#endif + +#ifndef SECURE_LOGE +#define SECURE_LOGE(fmt, arg...) LOGE(fmt,##arg) +#endif + #define retvm_if(expr, val, fmt, arg ...) do { \ if (expr) { \ _E(fmt,##arg); \ diff --git a/src/wrt-launchpad-daemon/launchpad_src/launchpad.c b/src/wrt-launchpad-daemon/launchpad_src/launchpad.c index 5fa0986..5e530cb 100644 --- a/src/wrt-launchpad-daemon/launchpad_src/launchpad.c +++ b/src/wrt-launchpad-daemon/launchpad_src/launchpad.c @@ -528,7 +528,7 @@ _static_ void __launchpad_main_loop(int main_fd, int pool_fd) PERF("packet processing start"); pkg_name = bundle_get_val(kb, AUL_K_PKG_NAME); - _D("pkg name : %s\n", pkg_name); + SECURE_LOGD("pkg name : %s\n", pkg_name); menu_info = _get_app_info_from_bundle_by_pkgname(pkg_name, kb); if (menu_info == NULL) { @@ -595,7 +595,7 @@ _static_ void __launchpad_main_loop(int main_fd, int pool_fd) if (__prepare_exec(pkg_name, app_path, menu_info, kb) < 0) { - _E("preparing work fail to launch - " + SECURE_LOGE("preparing work fail to launch - " "can not launch %s\n", pkg_name); exit(-1); } diff --git a/src/wrt-launchpad-daemon/legacy/preload.h b/src/wrt-launchpad-daemon/legacy/preload.h index a2da81b..a988f74 100644 --- a/src/wrt-launchpad-daemon/legacy/preload.h +++ b/src/wrt-launchpad-daemon/legacy/preload.h @@ -17,7 +17,6 @@ #ifdef PRELOAD_ACTIVATE #include -#include #define PRELOAD_FILE SHARE_PREFIX "/preload_list.txt" #define PRELOAD_FILE_WRT SHARE_PREFIX "/preload_list_wrt.txt" @@ -30,8 +29,6 @@ static int g_argc; static char **g_argv; static size_t max_cmdline_size = 0; -static GSList *g_dlopen_handle_list = NULL; - typedef struct handle_list_t { int (*dl_einit)(); int (*dl_efini)(); @@ -52,79 +49,9 @@ static inline void __preload_init(int argc, char **argv) } _D("max_cmdline_size = %d", max_cmdline_size); - preload_list = fopen(PRELOAD_FILE, "rt"); - if (preload_list == NULL) { - _E("no preload\n"); - return; - } - - while (fgets(soname, MAX_LOCAL_BUFSZ, preload_list) != NULL) { - size_t pos = strnlen(soname, MAX_LOCAL_BUFSZ); - if (pos > 0) { - soname[pos - 1] = '\0'; - } - - handle_list_t *entry = calloc(1, sizeof(handle_list_t)); - if (!entry) { - _E("out of memory\n"); - break; - } - - entry->handle = dlopen(soname, RTLD_NOW); - if (entry->handle == NULL) { - free(entry); - continue; - } - _D("preload %s# - handle : %x\n", soname, entry->handle); - - func = dlsym(entry->handle, EFL_PREINIT_FUNC); - if (func != NULL) { - _D("get pre-initialization function\n"); - entry->dl_einit = func; - func = dlsym(entry->handle, EFL_SHUTDOWN_FUNC); - if (func != NULL) { - _D("get shutdown function\n"); - entry->dl_efini = func; - } - } - g_dlopen_handle_list = g_slist_prepend(g_dlopen_handle_list, entry); - } - fclose(preload_list); preload_initialized = 1; } -static inline int preinit_init() -{ - GSList *iter = NULL; - handle_list_t *entry; - - for (iter = g_dlopen_handle_list; iter != NULL; iter = g_slist_next(iter)) { - entry = iter->data; - if (entry->dl_einit != NULL) - entry->dl_einit(0, NULL); - } - _D("pre-initialzation on"); - return 0; -} - -static inline int preinit_fini() -{ - GSList *iter = NULL; - handle_list_t *entry; - - for (iter = g_dlopen_handle_list; iter != NULL; iter = g_slist_next(iter)) { - entry = iter->data; - if (entry->dl_efini != NULL) - entry->dl_efini(); - if (entry->handle) - dlclose(entry->handle); - } - _D("pre-initialization off"); - g_slist_free_full(g_dlopen_handle_list, free); - g_dlopen_handle_list = NULL; - return 0; -} - /* TODO : how to set cmdline gracefully ?? */ static inline int __change_cmdline(char *cmdline) { @@ -238,6 +165,7 @@ static inline void __preload_init_for_wrt() } handle = dlopen(soname, RTLD_NOW | RTLD_GLOBAL); if (handle == NULL) { + _E("dlopen(\"%s\") was failed!", soname); continue; } if (0 != __preload_save_dlopen_handle(handle)) { diff --git a/src/wrt-launchpad-daemon/legacy/preload_list_wrt.txt b/src/wrt-launchpad-daemon/legacy/preload_list_wrt.txt index 675f10b..cd974e2 100644 --- a/src/wrt-launchpad-daemon/legacy/preload_list_wrt.txt +++ b/src/wrt-launchpad-daemon/legacy/preload_list_wrt.txt @@ -1,3 +1,6 @@ +/usr/lib/libappcore-efl.so.1 +/usr/lib/libappcore-common.so.1 +/usr/lib/ecore/immodules/libisf-imf-module.so /usr/bin/wrt-client /usr/lib/libwrt-injected-bundle.so /usr/lib/wrt-plugins/w3c-widget-interface/libwrt-plugins-w3c-widget-interface.so diff --git a/tests/widgets/common/include/mock/MockViewModule.h b/tests/widgets/common/include/mock/MockViewModule.h index 4149743..f9a21d6 100644 --- a/tests/widgets/common/include/mock/MockViewModule.h +++ b/tests/widgets/common/include/mock/MockViewModule.h @@ -45,6 +45,9 @@ public: const char* name, const char* body, char** returnData); + void checkAsyncMessageFromBundle( + const char* name, + const char* body); void downloadData(const char* url); void activateVibration(bool on, uint64_t time); }; diff --git a/tests/widgets/common/src/mock/MockViewModule.cpp b/tests/widgets/common/src/mock/MockViewModule.cpp index bfc6374..d691b98 100644 --- a/tests/widgets/common/src/mock/MockViewModule.cpp +++ b/tests/widgets/common/src/mock/MockViewModule.cpp @@ -83,6 +83,12 @@ void MockViewModule::checkSyncMessageFromBundle( { } +void MockViewModule::checkAsyncMessageFromBundle( + const char* /*name*/, + const char* /*body*/) +{ +} + void MockViewModule::downloadData(const char* /*url*/) { } -- 2.7.4