diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:12:45 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:12:45 +0900 |
commit | 03a25875bf9286f887cec3b1d75d628cb3505a63 (patch) | |
tree | 5f7e1967fcaa5403966f6ca416f90d0a1f63e505 | |
parent | 3e2521f912b7820c71d13190125cbdd9bfba279c (diff) | |
download | WebViewer-03a25875bf9286f887cec3b1d75d628cb3505a63.tar.gz WebViewer-03a25875bf9286f887cec3b1d75d628cb3505a63.tar.bz2 WebViewer-03a25875bf9286f887cec3b1d75d628cb3505a63.zip |
Tizen 2.1 base
-rw-r--r-- | LICENSE | 206 | ||||
-rw-r--r-- | NOTICE | 4 | ||||
-rwxr-xr-x | description.xml | 11 | ||||
-rwxr-xr-x | project/data/uritest.html | 9 | ||||
-rw-r--r-- | project/inc/WebViewer.h | 129 | ||||
-rw-r--r-- | project/manifest.xml | 34 | ||||
-rwxr-xr-x | project/res/eng-GB.xml | 5 | ||||
-rwxr-xr-x | project/res/screen-density-high/cancel.png | bin | 0 -> 2821 bytes | |||
-rwxr-xr-x | project/res/screen-density-high/cancel_press.png | bin | 0 -> 3125 bytes | |||
-rwxr-xr-x | project/res/screen-density-high/goto.png | bin | 0 -> 2994 bytes | |||
-rwxr-xr-x | project/res/screen-density-high/goto_press.png | bin | 0 -> 3374 bytes | |||
-rw-r--r-- | project/shared/data/nofile.dummy | 0 | ||||
-rwxr-xr-x | project/shared/res/screen-density-xhigh/mainmenu.png | bin | 0 -> 17581 bytes | |||
-rw-r--r-- | project/shared/trusted/nofile.dummy | 0 | ||||
-rwxr-xr-x | project/src/WebViewer.cpp | 547 | ||||
-rw-r--r-- | project/src/WebViewerEntry.cpp | 60 | ||||
-rwxr-xr-x | sample.xml | 34 | ||||
-rwxr-xr-x | screenshot.png | bin | 0 -> 38709 bytes |
18 files changed, 1039 insertions, 0 deletions
@@ -0,0 +1,206 @@ +Flora License + +Version 1.0, May, 2012 + +http://www.tizenopensource.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 Compatibility Definition Document +and passes the Compatibility Test Suite 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. + +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.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.tizenopensource.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. + @@ -0,0 +1,4 @@ +Copyright (c) Samsung Electronics Co., Ltd. All rights reserved. +Except as noted, this software is licensed under Flora License, Version 1. +Please, see the LICENSE file for Flora License terms and conditions. + diff --git a/description.xml b/description.xml new file mode 100755 index 0000000..a546ef6 --- /dev/null +++ b/description.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="utf-8"?> +<?xml-stylesheet type="text/xsl" href="../../../../description.xsl"?> + +<Overview version="0.17.1"> + <SampleName> WebViewer </SampleName> + <SampleVersion>1.0</SampleVersion> + <Preview>screenshot.png</Preview> + <Description> + This sample application demonstrates how you can embed a Web browser. + </Description> +</Overview> diff --git a/project/data/uritest.html b/project/data/uritest.html new file mode 100755 index 0000000..1370073 --- /dev/null +++ b/project/data/uritest.html @@ -0,0 +1,9 @@ +<html>
+
+<body>
+<div id="myText">SamsungApps Uri scheme Test</div>
+<br>
+<a href="samsungapps://ProductDetail/uw6b8ch0i3">Click to see the application page from SamsungApps</a>
+
+</body>
+</html>
\ No newline at end of file diff --git a/project/inc/WebViewer.h b/project/inc/WebViewer.h new file mode 100644 index 0000000..7c0ea11 --- /dev/null +++ b/project/inc/WebViewer.h @@ -0,0 +1,129 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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.tizenopensource.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. +// + +#ifndef _WEB_VIEWER_H_ +#define _WEB_VIEWER_H_ + +#include <FApp.h> +#include <FBase.h> +#include <FSystem.h> +#include <FUi.h> +#include <FWeb.h> + +class WebViewer + : public Tizen::App::Application + , public Tizen::System::IScreenEventListener + , public Tizen::Ui::IActionEventListener + , public Tizen::Ui::ITextEventListener + , public Tizen::Ui::Controls::IFormBackEventListener + , public Tizen::Web::Controls::ILoadingListener + , public Tizen::Web::Controls::IWebKeypadEventListener + , public Tizen::Web::Controls::IWebUiEventListener + , public Tizen::Ui::IOrientationEventListener +{ +public: + WebViewer(void); + ~WebViewer(void); + + // The application must have a factory method that creates an instance of the application. + static Tizen::App::Application* CreateInstance(void); + + // This method is called when the application is on initializing. + virtual bool OnAppInitializing(Tizen::App::AppRegistry& appRegistry); + + // This method is called when the application is on terminating. + virtual bool OnAppTerminating(Tizen::App::AppRegistry& appRegistry, bool forcedTermination = false); + + // Thie method is called when the application is brought to the foreground + virtual void OnForeground(void); + + // This method is called when the application is sent to the background. + virtual void OnBackground(void); + + // This method is called when the application has little available memory. + virtual void OnLowMemory(void); + + // This method is called when the device's battery level is changed. + virtual void OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel); + + virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId); + + virtual void OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus); + + virtual void OnTextValueChangeCanceled(const Tizen::Ui::Control& source); + virtual void OnTextValueChanged(const Tizen::Ui::Control& source); + + // Called when the screen turns on. + virtual void OnScreenOn(void); + + // Called when the screen turns off. + virtual void OnScreenOff(void); + + virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication); + virtual void OnHttpAuthenticationCanceled(void); + virtual void OnLoadingStarted(void); + virtual void OnLoadingCanceled(void); + virtual void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason); + virtual void OnLoadingCompleted(void); + virtual void OnEstimatedProgress(int progress); + virtual void OnPageTitleReceived(const Tizen::Base::String& title); + virtual bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type); + virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& header); + + virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source); + + virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source); + virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source); + virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source); + + virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web &source, Tizen::Graphics::Point &startPoint, Tizen::Graphics::Point &endPoint); + virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web &source); + virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web &source); + virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void); + +private: + result CreateWebForm(void); + Tizen::Base::String GetValidUrl(Tizen::Base::String& url); + + void SetButtonGotoImage(void); + void SetButtonCancelImage(void); + void SetUrl(const Tizen::Base::String& url); + +private: + const wchar_t* WEB_URL_PREFIX_HTTP; + + static const int AC_BUTTON_WEB_BACK = 3001; + static const int AC_BUTTON_WEB_FORWARD = 3002; + + static const int AC_BUTTON_WEB_GOTO = 5001; + static const int AC_BUTTON_WEB_STOP = 5002; + + static const int WEB_URL_EDIT_FIELD_MAX_SIZE = 1024; + + static const int BUTTON_WIDTH = 112; + static const int EDIT_LINE_HEIGHT = 106; + static const int EDIT_LINE_LEFT_RIGHT_MARGIN = 7; + static const int EDIT_LINE_BOTTOM_MARGIN = 5; + + Tizen::Ui::Controls::Form* __pMainForm; + Tizen::Web::Controls::Web* __pWeb; + Tizen::Ui::Controls::EditField* __pEdit; + Tizen::Ui::Controls::Button* __pButton; +}; + +#endif //_WEB_VIEWER_H_ + diff --git a/project/manifest.xml b/project/manifest.xml new file mode 100644 index 0000000..d1aa9fe --- /dev/null +++ b/project/manifest.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<Manifest xmlns="http://schemas.tizen.org/2012/12/manifest"> + <Id>$(manifestAppId)</Id> + <Version>1.0.0</Version> + <Type>C++App</Type> + <Descriptions> + <Description Locale="eng-GB"/> + </Descriptions> + <Url/> + <Requirements> + <Feature Name="http://tizen.org/feature/platform.core.cpu.arch">x86</Feature> + <Feature Name="http://tizen.org/feature/platform.core.fpu.arch">vfpv3</Feature> + <Feature Name="http://tizen.org/feature/screen.coordinate_system.logical">Normal</Feature> + </Requirements> + <Apps> + <ApiVersion>2.0</ApiVersion> + <Privileges> + <Privilege>http://tizen.org/privilege/web.privacy</Privilege> + <Privilege>http://tizen.org/privilege/web.service</Privilege> + </Privileges> + <UiApp HwAcceleration="On" Main="True" MenuIconVisible="True" Name="$(projectName)"> + <UiScalability BaseScreenSize="Normal" CoordinateSystem="Logical" LogicalCoordinate="720"/> + <UiTheme SystemTheme="White"/> + <DisplayNames> + <DisplayName Locale="eng-GB">$(projectName)</DisplayName> + </DisplayNames> + <Icons> + <Icon Section="MainMenu" Type="Xhigh">mainmenu.png</Icon> + </Icons> + <LaunchConditions/> + <Notifications/> + </UiApp> + </Apps> +</Manifest> diff --git a/project/res/eng-GB.xml b/project/res/eng-GB.xml new file mode 100755 index 0000000..290d738 --- /dev/null +++ b/project/res/eng-GB.xml @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!--
+ This XML file was automatically generated by UiBuilder - do not modify by hand.
+-->
+<string_table Bversion="2.0.0.v20110401" Dversion="20100701"/>
diff --git a/project/res/screen-density-high/cancel.png b/project/res/screen-density-high/cancel.png Binary files differnew file mode 100755 index 0000000..0bfdb09 --- /dev/null +++ b/project/res/screen-density-high/cancel.png diff --git a/project/res/screen-density-high/cancel_press.png b/project/res/screen-density-high/cancel_press.png Binary files differnew file mode 100755 index 0000000..4cdee03 --- /dev/null +++ b/project/res/screen-density-high/cancel_press.png diff --git a/project/res/screen-density-high/goto.png b/project/res/screen-density-high/goto.png Binary files differnew file mode 100755 index 0000000..233fbce --- /dev/null +++ b/project/res/screen-density-high/goto.png diff --git a/project/res/screen-density-high/goto_press.png b/project/res/screen-density-high/goto_press.png Binary files differnew file mode 100755 index 0000000..680dcf2 --- /dev/null +++ b/project/res/screen-density-high/goto_press.png diff --git a/project/shared/data/nofile.dummy b/project/shared/data/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/shared/data/nofile.dummy diff --git a/project/shared/res/screen-density-xhigh/mainmenu.png b/project/shared/res/screen-density-xhigh/mainmenu.png Binary files differnew file mode 100755 index 0000000..983c883 --- /dev/null +++ b/project/shared/res/screen-density-xhigh/mainmenu.png diff --git a/project/shared/trusted/nofile.dummy b/project/shared/trusted/nofile.dummy new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/project/shared/trusted/nofile.dummy diff --git a/project/src/WebViewer.cpp b/project/src/WebViewer.cpp new file mode 100755 index 0000000..d53034c --- /dev/null +++ b/project/src/WebViewer.cpp @@ -0,0 +1,547 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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.tizenopensource.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. +// + +#include <FSysPowerManager.h> +#include "WebViewer.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Utility; +using namespace Tizen::Graphics; +using namespace Tizen::Locales; +using namespace Tizen::System; +using namespace Tizen::App; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Web::Controls; + +WebViewer::WebViewer(void) + : WEB_URL_PREFIX_HTTP(L"http://") + , __pMainForm(null) + , __pWeb(null) + , __pEdit(null) + , __pButton(null) +{ +} + + +WebViewer::~WebViewer(void) +{ +} + + +Application* +WebViewer::CreateInstance(void) +{ + // You can create the instance through another constructor. + return new WebViewer(); +} + + +bool +WebViewer::OnAppInitializing(AppRegistry& appRegistry) +{ + Frame* pAppFrame = new Frame(); + pAppFrame->Construct(); + AddFrame(*pAppFrame); + + result r = E_SUCCESS; + + r = CreateWebForm(); + TryCatch(r == E_SUCCESS, , "CreateWebForm() has failed.\n"); + return true; + +CATCH: + return false; +} + +bool +WebViewer::OnAppTerminating(AppRegistry& appRegistry, bool forcedTermination) +{ + return true; +} + + +void +WebViewer::OnForeground(void) +{ + __pWeb->Resume(); +} + + +void +WebViewer::OnBackground(void) +{ + __pWeb->Pause(); +} + + +void +WebViewer::OnLowMemory(void) +{ +} + + +void +WebViewer::OnBatteryLevelChanged(BatteryLevel batteryLevel) +{ +} + +result +WebViewer::CreateWebForm(void) +{ + result r = E_SUCCESS; + Rectangle bound; + WebSetting setting; + + Header* pHeader; + Footer* pFooter; + + FooterItem footerItem1; + FooterItem footerItem2; + IAppFrame* pAppFrame = GetAppFrame(); + + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + const Bitmap* pBitmap1 = pAppResource->GetBitmapN("/goto.png"); + const Bitmap* pBitmap2 = pAppResource->GetBitmapN("/goto_press.png"); + + const String url = L"http://www.tizen.org"; + + TryReturn(pAppFrame != null, E_SYSTEM, "GetAppFrame() has failed.\n"); + + //form + __pMainForm = new (std::nothrow) Form(); + r = __pMainForm->Construct(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER | FORM_STYLE_FOOTER); + TryReturn(r == E_SUCCESS, r, "Form Construct() has failed. \n "); + + __pMainForm->AddOrientationEventListener(*this); + __pMainForm->SetOrientation(ORIENTATION_AUTOMATIC_FOUR_DIRECTION); + + bound = __pMainForm->GetClientAreaBounds(); + + pAppFrame->GetFrame()->AddControl(*__pMainForm); + pAppFrame->GetFrame()->SetCurrentForm(*__pMainForm); + + //edit field + __pEdit = new (std::nothrow) EditField(); + r = __pEdit->Construct(Rectangle(EDIT_LINE_LEFT_RIGHT_MARGIN, 0, bound.width - EDIT_LINE_LEFT_RIGHT_MARGIN - BUTTON_WIDTH, EDIT_LINE_HEIGHT), + EDIT_FIELD_STYLE_URL_SMALL, INPUT_STYLE_FULLSCREEN, false, WEB_URL_EDIT_FIELD_MAX_SIZE /*GROUP_STYLE_NONE*/); + TryReturn(r == E_SUCCESS, r, "Editfield Construct() has failed.\n "); + __pEdit->AddTextEventListener(*this); + __pEdit->SetText(url); + + r = __pMainForm->AddControl(*__pEdit); + TryReturn(r == E_SUCCESS, r, "Addcontrol() has failed.\n "); + + //header + pHeader = __pMainForm->GetHeader(); + pHeader->SetStyle(HEADER_STYLE_TITLE); + pHeader->SetTitleText(L"WEB VIEWER"); + + //footer + pFooter = __pMainForm->GetFooter(); + pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT); + pFooter->SetBackButton(); + pFooter->AddActionEventListener(*this); + __pMainForm->SetFormBackEventListener(this); + + //footer item + footerItem1.Construct(AC_BUTTON_WEB_BACK); + footerItem1.SetText(L"Back"); + + footerItem2.Construct(AC_BUTTON_WEB_FORWARD); + footerItem2.SetText(L"Forward"); + + pFooter->AddItem(footerItem1); + pFooter->AddItem(footerItem2); + + //button + __pButton = new (std::nothrow) Button(); + r = __pButton->Construct(Rectangle(bound.width - BUTTON_WIDTH, 0, BUTTON_WIDTH, EDIT_LINE_HEIGHT), ""); + TryReturn(r == E_SUCCESS, r, "Button Construct() has failed.\n "); + + __pMainForm->SetBackgroundColor(pFooter->GetColor()); + + __pButton->SetColor(BUTTON_STATUS_NORMAL, pFooter->GetColor()); + __pButton->SetColor(BUTTON_STATUS_PRESSED, pFooter->GetColor()); + + __pButton->SetActionId(AC_BUTTON_WEB_GOTO); + __pButton->SetNormalBackgroundBitmap(*pBitmap1); + __pButton->SetPressedBackgroundBitmap(*pBitmap2); + __pButton->AddActionEventListener(*this); + + r = __pMainForm->AddControl(*__pButton); + TryReturn(r == E_SUCCESS, r, "Addcontrol() has failed.\n "); + + //Web + __pWeb = new (std::nothrow) Web(); + + bound = __pMainForm->GetClientAreaBounds(); + r = __pWeb->Construct(Rectangle(0, EDIT_LINE_HEIGHT + EDIT_LINE_BOTTOM_MARGIN, bound.width, bound.height - EDIT_LINE_HEIGHT - EDIT_LINE_BOTTOM_MARGIN)); + TryReturn(r == E_SUCCESS, r, "Web Construct() has failed.\n "); + + r = __pMainForm->AddControl(*__pWeb); + TryReturn(r == E_SUCCESS, r, "Addcontrol() has failed.\n "); + + setting.SetInputStyle(INPUT_STYLE_OVERLAY); + r = __pWeb->SetSetting(setting); + TryReturn(r == E_SUCCESS, r, "SetSetting() has failed.\n "); + + __pWeb->SetLoadingListener(this); + __pWeb->SetWebKeypadEventListener(this); + __pWeb->SetWebUiEventListener(this); + + __pWeb->SetFocus(); + + delete pBitmap1; + delete pBitmap2; + + return r; +} + +void +WebViewer::OnActionPerformed(const Control& source, int actionId) +{ + String url; + switch (actionId) + { + case AC_BUTTON_WEB_BACK: + { + __pWeb->GoBack(); + } + break; + + case AC_BUTTON_WEB_FORWARD: + { + __pWeb->GoForward(); + } + break; + + case AC_BUTTON_WEB_GOTO: + { + url = __pEdit->GetText(); + + if (url.IsEmpty()) + { + MessageBox messageBox; + messageBox.Construct(L"", L"URL is empty", MSGBOX_STYLE_NONE, 2000); + + int modalResult = 0; + messageBox.ShowAndWait(modalResult); + + return; + } + + __pWeb->LoadUrl(GetValidUrl(url)); + __pMainForm->RequestRedraw(true); + } + break; + + case AC_BUTTON_WEB_STOP: + { + __pWeb->StopLoading(); + } + break; + + default: + break; + } + + return; + +} + +void +WebViewer::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus) +{ + Rectangle bound = __pMainForm->GetClientAreaBounds(); + + __pEdit->SetBounds(Rectangle(EDIT_LINE_LEFT_RIGHT_MARGIN, 0, bound.width - BUTTON_WIDTH - EDIT_LINE_LEFT_RIGHT_MARGIN, EDIT_LINE_HEIGHT)); + __pButton->SetBounds(Rectangle(bound.width - BUTTON_WIDTH, 0, BUTTON_WIDTH, EDIT_LINE_HEIGHT)); + + if (__pWeb->IsVisible()) + { + __pWeb->SetBounds(Rectangle(0, EDIT_LINE_HEIGHT + EDIT_LINE_BOTTOM_MARGIN, bound.width, bound.height - EDIT_LINE_HEIGHT - EDIT_LINE_BOTTOM_MARGIN)); + } + + __pMainForm->Invalidate(true); +} + +void +WebViewer::OnTextValueChangeCanceled(const Tizen::Ui::Control& source) +{ + __pMainForm->SetFocus(); +} + +void +WebViewer::OnTextValueChanged(const Tizen::Ui::Control& source) +{ + __pMainForm->SetFocus(); +} + +void +WebViewer::OnScreenOn(void) +{ +} + +void +WebViewer::OnScreenOff(void) +{ +} + +String +WebViewer::GetValidUrl(Tizen::Base::String& url) +{ + String absoluteUrl = url; + Uri uri; + + uri.SetUri(url); + if (uri.GetScheme() == L"") + { + absoluteUrl.Insert(WEB_URL_PREFIX_HTTP, 0); + } + return absoluteUrl; +} + +bool +WebViewer::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication) +{ + return false; +} + +void +WebViewer::OnHttpAuthenticationCanceled(void) +{ +} + +void +WebViewer::OnLoadingStarted(void) +{ + SetButtonCancelImage(); +} + +void +WebViewer::OnLoadingCanceled(void) +{ + SetButtonGotoImage(); +} + +void +WebViewer::OnLoadingErrorOccurred(LoadingErrorType error, const String& reason) +{ + Tizen::Ui::Controls::MessageBox msgBox; + int modalresult = 0; + Tizen::Base::String errReason; + + switch (error) + { + case WEB_REQUEST_TIMEOUT: + { + errReason = Tizen::Base::String(L"Request timeout"); + } + break; + + case WEB_NO_CONNECTION: + { + errReason = Tizen::Base::String(L"Network is not in service"); + } + break; + + case WEB_MIME_NOT_SUPPORTED: + { + errReason = Tizen::Base::String(L"The content type is not supported"); + } + break; + + case WEB_BAD_URL: + { + errReason = Tizen::Base::String(L"The url is invalid"); + } + break; + + case WEB_HTTP_RESPONSE: + { + errReason = Tizen::Base::String(L"HTTP response"); + } + break; + + case WEB_OUT_OF_MEMORY: + { + errReason = Tizen::Base::String(L"Page Too Large"); + } + break; + + case WEB_REQUEST_MAX_EXCEEDED: + { + errReason = Tizen::Base::String(L"Request Max Exceeded"); + } + break; + + case WEB_ERROR_UNKNOWN: + default: + { + errReason = Tizen::Base::String(L"An Unknown error"); + } + break; + } + + msgBox.Construct(L"LOADING ERROR TYPE", errReason, MSGBOX_STYLE_NONE, 3000); + msgBox.ShowAndWait(modalresult); + SetButtonGotoImage(); +} + +void +WebViewer::OnLoadingCompleted(void) +{ + SetUrl(__pWeb->GetUrl()); + SetButtonGotoImage(); +} + +void +WebViewer::OnEstimatedProgress(int progress) +{ +} + +void +WebViewer::OnPageTitleReceived(const Tizen::Base::String& title) +{ +} + +bool +WebViewer::OnLoadingRequested(const Tizen::Base::String& url, WebNavigationType type) +{ + AppLog("%S",url.GetPointer()); + SetUrl(url); + return false; +} + + +void +WebViewer::SetUrl(const Tizen::Base::String& url) +{ + result r = E_SUCCESS; + if (url.GetLength() < WEB_URL_EDIT_FIELD_MAX_SIZE) + { + r = __pEdit->SetText(url); + TryReturnVoid(r == E_SUCCESS, "Fail to update URL in the EditField."); + __pMainForm->RequestRedraw (true); + } + else + { + AppLog("The length of the URL exceeds the limit of the length of text in this EditField."); + } +} + +DecisionPolicy +WebViewer::OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& header) +{ + return WEB_DECISION_CONTINUE; +} + +void +WebViewer::OnFormBackRequested(Tizen::Ui::Controls::Form& source) +{ + AppLog("OnFormBackRequested."); + Terminate(); +} + +void +WebViewer::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source) +{ + Rectangle bound = __pMainForm->GetClientAreaBounds(); + AppLog("OnWebKeypadWillOpen."); + + if (source.IsVisible()) + { + source.SetSize(bound.width, bound.height - EDIT_LINE_HEIGHT - EDIT_LINE_BOTTOM_MARGIN); + } +} + +void +WebViewer::OnWebKeypadOpened(Tizen::Web::Controls::Web& source) +{ + AppLog("OnWebKeypadOpened."); +} + +void +WebViewer::OnWebKeypadClosed(Tizen::Web::Controls::Web& source) +{ + AppLog("OnWebKeypadClosed."); + Rectangle bound = __pMainForm->GetClientAreaBounds(); + source.SetSize(bound.width, bound.height - EDIT_LINE_HEIGHT - EDIT_LINE_BOTTOM_MARGIN); +} + +void +WebViewer::OnWebPageBlockSelected(Tizen::Web::Controls::Web &source, Tizen::Graphics::Point &startPoint, Tizen::Graphics::Point &endPoint) +{ +} + +void +WebViewer::OnWebPageShowRequested(Tizen::Web::Controls::Web &source) +{ +} + +void +WebViewer::OnWebWindowCloseRequested(Tizen::Web::Controls::Web &source) +{ +} + +Tizen::Web::Controls::Web* +WebViewer::OnWebWindowCreateRequested(void) +{ + MessageBox messageBox; + messageBox.Construct(L"", L"WebViewer doesn't include new window creation.", MSGBOX_STYLE_NONE, 3000); + + int modalResult = 0; + messageBox.ShowAndWait(modalResult); + + return null; +} + +void +WebViewer::SetButtonGotoImage(void) +{ + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + const Bitmap* pBitmap1 = pAppResource->GetBitmapN("/goto.png"); + const Bitmap* pBitmap2 = pAppResource->GetBitmapN("/goto_press.png"); + + __pButton->SetNormalBackgroundBitmap(*pBitmap1); + __pButton->SetPressedBackgroundBitmap(*pBitmap2); + __pButton->SetActionId(AC_BUTTON_WEB_GOTO); + + __pButton->Draw(); + + delete pBitmap1; + delete pBitmap2; +} + +void +WebViewer::SetButtonCancelImage(void) +{ + AppResource* pAppResource = Application::GetInstance()->GetAppResource(); + const Bitmap* pBitmap1 = pAppResource->GetBitmapN("/cancel.png"); + const Bitmap* pBitmap2 = pAppResource->GetBitmapN("/cancel_press.png"); + + __pButton->SetNormalBackgroundBitmap(*pBitmap1); + __pButton->SetPressedBackgroundBitmap(*pBitmap2); + __pButton->SetActionId(AC_BUTTON_WEB_STOP); + + __pButton->Draw(); + + delete pBitmap1; + delete pBitmap2; +} + diff --git a/project/src/WebViewerEntry.cpp b/project/src/WebViewerEntry.cpp new file mode 100644 index 0000000..492373f --- /dev/null +++ b/project/src/WebViewerEntry.cpp @@ -0,0 +1,60 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Flora License, Version 1.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.tizenopensource.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. +// + +/** + * This file contains the Tizen C++ application entry point. + */ +#include "WebViewer.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; + +#ifdef __cplusplus +extern "C" +{ +#endif // __cplusplus + +_EXPORT_ int OspMain(int argc, char* pArgv[]); + + +/** + * The entry function of Tizen C++ application called by the operating system. + */ +int +OspMain(int argc, char* pArgv[]) +{ + result r = E_SUCCESS; + + AppLog("Application started."); + ArrayList args; + args.Construct(); + for (int i = 0; i < argc; i++) + { + args.Add(*(new (std::nothrow) String(pArgv[i]))); + } + + r = Tizen::App::Application::Execute(WebViewer::CreateInstance, &args); + TryLog(r == E_SUCCESS, "Application execution failed-[%s].", GetErrorMessage(r)); + + args.RemoveAll(true); + AppLog("Application finished."); + + return static_cast< int >(r); +} +#ifdef __cplusplus +} +#endif // __cplusplus diff --git a/sample.xml b/sample.xml new file mode 100755 index 0000000..917bcb9 --- /dev/null +++ b/sample.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="ISO-8859-1"?> +<template> + + <slp-property> + <property-group> + <sample-name>WebViewer</sample-name> + <category>Sample</category> + <sdk-version>1.00</sdk-version> + <project-type>org.tizen.nativecpp.buildArtefactType.app</project-type> + <sample-description>description.xml</sample-description> + </property-group> + </slp-property> + + <process type="org.tizen.nativeappcommon.TizenCopyFolder"> + <simple name="projectName" value="$(projectName)"/> + <simple name="folderPath" value="project"/> + <complex-array name="replaceableFiles"> + <element> + <simple name="sourcePath" value="manifest.xml"/> + <simple name="targetPath" value="manifest.xml"/> + <simple name="replaceable" value = "true"/> + </element> + </complex-array> + </process> + <process type="org.tizen.nativecpp.SetDefaultFrameworks"> + <simple name="projectName" value="$(projectName)"/> + <complex-array name="frameworkList"> + <element> + <simple name="framework" value="osp"/> + </element> + </complex-array> + </process> + +</template> diff --git a/screenshot.png b/screenshot.png Binary files differnew file mode 100755 index 0000000..0af374b --- /dev/null +++ b/screenshot.png |