src/controls/FWebCtrl_CertificateConfirmPopup.cpp
src/controls/FWebCtrlWebStorageManager.cpp
src/controls/FWebCtrl_WebStorageManagerImpl.cpp
+ src/controls/FWebCtrl_WebNotification.cpp
+ src/controls/FWebCtrl_WebNotificationHandler.cpp
)
## Add Definitions
ADD_DEFINITIONS(${OSP_DEFINITIONS} -D_MODEL_RES_WVGA)
#include "FWebCtrl_GeolocationPermissionManagerImpl.h"
#include "FWebCtrl_HitElementResultImpl.h"
#include "FWebCtrl_InputPickerPopup.h"
+#include "FWebCtrl_WebNotification.h"
#include "FWebCtrl_PageNavigationListImpl.h"
#include "FWebCtrl_PromptPopup.h"
#include "FWebCtrl_SelectBox.h"
void
OnNotificationPermissionRequested(void* pUserData, Evas_Object* pView, void* pEventInfo)
{
+ result r = E_SUCCESS;
_WebImpl* pImpl = reinterpret_cast<_WebImpl*>(pUserData);
Ewk_Notification_Permission_Request* pPermissionRequest = reinterpret_cast< Ewk_Notification_Permission_Request* >(pEventInfo);
SysAssertf(pImpl && pPermissionRequest, "Failed to request");
- SysLog(NID_WEB_CTRL, "The permission popup has not Implemented yet. allow is the default value now.");
-
- //ToDo : Show NotificationPermissionPopup
-
- Ewk_Context* pContext = ewk_view_context_get(pView);
- SysAssertf(pContext, "Failed to get webkit instance.");
+ MessageBox messageBox;
+ r = messageBox.Construct(L"Notification request", L"Do you want to allow notifications from this site ?", MSGBOX_STYLE_OKCANCEL);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- //ewk_notification_permission_request_origin_get(pPermissionRequest);
+ int modalResult = 0;
+ r = messageBox.ShowAndWait(modalResult);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
- ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
+ if (modalResult == MSGBOX_RESULT_OK)
+ {
+ ewk_notification_permission_request_set(pPermissionRequest, EINA_TRUE);
+ }
+ else
+ {
+ ewk_notification_permission_request_set(pPermissionRequest, EINA_FALSE);
+ }
}
Ewk_Notification* pNotification = reinterpret_cast< Ewk_Notification* >(pEventInfo);
SysAssertf(pImpl && pNotification, "Failed to request");
+ result r = E_SUCCESS;
Ewk_Context* pContext = ewk_view_context_get(pView);
SysAssertf(pContext, "Failed to get webkit instance.");
+ uint64_t notificationId = ewk_notification_id_get(pNotification);
- //ToDo : Show Notification
- //Perform ewk_notification_clicked
//ewk_notification_security_origin_get(pNotification)
- SysLog(NID_WEB_CTRL, "The current value of title is %s", ewk_notification_title_get(pNotification));
- SysLog(NID_WEB_CTRL, "The current value of body is %s", ewk_notification_body_get(pNotification));
+
+ const char* text = ewk_notification_body_get(pNotification);
SysLog(NID_WEB_CTRL, "The current value of icon path is %s",ewk_notification_icon_url_get(pNotification));
- uint64_t notificationId = ewk_notification_id_get(pNotification);
+ std::unique_ptr<_WebNotification> pNotificationWindow( new (std::nothrow) _WebNotification());
+ SysTryReturnVoidResult(NID_WEB_CTRL, pNotificationWindow.get(), E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
+
+ r = pNotificationWindow->Construct(pContext, notificationId);
+ SysTryReturnVoidResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error propogated.", GetErrorMessage(r));
+
+ pNotificationWindow->SetText(String(text));
+ pNotificationWindow->LaunchNotification();
+ pNotificationWindow.release();
+
ewk_notification_showed(pContext, notificationId);
}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 FWebCtrl_WebNotification.cpp
+ * @brief The file contains the definition of _WebNotification class.
+ */
+
+#include <FBaseRtTimer.h>
+#include <FBaseSysLog.h>
+#include <FUiAnimControlAnimator.h>
+#include <FUiAnimPointAnimation.h>
+#include <FUiAnimFloatAnimation.h>
+#include <FUiAnimAnimationTransaction.h>
+#include <FUiCtrlButton.h>
+#include "FWebCtrl_WebNotificationHandler.h"
+#include "FWebCtrl_WebNotification.h"
+
+
+using namespace Tizen::Base;
+using namespace Tizen::Base::Runtime;
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Animations;
+using namespace Tizen::Ui::Controls;
+
+namespace Tizen { namespace Web { namespace Controls
+{
+
+_WebNotification::_WebNotification(void)
+ : __pNotificationHandler(null)
+ , __pContext(null)
+ , __notificationId(0)
+ , __pTimer(null)
+{
+}
+
+
+_WebNotification::~_WebNotification(void)
+{
+}
+
+result
+_WebNotification::Construct(Ewk_Context *pContext, uint64_t notificationId)
+{
+
+// _ControlOrientation orientation = _ControlManager::GetInstance()->GetOrientation();
+// Dimension screenRect = _ControlManager::GetInstance()->GetScreenSize();
+
+ Rectangle rect(NOTIFCATION_RECT_AREA);
+ result r = E_SUCCESS;
+
+ __pContext = pContext;
+ __notificationId = notificationId;
+
+ r = Window::Construct(rect, true, true);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
+ SetBounds(rect);
+
+ __pNotificationHandler = std::unique_ptr<_WebNotificationHandler>(new (std::nothrow) _WebNotificationHandler());
+ SysTryReturnResult(NID_WEB_CTRL, __pNotificationHandler.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pNotificationHandler->Construct(this);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
+
+ SetPropagatedTouchEventListener(__pNotificationHandler.get());
+ __pTimer = std::unique_ptr<Timer>( new (std::nothrow) Timer());
+ SysTryReturnResult(NID_WEB_CTRL, __pTimer.get(), E_OUT_OF_MEMORY, "Memory allocation failed.");
+
+ r = __pTimer->Construct(*this);
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
+
+ return r;
+}
+
+
+void
+_WebNotification::SetText(const String& text)
+{
+ __pNotificationHandler->SetText(text);
+}
+
+String
+_WebNotification::GetText(void) const
+{
+ return __pNotificationHandler->GetText();
+}
+
+
+result
+_WebNotification::OnDraw(void)
+{
+ result r = E_SUCCESS;
+ SysTryReturnResult(NID_WEB_CTRL, __pNotificationHandler.get(), E_SYSTEM, "Failed to find Impl Instance.");
+
+ std::unique_ptr<Canvas> pCanvas(GetCanvasN());
+ SysTryReturnResult(NID_WEB_CTRL, pCanvas.get(), GetLastResult(), "[%s] Error Propagated.", GetErrorMessage(GetLastResult()));
+
+ r = __pNotificationHandler->DrawNotification(*pCanvas);
+
+ return r;
+}
+
+
+void
+_WebNotification::OnClicked()
+{
+ SysTryReturnVoidResult(NID_WEB_CTRL, __pContext != null, E_SYSTEM, "[E_SYSTEM] Context instance not found.");
+ ewk_notification_clicked(__pContext,__notificationId);
+}
+
+result
+_WebNotification::LaunchNotification()
+{
+ result r = E_SUCCESS;
+ std::unique_ptr<Button> pButton( new (std::nothrow) Button());
+ SysTryReturnResult(NID_WEB_CTRL, pButton.get(), E_OUT_OF_MEMORY, "Memory Allocation Failed.");
+
+ r = pButton->Construct(Rectangle(NOTIFCATION_BUTTON_AREA));
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
+
+ pButton->SetText(L"x"); //Need to add bit map
+ pButton->AddActionEventListener(*this);
+
+ r = AddControl(pButton.get());
+ pButton.release();
+
+ SetShowState(true);
+ r = Window::Show();
+ SysTryReturn(NID_WEB_CTRL, r == E_SUCCESS, r, r, "[%s] Error Propogating.", GetErrorMessage(r));
+
+ Point start(0,-200),end;
+ PointAnimation pointAnimation(Point(0, 0), Point(0, 0), 0, ANIMATION_INTERPOLATOR_LINEAR);
+
+ end = Point(0,0);
+
+ pointAnimation.SetStartValue(start);
+ pointAnimation.SetEndValue(end);
+ pointAnimation.SetDuration(2000);
+ pointAnimation.SetAutoReverseEnabled(false);
+
+ ControlAnimator *pAnimator = this->GetControlAnimator();
+ r = pAnimator->StartUserAnimation(ANIMATION_TARGET_POSITION, pointAnimation);
+ SysTryReturnResult(NID_WEB_CTRL, r == E_SUCCESS, r, "[%s] Error Propagated.", GetErrorMessage(r));
+
+ __pTimer->Start(15000);
+ return E_SUCCESS;
+}
+
+
+void
+_WebNotification::OnTimerExpired(Timer& timer)
+{
+
+ int transactionId = 0;
+ int duration = 1000;
+ float start = 1.0f;
+ float end = 0.0f;
+
+ ParallelAnimationGroup showAnim;
+ FloatAnimation floatAnim(start, end, duration, ANIMATION_INTERPOLATOR_LINEAR);
+ showAnim.AddAnimation(ANIMATION_TARGET_ALPHA, floatAnim);
+
+ AnimationTransaction::Begin(transactionId);
+
+ ControlAnimator *pAnimator = this->GetControlAnimator();
+ pAnimator->SetAnimation(ANIMATION_TRIGGER_SHOW_STATE_CHANGE, &showAnim);
+ pAnimator->SetShowState(static_cast< int >(start));
+
+ AnimationTransaction::Commit();
+ delete this;
+}
+
+void
+_WebNotification::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
+{
+ SetShowState(false);
+
+ delete this;
+}
+
+}}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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» » FWebCtrl_WebNotification.h
+* @brief» » The file contains the declaration of _WebNotification class.
+*
+* The file contains the declaration of _WebNotification class.
+*/
+#ifndef _FWEB_CTRL_INTERNAL_WEB_NOTIFCATION_H_
+#define _FWEB_CTRL_INTERNAL_WEB_NOTIFCATION_H_
+
+#include <EWebKit2.h>
+#include <FBaseRtITimerEventListener.h>
+#include <FBaseString.h>
+#include <FGrpDimension.h>
+#include <FGrpRectangle.h>
+#include <FUiControl.h>
+#include <FUiIActionEventListener.h>
+#include <FUiWindow.h>
+
+
+namespace Tizen { namespace Base { namespace Runtime {
+
+class Timer;
+}}} //Tizen::Base::Runtime
+
+
+namespace Tizen { namespace Web { namespace Controls
+{
+
+// forward declaration
+class _WebNotification;
+class _WebNotificationHandler;
+
+
+class _WebNotification
+ : public Tizen::Ui::Window
+ , public Tizen::Base::Runtime::ITimerEventListener
+ , public Tizen::Ui::IActionEventListener
+{
+// Life-cycle
+public:
+ _WebNotification(void);
+ virtual ~_WebNotification(void);
+
+ result Construct(Ewk_Context *pContext, uint64_t notificationId);
+ void SetText(const Tizen::Base::String& text);
+ Tizen::Base::String GetText(void) const;
+ virtual result OnDraw(void);
+
+ result LaunchNotification();
+ void OnClicked();
+
+private:
+ void OnTimerExpired(Tizen::Base::Runtime::Timer& timer);
+ void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
+
+private:
+ std::unique_ptr<_WebNotificationHandler> __pNotificationHandler;
+ Ewk_Context *__pContext;
+ uint64_t __notificationId;
+ std::unique_ptr<Tizen::Base::Runtime::Timer> __pTimer;
+ Tizen::Graphics::Dimension __screenRect;
+}; // _WebNotification
+
+}}}
+#endif // _FWEB_CTRL_INTERNAL_WEB_NOTIFCATION_H_
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 FWebCtrl_WebNotificationHandler.cpp
+ * @brief The file contains the definition of _WebNotificationHandler class.
+ */
+
+#include "FWebCtrl_WebNotification.h"
+#include "FWebCtrl_WebNotificationHandler.h"
+#include <FBaseSysLog.h>
+
+using namespace Tizen::Base;
+using namespace Tizen::Graphics;
+using namespace Tizen::Ui;
+using namespace Tizen::Ui::Controls;
+
+namespace Tizen { namespace Web { namespace Controls
+{
+
+_WebNotificationHandler::_WebNotificationHandler(void)
+ : __pNotification(null)
+ , __state(NOTIFCATION_STATE_NORMAL)
+{
+}
+
+_WebNotificationHandler::~_WebNotificationHandler(void)
+{
+}
+
+
+result
+_WebNotificationHandler::Construct(_WebNotification* pNotification)
+{
+
+ SysTryReturnResult(NID_WEB_CTRL, pNotification != null, E_INVALID_ARG, "Notification instancce cannot be null.");
+
+ __pNotification = pNotification;
+ __pallete[NOTIFCATION_COLOR_BG_NORMAL] = NOTIFCATION_NORMAL_BLACKGROUND_COLOR;
+ __pallete[NOTIFCATION_COLOR_FG_NORMAL] = NOTIFCATION_NORMAL_FOREGROUND_COLOR;
+
+ __bounds = __pNotification->GetBounds();
+ return E_SUCCESS;
+}
+
+
+int
+_WebNotificationHandler::GetState(void) const
+{
+ return __state;
+}
+
+
+void
+_WebNotificationHandler::SetState(int newState)
+{
+ __state = newState;
+}
+
+
+bool
+_WebNotificationHandler::OnPreviewTouchMoved(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ return false;
+}
+
+
+bool
+_WebNotificationHandler::OnPreviewTouchPressed(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ return false;
+}
+
+
+bool
+_WebNotificationHandler::OnPreviewTouchReleased(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ return false;
+}
+
+
+bool
+_WebNotificationHandler::OnTouchCanceled(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ if (GetState() == NOTIFCATION_STATE_PRESSED)
+ {
+ SetState(NOTIFCATION_STATE_NORMAL);
+ __pNotification->Invalidate(false);
+ }
+}
+
+
+bool
+_WebNotificationHandler::OnTouchMoved(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ return false;
+}
+
+
+bool
+_WebNotificationHandler::OnTouchPressed(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ if (GetState() == NOTIFCATION_STATE_NORMAL)
+ {
+ SetState(NOTIFCATION_STATE_PRESSED);
+ __pNotification->Invalidate(false);
+ }
+ return true;
+}
+
+
+bool
+_WebNotificationHandler::OnTouchReleased(Control &source, const TouchEventInfo &touchEventInfo)
+{
+ if (GetState() == NOTIFCATION_STATE_PRESSED)
+ {
+ SetState(NOTIFCATION_STATE_NORMAL);
+ __pNotification->Invalidate(false);
+
+ __pNotification->OnClicked();
+ }
+ return true;
+}
+
+
+result
+_WebNotificationHandler::DrawNotification(Canvas& canvas)
+{
+
+ canvas.SetBackgroundColor(Color(0, 0, 0, 0));
+ canvas.Clear();
+ canvas.FillRoundRectangle(__pallete[NOTIFCATION_COLOR_BG_NORMAL], Rectangle(0, 0 , __bounds.width, __bounds.height), Dimension(5, 5));
+
+ EnrichedText enriched;
+ enriched.Construct(Dimension(__bounds.width, __bounds.height));
+ enriched.SetVerticalAlignment(TEXT_ALIGNMENT_MIDDLE);
+ enriched.SetHorizontalAlignment(TEXT_ALIGNMENT_CENTER);
+
+ TextElement element;
+ element.Construct(__text);
+ element.SetTextColor(__pallete[NOTIFCATION_COLOR_FG_NORMAL]);
+
+ enriched.Add(element);
+ canvas.DrawText(Point(0, 0), enriched);
+ enriched.RemoveAll(false);
+
+ return E_SUCCESS;
+}
+
+
+String
+_WebNotificationHandler::GetText(void) const
+{
+ return __text;
+}
+
+
+void
+_WebNotificationHandler::SetText(const String& text)
+{
+
+ __text = text;
+}
+
+}}}
--- /dev/null
+//
+// Open Service Platform
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// 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 FWebCtrl_WebNotificationImpl.h
+ * @brief The file contains the declaration of _WebNotificationHandler class.
+ *
+ * The file contains the declaration of _WebNotificationHandler class.
+ */
+#ifndef _FWEB_CTRL_INTERNAL_WEB_NOTIFCATION_Handler_H_
+#define _FWEB_CTRL_INTERNAL_WEB_NOTIFCATION_Handler_H_
+
+
+#include <FBaseString.h>
+#include <FGrpDimension.h>
+#include <FGrpRectangle.h>
+#include <FUiControl.h>
+#include <FUiIPropagatedTouchEventListener.h>
+#include <FUiTouchEventInfo.h>
+
+const Tizen::Graphics::Color NOTIFCATION_NORMAL_BLACKGROUND_COLOR = Tizen::Graphics::Color(255, 255, 255, 255);
+const Tizen::Graphics::Color NOTIFCATION_NORMAL_FOREGROUND_COLOR = Tizen::Graphics::Color(0, 0, 0, 255);
+const Tizen::Graphics::Rectangle NOTIFCATION_RECT_AREA = Tizen::Graphics::Rectangle(0,0,600,150);
+const Tizen::Graphics::Rectangle NOTIFCATION_BUTTON_AREA = Tizen::Graphics::Rectangle(550,0,50,50);
+
+const int NOTIFCATION_STATE_NORMAL = 0;
+const int NOTIFCATION_STATE_PRESSED = 1;
+const int NOTIFCATION_STATE_MAX = 2;
+
+const int NOTIFCATION_COLOR_BG_NORMAL = 0;
+const int NOTIFCATION_COLOR_FG_NORMAL = 1;
+const int NOTIFCATION_COLOR_MAX = 2;
+
+
+namespace Tizen { namespace Web { namespace Controls
+{
+// forward declaration
+class _WebNotification;
+class _WebNotificationHandler;
+
+class _WebNotificationHandler
+ : public Tizen::Ui::IPropagatedTouchEventListener
+{
+// Life-cycle
+public:
+ _WebNotificationHandler(void);
+ virtual ~_WebNotificationHandler(void);
+
+ result Construct(_WebNotification* pnotification);
+
+ int GetState(void) const;
+ void SetState(int newState);
+
+ bool OnPreviewTouchMoved(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+ bool OnPreviewTouchPressed(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+ bool OnPreviewTouchReleased(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+ bool OnTouchCanceled(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+ bool OnTouchMoved(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+ bool OnTouchPressed(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+ bool OnTouchReleased(Tizen::Ui::Control &source, const Tizen::Ui::TouchEventInfo &touchEventInfo);
+
+ virtual result DrawNotification(Tizen::Graphics::Canvas& canvas);
+ void SetText(const Tizen::Base::String& text);
+ Tizen::Base::String GetText(void) const;
+
+
+protected:
+ _WebNotification* __pNotification;
+ int __state;
+ Tizen::Base::String __text;
+ Tizen::Graphics::Rectangle __bounds;
+ Tizen::Graphics::Color __pallete[NOTIFCATION_COLOR_MAX];
+}; // _WebNotificationHandler
+
+}}}
+#endif // _FWEB_CTRL_INTERNAL_WEB_NOTIFCATION_Handler_H_