From 0dd61df5ec29ceb9b423b7525c2b7b7d410a914d Mon Sep 17 00:00:00 2001 From: Choi Munseok Date: Mon, 17 Dec 2012 14:50:54 +0900 Subject: [PATCH] Add Livebox Change-Id: Ic736e8860748b26bb9779fbbe0ae4f5e0fc6be76 Signed-off-by: Choi Munseok --- inc/FShellILiveboxPopupProviderFactory.h | 92 ++++ inc/FShellILiveboxProviderFactory.h | 93 ++++ inc/FShellLivebox.h | 42 ++ inc/FShellLiveboxFrame.h | 153 +++++++ inc/FShellLiveboxManager.h | 259 +++++++++++ inc/FShellLiveboxPopup.h | 153 +++++++ inc/FShellLiveboxPopupProvider.h | 173 +++++++ inc/FShellLiveboxProvider.h | 222 +++++++++ inc/FShellLiveboxProviderInfo.h | 195 ++++++++ inc/FShellLiveboxSizeInfo.h | 110 +++++ inc/FShellLiveboxView.h | 162 +++++++ packaging/osp-shell.spec | 13 + src/CMakeLists.txt | 45 ++ src/FShellLiveboxFrame.cpp | 83 ++++ src/FShellLiveboxManager.cpp | 238 ++++++++++ src/FShellLiveboxPopup.cpp | 81 ++++ src/FShellLiveboxPopupProvider.cpp | 72 +++ src/FShellLiveboxProvider.cpp | 68 +++ src/FShellLiveboxProviderInfo.cpp | 115 +++++ src/FShellLiveboxSizeInfo.cpp | 69 +++ src/FShellLiveboxView.cpp | 69 +++ src/FShell_ILiveboxPopupViewEventListener.h | 56 +++ src/FShell_LiveboxFrame.cpp | 229 ++++++++++ src/FShell_LiveboxFrame.h | 85 ++++ src/FShell_LiveboxFrameImpl.cpp | 109 +++++ src/FShell_LiveboxFrameImpl.h | 60 +++ src/FShell_LiveboxFrameModel.cpp | 50 ++ src/FShell_LiveboxFrameModel.h | 53 +++ src/FShell_LiveboxFramePresenter.cpp | 67 +++ src/FShell_LiveboxFramePresenter.h | 55 +++ src/FShell_LiveboxLayer.cpp | 431 ++++++++++++++++++ src/FShell_LiveboxLayer.h | 89 ++++ src/FShell_LiveboxManagerImpl.cpp | 678 ++++++++++++++++++++++++++++ src/FShell_LiveboxManagerIpcMessage.cpp | 41 ++ src/FShell_LiveboxManagerProxy.cpp | 204 +++++++++ src/FShell_LiveboxPopup.cpp | 295 ++++++++++++ src/FShell_LiveboxPopup.h | 85 ++++ src/FShell_LiveboxPopupImpl.cpp | 109 +++++ src/FShell_LiveboxPopupImpl.h | 55 +++ src/FShell_LiveboxPopupModel.cpp | 50 ++ src/FShell_LiveboxPopupModel.h | 53 +++ src/FShell_LiveboxPopupPresenter.cpp | 67 +++ src/FShell_LiveboxPopupPresenter.h | 56 +++ src/FShell_LiveboxPopupProviderImpl.cpp | 72 +++ src/FShell_LiveboxPopupView.cpp | 343 ++++++++++++++ src/FShell_LiveboxPopupView.h | 113 +++++ src/FShell_LiveboxPopupViewEvent.cpp | 122 +++++ src/FShell_LiveboxPopupViewEvent.h | 65 +++ src/FShell_LiveboxPopupViewPresenter.cpp | 57 +++ src/FShell_LiveboxPopupViewPresenter.h | 49 ++ src/FShell_LiveboxProviderImpl.cpp | 60 +++ src/FShell_LiveboxProviderInfoImpl.cpp | 137 ++++++ src/FShell_LiveboxSizeInfoImpl.cpp | 73 +++ src/FShell_LiveboxView.cpp | 392 ++++++++++++++++ src/FShell_LiveboxView.h | 118 +++++ src/FShell_LiveboxViewImpl.cpp | 110 +++++ src/FShell_LiveboxViewImpl.h | 65 +++ src/FShell_LiveboxViewManager.cpp | 487 ++++++++++++++++++++ src/FShell_LiveboxViewManager.h | 122 +++++ src/FShell_LiveboxViewModel.cpp | 101 +++++ src/FShell_LiveboxViewModel.h | 57 +++ src/FShell_LiveboxViewPresenter.cpp | 175 +++++++ src/FShell_LiveboxViewPresenter.h | 72 +++ src/inc/FShell_ILiveboxTouchEventListener.h | 39 ++ src/inc/FShell_LiveboxManagerImpl.h | 116 +++++ src/inc/FShell_LiveboxManagerIpcMessage.h | 36 ++ src/inc/FShell_LiveboxManagerProxy.h | 61 +++ src/inc/FShell_LiveboxPopupProviderImpl.h | 173 +++++++ src/inc/FShell_LiveboxProviderImpl.h | 50 ++ src/inc/FShell_LiveboxProviderInfoImpl.h | 165 +++++++ src/inc/FShell_LiveboxSizeInfoImpl.h | 107 +++++ src/inc/FShell_TemplateUtil.h | 169 +++++++ 72 files changed, 9190 insertions(+) create mode 100644 inc/FShellILiveboxPopupProviderFactory.h create mode 100644 inc/FShellILiveboxProviderFactory.h create mode 100644 inc/FShellLivebox.h create mode 100644 inc/FShellLiveboxFrame.h create mode 100644 inc/FShellLiveboxManager.h create mode 100644 inc/FShellLiveboxPopup.h create mode 100644 inc/FShellLiveboxPopupProvider.h create mode 100644 inc/FShellLiveboxProvider.h create mode 100644 inc/FShellLiveboxProviderInfo.h create mode 100644 inc/FShellLiveboxSizeInfo.h create mode 100644 inc/FShellLiveboxView.h create mode 100644 src/FShellLiveboxFrame.cpp create mode 100644 src/FShellLiveboxManager.cpp create mode 100644 src/FShellLiveboxPopup.cpp create mode 100644 src/FShellLiveboxPopupProvider.cpp create mode 100644 src/FShellLiveboxProvider.cpp create mode 100644 src/FShellLiveboxProviderInfo.cpp create mode 100644 src/FShellLiveboxSizeInfo.cpp create mode 100644 src/FShellLiveboxView.cpp create mode 100644 src/FShell_ILiveboxPopupViewEventListener.h create mode 100644 src/FShell_LiveboxFrame.cpp create mode 100644 src/FShell_LiveboxFrame.h create mode 100644 src/FShell_LiveboxFrameImpl.cpp create mode 100644 src/FShell_LiveboxFrameImpl.h create mode 100644 src/FShell_LiveboxFrameModel.cpp create mode 100644 src/FShell_LiveboxFrameModel.h create mode 100644 src/FShell_LiveboxFramePresenter.cpp create mode 100644 src/FShell_LiveboxFramePresenter.h create mode 100644 src/FShell_LiveboxLayer.cpp create mode 100644 src/FShell_LiveboxLayer.h create mode 100644 src/FShell_LiveboxManagerImpl.cpp create mode 100644 src/FShell_LiveboxManagerIpcMessage.cpp create mode 100644 src/FShell_LiveboxManagerProxy.cpp create mode 100644 src/FShell_LiveboxPopup.cpp create mode 100644 src/FShell_LiveboxPopup.h create mode 100644 src/FShell_LiveboxPopupImpl.cpp create mode 100644 src/FShell_LiveboxPopupImpl.h create mode 100644 src/FShell_LiveboxPopupModel.cpp create mode 100644 src/FShell_LiveboxPopupModel.h create mode 100644 src/FShell_LiveboxPopupPresenter.cpp create mode 100644 src/FShell_LiveboxPopupPresenter.h create mode 100644 src/FShell_LiveboxPopupProviderImpl.cpp create mode 100644 src/FShell_LiveboxPopupView.cpp create mode 100644 src/FShell_LiveboxPopupView.h create mode 100644 src/FShell_LiveboxPopupViewEvent.cpp create mode 100644 src/FShell_LiveboxPopupViewEvent.h create mode 100644 src/FShell_LiveboxPopupViewPresenter.cpp create mode 100644 src/FShell_LiveboxPopupViewPresenter.h create mode 100644 src/FShell_LiveboxProviderImpl.cpp create mode 100644 src/FShell_LiveboxProviderInfoImpl.cpp create mode 100644 src/FShell_LiveboxSizeInfoImpl.cpp create mode 100644 src/FShell_LiveboxView.cpp create mode 100644 src/FShell_LiveboxView.h create mode 100644 src/FShell_LiveboxViewImpl.cpp create mode 100644 src/FShell_LiveboxViewImpl.h create mode 100644 src/FShell_LiveboxViewManager.cpp create mode 100644 src/FShell_LiveboxViewManager.h create mode 100644 src/FShell_LiveboxViewModel.cpp create mode 100644 src/FShell_LiveboxViewModel.h create mode 100644 src/FShell_LiveboxViewPresenter.cpp create mode 100644 src/FShell_LiveboxViewPresenter.h create mode 100644 src/inc/FShell_ILiveboxTouchEventListener.h create mode 100644 src/inc/FShell_LiveboxManagerImpl.h create mode 100644 src/inc/FShell_LiveboxManagerIpcMessage.h create mode 100644 src/inc/FShell_LiveboxManagerProxy.h create mode 100644 src/inc/FShell_LiveboxPopupProviderImpl.h create mode 100644 src/inc/FShell_LiveboxProviderImpl.h create mode 100644 src/inc/FShell_LiveboxProviderInfoImpl.h create mode 100644 src/inc/FShell_LiveboxSizeInfoImpl.h create mode 100644 src/inc/FShell_TemplateUtil.h diff --git a/inc/FShellILiveboxPopupProviderFactory.h b/inc/FShellILiveboxPopupProviderFactory.h new file mode 100644 index 0000000..e935a1d --- /dev/null +++ b/inc/FShellILiveboxPopupProviderFactory.h @@ -0,0 +1,92 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellILiveboxPopupProvider.h + * @brief This is the header file for the %ILiveboxPopupProviderFactory interface. + * + * This header file contains the declarations of the %ILiveboxPopupProviderFactory interface. + */ + +#ifndef _FSHL_ILIVEBOX_POPUP_PROVIDER_FACTORY_H_ +#define _FSHL_ILIVEBOX_POPUP_PROVIDER_FACTORY_H_ + +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +/** + * @interface ILiveboxPopupProviderFactory + * @brief This interface defines the factory for the %LiveboxPopupProvider creation + * + * @since 2.1 + * + * The %ILiveboxPopupProviderFactory is the factory interface for creating the %LiveboxPopupProvider instance. + * The %LiveboxManager calls CreateInstance() when an instance of %ILiveboxPopupProvider is required. + * + * @see LiveboxManager + */ +class _OSP_EXPORT_ ILiveboxPopupProviderFactory +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.1 + */ + virtual ~ILiveboxPopupProviderFactory() {}; + + /** + * Creates a LiveboxPopupProvider instance@n + * Called when the LiveboxPopupProvider creation request is received from the livebox service. @n + * Applications that provide the Livebox functionality must implement this listener. + * + * @since 2.1 + * + * @param[in] providerName The Livebox provider name + * @param[in] userInfo User information that specifed when the Livebox is added + */ + virtual LiveboxPopupProvider* CreateInstance(const Tizen::Base::String& providerName, const Tizen::Base::String& userInfo) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void ILiveboxPopupProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void ILiveboxPopupProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void ILiveboxPopupProvider_Reserved3(void) {} +}; + +}} // Tizen::Shell + +#endif /* _ILIVEBOX_POPUP_FACTORY_H_ */ diff --git a/inc/FShellILiveboxProviderFactory.h b/inc/FShellILiveboxProviderFactory.h new file mode 100644 index 0000000..7a50f8e --- /dev/null +++ b/inc/FShellILiveboxProviderFactory.h @@ -0,0 +1,93 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellILiveboxProviderFactory.h + * @brief This is the header file for the %ILiveboxProviderFactory interface. + * + * This header file contains the declarations of the %ILiveboxProviderFactory interface. + */ + +#ifndef _FSHL_ILIVEBOX_PROVIDER_FACTORY_H_ +#define _FSHL_ILIVEBOX_PROVIDER_FACTORY_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +/** + * @interface ILiveboxProviderFactory + * @brief This interface defines the factory for the %LiveboxProvider creation + * + * @since 2.1 + * + * The %ILiveboxProviderFactory interface defines a factory for the %LiveboxProvider creation + * The %LiveboxManager calls CreateInstance() when an instance of %LiveboxProvider is required. + * Applications that provide the %LiveboxProvider functionality must implement this interface. + * + * @see LiveboxManager + */ +class _OSP_EXPORT_ ILiveboxProviderFactory +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.1 + */ + virtual ~ILiveboxProviderFactory() {}; + + /** + * Called when the LiveboxProvider creation request is received from the livebox service. @n + * Applications that provide the %LiveboxProvider functionality must implement this listener. + * + * @since 2.1 + * + * @param[in] name The Livebox provider name + * @param[in] width The width of the Livebox + * @param[in] height The height of the Livebox + * @param[in] userInfo User information that specifed when the Livebox is added + */ + virtual LiveboxProvider* CreateInstance(const Tizen::Base::String& name, int width, int height, const Tizen::Base::String& userInfo) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void ILiveboxProviderFactory_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void ILiveboxProviderFactory_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void ILiveboxProviderFactory_Reserved3(void) {} +}; + +}} // Tizen::Shell + +#endif /* _FSHL_ILIVEBOX_PROVIDER_FACTORY_H_ */ diff --git a/inc/FShellLivebox.h b/inc/FShellLivebox.h new file mode 100644 index 0000000..0270faf --- /dev/null +++ b/inc/FShellLivebox.h @@ -0,0 +1,42 @@ +// +// 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 FShell.h + * @brief This is the header file for the %Shell namespace. + * + * This header file contains the declarations of the %Shell namespace. + */ + +#ifndef _FSHELL_LIVEBOX_H_ +#define _FSHELL_LIVEBOX_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +} } // Tizen::Shell + +#endif // _FSHELL_LIVEBOX_H_ diff --git a/inc/FShellLiveboxFrame.h b/inc/FShellLiveboxFrame.h new file mode 100644 index 0000000..a3a1ef5 --- /dev/null +++ b/inc/FShellLiveboxFrame.h @@ -0,0 +1,153 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxFrame.h + * @brief This is the header file for the %LiveboxFrame class. + * + * This header file contains the declarations of the %LiveboxFrame class. + */ +#ifndef _FSHL_LIVEBOX_FRAME_H_ +#define _FSHL_LIVEBOX_FRAME_H_ + +#include + +namespace Tizen { namespace Shell +{ + +/** + * @class LiveboxFrame + * @brief This class provides the main frame window for a LiveboxProvider. + * @since 2.1 + * + * The %LiveboxFrame is the root parent of all Livebox controls that are created by a LiveboxProvider. + * + */ +class _OSP_EXPORT_ LiveboxFrame + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. + * Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.1 + */ + LiveboxFrame(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxFrame(void); + + /** + * Initializes this instance of %LiveboxFrame with the specified parameter. + * + * @since 2.1 + * @return An error code + * @param[in] instanceId The Id of LiveboxFrame. + * @param[in] size The new width and height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + + /** + * Initializes this instance of %LiveboxFrame with the specified parameter. + * + * @since 2.1 + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] instanceId The Id of LiveboxFrame. + * @param[in] size The new width and height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxFrame_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxFrame_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxFrame_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxFrame_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxFrame_Reserved5(void) {} + +private: + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxFrame(const LiveboxFrame& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxFrame& operator =(const LiveboxFrame& rhs); +}; // LiveboxFrame + +}} // Tizen::Shell + +#endif // _FSHL_LIVEBOX_FRAME_H_ diff --git a/inc/FShellLiveboxManager.h b/inc/FShellLiveboxManager.h new file mode 100644 index 0000000..1569274 --- /dev/null +++ b/inc/FShellLiveboxManager.h @@ -0,0 +1,259 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxManager.h + * @brief This is the header file for the %LiveboxManager class. + * + * This header file contains the declarations of the %LiveboxManager class. + */ + +#ifndef _FSHL_LIVEBOX_MANAGER_H_ +#define _FSHL_LIVEBOX_MANAGER_H_ + +#include +#include +#include +#include +#include +#include + +namespace Tizen { namespace Base { namespace Collection { class IList; } } } +namespace Tizen { namespace Shell +{ + +/** + * @interface ILiveboxRequestEventListener + * @brief This interface defines a listener for a Livebox viewer(eg, Home screen, Lock screen) that receives request to add Livebox + * + * @since 2.1 + * + * The %ILiveboxRequestEventListener interface defines a listener for a Livebox viewer(eg, Home screen, Lock screen) that receives request to add Livebox + */ +class _OSP_EXPORT_ ILiveboxRequestEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. + * This way, the destructors of the derived classes are called when the destructor of this interface is called. + * + * @since 2.1 + */ + virtual ~ILiveboxRequestEventListener() {} + + /** + * Called when requested to add a Livebox @n + * The client can get callback request to add a Livebox by implementing this listener. @n + * + * @param[in] appId The application ID of the application providing Livebox + * @param[in] providerName The name of Livebox provider to be added + * @param[in] userInfo User information for the Livebox provider + * @param[in] text Alternative text for the Livebox + * @see LiveboxManager::AddLivebox() + */ + virtual void OnLiveboxAddRequested(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& userInfo, const Tizen::Base::String& text) = 0; +}; + + +/** + * @class LiveboxManager + * @brief Manages all the Livebox providers. + * + * @since 2.1 + * + * @final This class is not intended for extension. + * + * The %LiveboxManager class manages all the Livebox providers. + * The livebox manager manages static and run time Livebox information. + */ +class _OSP_EXPORT_ LiveboxManager + : public Tizen::Base::Object +{ +public: + + /** + * Gets the Livebox manager instance. + * + * @since 2.1 + * + * @return A pointer to the %LiveboxManager instance, @n + * else @c null if it fails + */ + static LiveboxManager* GetInstance(); + + /** + * Gets a list of installed LiveboxProviderInfo + * + * @since 2.1 + * + * @return A pointer to the array list that contains all LiveboxProviderInfo of installed LiveboxProvider@n + * else @c null if an error occurs + * + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::Collection::IList* GetLiveboxProviderInfosN(); + + /** + * Gets a list of installed LiveboxProviderInfo + * + * @since 2.1 + * + * @return A pointer to the LiveboxProviderInfo of the specified LiveboxProvider@n + * else @c null if an error occurs + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_OBJ_NOT_FOUND The specified Livebox provider is not found. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + LiveboxProviderInfo* GetLiveboxProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName); + + /** + * Request livebox service to trigger specified livebox update + * + * @since 2.1 + * + * @param[in] appId The appId that provides Livebox + * @param[in] providerName The name of the Livebox provider + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_OBJ_NOT_FOUND The specified Livebox provider is not found. + * @exception E_INVALID_OPERATION The application isn't permitted to request add Livebox of other application package. + * @exception E_SYSTEM A system error has occurred. + */ + result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument = L""); + + + /** + * Request add Livebox to a Livebox viewer(eg, Home screen, Lock screen) + * + * @since 2.1 + * @visibility partner + * @privlevel system + * @privilege http://tizen.org/privilege/shell.install + * + * @param[in] targetAppId The ID of the application that the specified Livebox will be added to + * @param[in] providerAppId The ID of the application providing Livebox + * @param[in] providerName The name of Livebox provider to be added + * @param[in] userInfo User information for the Livebox provider + * @param[in] text Text to represent the Livebox + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_OBJ_NOT_FOUND The specified Livebox provider is not found. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_INVALID_OPERATION The application isn't permitted to request add Livebox of other application package. + * @exception E_UNSUPPORTED_OPERATION The specifed Livebox provider doesn't support this operation. + * @exception E_SYSTEM A system error has occurred. + * + * @see SetLiveboxRequestEventHandler + */ + result AddLivebox(const Tizen::App::AppId& targetAppId, const Tizen::Base::String& providerAppId, const Tizen::Base::String& providerName, const Tizen::Base::String& text, const Tizen::Base::String& userInfo); + + /** + * Sets a Livebox request event listener. @n + * The listener gets notified when requested to add Livebox + * + * @since 2.1 + * + * @return An error code + * @param[in] listener The listener to receive the Livebox request event + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already set. + * @exception E_SYSTEM A system error has occurred. + * + * @see ILiveboxRequestEventListener + * + */ + result SetLiveboxRequestEventHandler(ILiveboxRequestEventListener& listener); + + /** + * Sets a LiveboxProvider factory. @n + * The factory is called when LiveboxProvider is need to be created. + * This function should be called in App::OnAppInitializing(), to receive event correctly. + * Implementing LiveboxProviderFactory is mandatory to provide Livebox functionality. + * + * @since 2.1 + * + * @return An error code + * @param[in] factory The factory to create concrete LiveboxProvider + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already set. + * @exception E_SYSTEM A system error has occurred. + * @see ILiveboxProviderFactory + */ + result SetLiveboxProviderFactory(ILiveboxProviderFactory& factory); + + /** + * Sets a LiveboxPopupProvider factory. @n + * The factory is called when LiveboxPopupProvider is need to be created. + * This function should be called in App::OnAppInitializing(), to receive event correctly. + * Implementing LiveboxPopupProviderFactory is mandatory to provide LiveboxPopup functionality. + * + * @since 2.1 + * + * @return An error code + * @param[in] factory The factory to create concrete LiveboxPopupProvider + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already set. + * @exception E_SYSTEM A system error has occurred. + * @see ILiveboxPopupProviderFactory + */ + result SetLiveboxPopupProviderFactory(ILiveboxPopupProviderFactory& factory); + + +private: + /** + * This default constructor is intentionally declared as private to implement the %Singleton semantic. + * + * @since 2.1 + */ + LiveboxManager(); + + /** + * This destructor is intentionally declared as private to implement the %Singleton semantic. + * + * @since 2.1 + */ + virtual ~LiveboxManager(); + + /** + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxManager& operator =(const LiveboxManager& rhs); + + /** + * Constructs the instance of this class. + * + * @since 2.1 + * + * @return An error code + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + */ + result Construct(); + +public: + ILiveboxRequestEventListener* __pLiveboxRequestEventListener;//TODO: to impl + +private: + class _LiveboxManagerImpl* __pLiveboxManagerImpl; +}; + +}} // Tizen::Shell +#endif /* _FSHL_LIVEBOX_MANAGER_H_ */ diff --git a/inc/FShellLiveboxPopup.h b/inc/FShellLiveboxPopup.h new file mode 100644 index 0000000..a3cdd7b --- /dev/null +++ b/inc/FShellLiveboxPopup.h @@ -0,0 +1,153 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxPopup.h + * @brief This is the header file for the %LiveboxPopup class. + * + * This header file contains the declarations of the %LiveboxPopup class. + */ +#ifndef _FSHL_LIVEBOX_POPUP_H_ +#define _FSHL_LIVEBOX_POPUP_H_ + +#include + +namespace Tizen { namespace Shell +{ + +/** + * @class LiveboxPopup + * @brief This class provides the popup for a LiveboxProvider. + * @since 2.1 + * + * The %LiveboxPopup supports detailed screen for a LiveboxProvider. + * + */ +class _OSP_EXPORT_ LiveboxPopup + : public Tizen::Ui::Window +{ +public: + /** + * The object is not fully constructed after this constructor is called. + * Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.1 + */ + LiveboxPopup(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxPopup(void); + + /** + * Initializes this instance of %LiveboxFrame with the specified parameter. + * + * @since 2.1 + * @return An error code + * @param[in] instanceId The Id of LiveboxPopup. + * @param[in] size The new width and height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + + /** + * Initializes this instance of %LiveboxFrame with the specified parameter. + * + * @since 2.1 + * @return An error code + * @param[in] layout The layout for both the portrait and landscape mode + * @param[in] instanceId The Id of LiveboxPopup. + * @param[in] size The new width and height + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Ui::Layout& layout, const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxPopup_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxPopup_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxPopup_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxPopup_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxPopup_Reserved5(void) {} + +private: + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxPopup(const LiveboxPopup& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxPopup& operator =(const LiveboxPopup& rhs); +}; // LiveboxPopup + +}} // Tizen::Shell + +#endif // _FSHL_LIVEBOX_POPUP_H_ diff --git a/inc/FShellLiveboxPopupProvider.h b/inc/FShellLiveboxPopupProvider.h new file mode 100644 index 0000000..8d07121 --- /dev/null +++ b/inc/FShellLiveboxPopupProvider.h @@ -0,0 +1,173 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxPopupProvider.h + * @brief This is the header file for the LiveboxPopupProvider class. + * + * This header file contains the declarations of the %LiveboxPopupProvider class. + */ + +#ifndef _FSHL_LIVEBOX_POPUP_PROVIDER_H_ +#define _FSHL_LIVEBOX_POPUP_PROVIDER_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class LiveboxFrame; +class LiveboxPopup; + +/** + * @class LiveboxPopupProvider + * @brief This class is the abstract base class of all Livebox popup provider + * + * @since 2.1 + * + * The %LiveboxPopupProvider class is a base class which represents a Livebox popup provider + */ +class _OSP_EXPORT_ LiveboxPopupProvider +: public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + LiveboxPopupProvider(); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxPopupProvider(); + +protected: + /** + * Called when the Livebox popup provider is required to be created @n + * + * @since 2.1 + * + * @param[in] width The width of the Livebox + * @param[in] height The height of the Livebox + * @param[in] userInfo User information that specifed when the Livebox is added + * + * @remarks LiveboxPopup should be created and set here + * @see SetLiveboxPopup + */ + virtual void OnLiveboxPopupProviderInitializing(const Tizen::Base::String& userInfo) = 0; + + /** + * Called when the Livebox popup provider is required to be destroyed @n + * + * @since 2.1 + */ + virtual void OnLiveboxPopupProviderTerminating() = 0; + + /** + * Gets the Livebox's Id. + * + * @since 2.1 + * + * @return The Livebox Id + */ + Tizen::Base::String GetId() const; + + /** + * Sets the frame to the Livebox + * + * @since 2.1 + * + * @return An error code + * @param[in] frame The frame to be set to the Livebox + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application. + * @exception E_SYSTEM A system error has occurred. + */ + void SetLiveboxPopup(Tizen::Shell::LiveboxPopup* pLiveboxPopup); + + /** + * Get the frame from the Livebox + * + * @since 2.1 + * + * @return The LiveBoxFrame instnace, or null if any LiveboxFrame is set yet. + * @param[in] frame The frame to be set to the Livebox + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application. + * @exception E_SYSTEM A system error has occurred. + */ + Tizen::Shell::LiveboxPopup* GetLiveboxPopup() const; + +private: + /** + * Initializes this instance of %LiveboxPopupProvider + * + * @since 2.1 + */ + result Construct(const Tizen::Base::String& instanceId); + + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxPopupProvider(const LiveboxPopupProvider& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxPopupProvider& operator =(const LiveboxPopupProvider& rhs); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxPopupProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxPopupProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxPopupProvider_Reserved3(void) {} + +private: + Tizen::Shell::LiveboxPopup* __pLiveboxFrame;//Todo to impl + class _LiveboxProviderImpl* __pLiveboxProviderImpl; + + friend class _LiveboxManagerImpl; +}; + +} /* namespace Livebox */ +} /* namespace Samsung */ +#endif /* _FSHL_LIVEBOX_POPUP_PROVIDER_H_ */ diff --git a/inc/FShellLiveboxProvider.h b/inc/FShellLiveboxProvider.h new file mode 100644 index 0000000..9f44a44 --- /dev/null +++ b/inc/FShellLiveboxProvider.h @@ -0,0 +1,222 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxProvider.h + * @brief This is the header file for the LiveboxProvider class. + * + * This header file contains the declarations of the %AppManager class. + */ + +#ifndef _FSHL_LIVEBOX_PROVIDER_H_ +#define _FSHL_LIVEBOX_PROVIDER_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class LiveboxFrame; + +/** + * @class LiveboxProvider + * @brief This class is the abstract base class of all Livebox provider + * + * @since 2.1 + * + * The %LiveboxProvider class is a base class which represents a Livebox provider + */ +class _OSP_EXPORT_ LiveboxProvider + : public Tizen::Base::Object +{ +protected: + + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + LiveboxProvider(); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxProvider(); + + /** + * Called when the Livebox provider is required to be created @n + * + * @since 2.1 + * + * @param[in] width The width of the Livebox + * @param[in] height The height of the Livebox + * @param[in] userInfo User information that specifed when the Livebox is added + * + * @remarks LiveboxFrame should be created and set here + * @see SetLiveboxFrame + * + * The following example demonstrates how to initialize the %LiveboxProvider. + * + * @code + * #include + * + * using namespace Tizen::Shell; + * + * void MyLiveboxProvider::OnLiveboxProviderInitializing(int width, int height, const String& userInfo) + * { + * LiveboxFrame* pFrame = new MyLiveboxProviderFrame(); + * pFrame->Construct(id, Dimension(width, height)); + * __pLabel = new Label(); + * + * Rectangle bounds = GetBounds(); + * __pLabel->Construct(bounds, L"TIZEN"); + * AddControl(*__pLabel); + * this->SetLiveboxFrame(pFrame); + * pFrame->Show(); + * } + * @endcode + */ + virtual void OnLiveboxProviderInitializing(int width, int height, const Tizen::Base::String& userInfo) = 0; + + /** + * Called when the Livebox provider is required to be destroyed @n + * The client can destroy it's own LiveboxProvider by implementing this pure virtual function + * + * @since 2.1 + * + * @param[in] isLiveboxRemoved If true, correspondent Livebox is removed from Livebox viewer application. (Home or Lock screen, etc) + */ + virtual void OnLiveboxProviderTerminating(bool isLiveboxRemoved) = 0; + + /** + * Called when the Livebox is required to be updated @n + * The client can update it's own LiveboxProvider by implementing this pure virtual function + * + * @since 2.1 + * + */ + virtual void OnLiveboxProviderUpdating(const Tizen::Base::String& argument) = 0; + + /** + * Gets the LiveboxProvider's Id. + * + * @since 2.1 + * + * @return the LiveboxProvider Id + */ + Tizen::Base::String GetId() const; + + /** + * Sets the frame to the LiveboxProvider + * + * @since 2.1 + * + * @return An error code + * @param[in] frame The frame to be set to the LiveboxProvider + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application. + * @exception E_SYSTEM A system error has occurred. + * + * @remark This function should be called only in OnLiveboxProviderInitializing + */ + result SetLiveboxFrame(Tizen::Shell::LiveboxFrame* pLiveboxFrame); + + /** + * Get the frame from the LiveboxProvider + * + * @since 2.1 + * + * @return the LiveboxFrame instnace, or null if any LiveboxFrame isn't set yet. + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application. + * @exception E_SYSTEM A system error has occurred. + */ + Tizen::Shell::LiveboxFrame* GetLiveboxFrame() const; + +private: + + /** + * Initializes this instance of %LiveboxProvider + * + * @since 2.1 + */ + result Construct(const Tizen::Base::String& instanceId); + + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxProvider(const LiveboxProvider& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxProvider& operator =(const LiveboxProvider& rhs); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxProvider_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxProvider_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxProvider_Reserved5(void) {} + + +private: + class _LiveboxProviderImpl* __pLiveboxProviderImpl; + + friend class _LiveboxManagerImpl; +}; + +}} // Tizen::Shell +#endif /* _FSHL_LIVEBOX_PROVIDER_H_ */ diff --git a/inc/FShellLiveboxProviderInfo.h b/inc/FShellLiveboxProviderInfo.h new file mode 100644 index 0000000..ff7273e --- /dev/null +++ b/inc/FShellLiveboxProviderInfo.h @@ -0,0 +1,195 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxProviderInfo.h + * @brief This is the header file for the %LiveboxProviderInfo class. + * + * This header file contains the declarations of the %LiveboxProviderInfo class. + */ + +#ifndef _FSHL_LIVEBOX_PROVIDER_INFO_H_ +#define _FSHL_LIVEBOX_PROVIDER_INFO_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +/** + * @class LiveboxProviderInfo + * @brief This class contains static Livebox information + * + * @since 2.1 + * + * The %LiveboxProviderInfo class contains static Livebox information@n + */ +class _OSP_EXPORT_ LiveboxProviderInfo + : public Tizen::Base::Object +{ +public: + + /** + * This is the constructor that initializes an instance of %LiveboxProviderInfo with the specified values. + * + * @since 2.1 + */ + LiveboxProviderInfo(const Tizen::App::AppId& appId, const Tizen::Base::String& name); + + /** + * This is the constructor that initializes an instance of %LiveboxProviderInfo with the specified values. + * + * @since 2.1 + */ + LiveboxProviderInfo(const Tizen::Base::String& providerId); + + /** + * This is the copy constructor for the %LiveboxProviderInfo class. + * + * @since 2.1 + * + * @param[in] value An instance of %LiveboxProviderInfo + */ + LiveboxProviderInfo(const LiveboxProviderInfo& rhs); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxProviderInfo(); + + /** + * Gets the application ID. + * + * @since 2.1 + * + * @return The application ID + */ + Tizen::App::AppId GetAppId() const; + + /** + * Gets the Livebox provider name + * + * @since 2.1 + * + * @return The application ID + */ + Tizen::Base::String GetName() const; + + /** + * Gets the display name of the Livbox @n + * If the system language setting is changed, this method returns the localized application name. + * The display name is displayed in applications that showing Livebox like Launcher, and so on. + * + * @since 2.1 + * + * @return The display name of the Livbox + */ + Tizen::Base::String GetDisplayName() const; + + /** + * Gets the icon path of the application. + * + * @since 2.1 + * + * @return The icon path of the application, @n + * An empty string is returned if there is no value. + */ + Tizen::Base::String GetIconPath() const; + + /** + * Gets the Id of the application that exports AppContorl to configure the Livebox + * + * @since 2.1 + * + * @return The Id of the application that exports AppContorl to configure the Livebox @n + * An empty string is returned if there is no value. + * + * The following example demonstrates how to start the application control that is exported for Livebox configuration + * + * @code + * #include + * + * using namespace Tizen::Shell; + * + * LiveboxProviderInfo* pProviderInfo = LiveboxManager::GetInstance()->GetLiveboxProviderInfoN(appId, providerName); + * if( !pProviderInfo->GetConfigurationAppControlAppId().IsEmpty ) + * { + * AppControl* pAc = AppManager::FindAppControl(pProviderInfo->GetConfigurationAppControlAppId(), L"http://tizen.org/appcontrol/operation/livebox/configuration"); + + * HashMap map(SingleObjectDeleter); + * map.Constrcuct(); + * map.Add(L"ProviderName", pProviderInfo->GetProviderName()); + + * pAc.Start(null, null, &map, null); + * } + * delete pProviderInfo; + * @endcode + */ + Tizen::Base::String GetCongiturationAppControlAppId() const; + + /** + * Checks whether the Livebox provider is default or not. + * + * @since 2.0 + * + * @return @c true if the Livebox is default @n + * else @c false + * + * @remarks Default Livebox provider providing Livebox that represents application.@n + * Home application can show Livebox instead of icon and text for applications that includes default Livebox provider. + */ + bool IsDefault() const; + + /** + * Gets a list of LiveboxSizeInfo of the Livebox + * + * @since 2.1 + * + * @return A pointer to the array list that contains all LiveboxSizeInfo of the LiveboxProvider@n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::Collection::IList* GetSizeInfosN() const; + +private: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + LiveboxProviderInfo(); + + /** + * Assigns the value of the specified instance of %LiveboxProviderInfo to the current instance of %LiveboxProviderInfo. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LiveboxProviderInfo + */ + LiveboxProviderInfo& operator =(const LiveboxProviderInfo& rhs); + +private: + class _LiveboxProviderInfoImpl* __pLiveboxProviderInfoImpl; + +friend class _LiveboxProviderInfoImpl; + +}; + +}} // Tizen::Shell +#endif /* _FSHL_LIVEBOX_PROVIDER_INFO_H_ */ diff --git a/inc/FShellLiveboxSizeInfo.h b/inc/FShellLiveboxSizeInfo.h new file mode 100644 index 0000000..3456e9a --- /dev/null +++ b/inc/FShellLiveboxSizeInfo.h @@ -0,0 +1,110 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxProviderInfo.h + * @brief This is the header file for the %LiveboxSizeInfo class. + * + * This header file contains the declarations of the %LiveboxSizeInfo class. + */ + +#ifndef _FSHL_LIVEBOX_SIZE_INFO_H_ +#define _FSHL_LIVEBOX_SIZE_INFO_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +class _LiveboxSizeInfoImpl; + +/** + * @class LiveboxSizeInfo + * @brief This class contains size and preview image path for the size + * + * @since 2.1 + */ +class _OSP_EXPORT_ LiveboxSizeInfo + : public Tizen::Base::Object +{ +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxSizeInfo(); + + /** + * This is the copy constructor for the %LiveboxSizeInfo class. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LiveboxSizeInfo + */ + LiveboxSizeInfo(const LiveboxSizeInfo& rhs); + + /** + * Assigns the value of the specified instance of %LiveboxSizeInfo to the current instance of %LiveboxSizeInfo. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LiveboxSizeInfo + */ + LiveboxSizeInfo& operator =(const LiveboxSizeInfo& rhs); + + /** + * Gets the size + * + * @since 2.1 + * + * @return A size + */ + Tizen::Graphics::Dimension GetSize() const; + + /** + * Gets the image path for preview + * + * @since 2.1 + * + * @return The image path for preview + */ + Tizen::Base::String GetPreviewImagePath() const; + +private: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + LiveboxSizeInfo(); + + /** + * This is the constructor that initializes an instance of %LiveboxSizeInfo with the specified values. + * + * @since 2.1 + */ + LiveboxSizeInfo(Tizen::Graphics::Dimension size, const Tizen::Base::String& previewImagePath); + +private: + _LiveboxSizeInfoImpl* __pLiveboxSizeInfoImpl; + +friend class _LiveboxSizeInfoImpl; +friend class _LiveboxProviderInfoImpl; +}; + + +}} // Tizen::Shell +#endif /* _FSHL_LIVEBOX_SIZE_INFO_H_ */ diff --git a/inc/FShellLiveboxView.h b/inc/FShellLiveboxView.h new file mode 100644 index 0000000..855fb0b --- /dev/null +++ b/inc/FShellLiveboxView.h @@ -0,0 +1,162 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxView.h + * @brief This is the header file for the %LiveboxView class. + * + * This header file contains the declarations of the %LiveboxView class. + */ +#ifndef _FSHL_LIVEBOX_VIEW_H_ +#define _FSHL_LIVEBOX_VIEW_H_ + +#include + +namespace Tizen { namespace Base +{ +class String; +}} //Tizen::Base + + +namespace Tizen { namespace Shell +{ + +/** + * @class LiveboxView + * @brief This class provides the view control for a LiveboxViewer. + * @since 2.1 + * + * The %LiveboxView shows a drawn buffer by LiveboxProvider. + * + */ +class _OSP_EXPORT_ LiveboxView + : public Tizen::Ui::Container +{ +public: + /** + * The object is not fully constructed after this constructor is called. + * Hence, the Construct() method must be called after calling this constructor. + * + * @since 2.1 + */ + LiveboxView(void); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxView(void); + + /** + * Initializes this instance of %LiveboxView with the specified parameter. + * + * @since 2.1 + * @return An error code + * @param[in] appId The AppId of the installed application + * @param[in] rect An instance of the Rectangle class @n + * This instance represents the x and y coordinates of the top-left corner @n + * of the created window along with its width and height. @n + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG A specified input parameter is invalid. + */ + result Construct(const Tizen::Base::String& appId, const Tizen::Graphics::Rectangle& rect); + + /** + * Initializes this instance of %LiveboxView with the specified parameter. + * + * @since 2.1 + * @return An error code + * @param[in] appId Livebox provider id to provide Livebox functionality + * @param[in] position The new position + * @param[in] userInfo Extra data to be delivered to Livebox provider + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG @c height is less than or equal to 0. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + */ + result Construct(const Tizen::Base::String& appId, const Tizen::Graphics::Rectangle& rect, const Tizen::Base::String& userInfo); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxView_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxView_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxView_Reserved3(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxView_Reserved4(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // + // Following method is reserved and may change its name at any time without + // prior notice. + // + // @since 2.1 + // + virtual void LiveboxView_Reserved5(void) {} + +private: + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxView(const LiveboxView& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxView& operator =(const LiveboxView& rhs); +}; // LiveboxView + +}} // Tizen::Shell + +#endif // _FSHL_LIVEBOX_VIEW_H_ diff --git a/packaging/osp-shell.spec b/packaging/osp-shell.spec index 7d90f7a..ce4c07c 100644 --- a/packaging/osp-shell.spec +++ b/packaging/osp-shell.spec @@ -20,8 +20,21 @@ BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(pkgmgr) BuildRequires: pkgconfig(minicontrol-provider) +BuildRequires: pkgconfig(x11) +BuildRequires: pkgconfig(xext) +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(ail) +BuildRequires: pkgconfig(provider) +BuildRequires: pkgconfig(livebox-viewer) +BuildRequires: pkgconfig(livebox-service) +BuildRequires: pkgconfig(shortcut) +BuildRequires: pkgconfig(osp-image-core) +BuildRequires: pkgconfig(osp-media) +BuildRequires: pkgconfig(osp-net) +BuildRequires: osp-image-core-internal-devel BuildRequires: osp-appfw-internal-devel BuildRequires: osp-uifw-internal-devel +BuildRequires: boost-devel # runtime requires Requires: chromium diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 793c192..4835401 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,6 +46,11 @@ INCLUDE_DIRECTORIES( /usr/include/pixman-1 /usr/include/system /usr/include/vconf + /usr/include/shortcut + /usr/include/provider + /usr/include/livebox-service + /usr/include/livebox-viewer + /usr/include/osp/media ) SET (${this_target}_SOURCE_FILES @@ -53,6 +58,37 @@ SET (${this_target}_SOURCE_FILES FShell_QuickPanelFrame.cpp FShell_QuickPanelFrameImpl.cpp FShell_QuickPanelFramePresenter.cpp + FShell_LiveboxProviderImpl.cpp + FShell_LiveboxProviderInfoImpl.cpp + FShell_LiveboxSizeInfoImpl.cpp + FShell_LiveboxManagerImpl.cpp + FShell_LiveboxManagerProxy.cpp + FShellLiveboxProvider.cpp + FShellLiveboxPopupProvider.cpp + FShellLiveboxProviderInfo.cpp + FShellLiveboxSizeInfo.cpp + FShellLiveboxManager.cpp + FShell_LiveboxManagerIpcMessage.cpp + FShell_LiveboxFrame.cpp + FShell_LiveboxFrameImpl.cpp + FShell_LiveboxFrameModel.cpp + FShell_LiveboxFramePresenter.cpp + FShell_LiveboxLayer.cpp + FShell_LiveboxPopup.cpp + FShell_LiveboxPopupImpl.cpp + FShell_LiveboxPopupModel.cpp + FShell_LiveboxPopupPresenter.cpp + FShell_LiveboxPopupView.cpp + FShell_LiveboxPopupViewEvent.cpp + FShell_LiveboxPopupViewPresenter.cpp + FShell_LiveboxView.cpp + FShell_LiveboxViewImpl.cpp + FShell_LiveboxViewManager.cpp + FShell_LiveboxViewModel.cpp + FShell_LiveboxViewPresenter.cpp + FShellLiveboxFrame.cpp + FShellLiveboxPopup.cpp + FShellLiveboxView.cpp ) ## Definitions @@ -74,6 +110,7 @@ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined - TARGET_LINK_LIBRARIES(${this_target} "-lchromium" ) TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-appfw" ) TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-uifw" ) +TARGET_LINK_LIBRARIES(${this_target} "-L/usr/lib/osp -losp-image-core" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" ) TARGET_LINK_LIBRARIES(${this_target} "-lnotification" ) @@ -83,6 +120,14 @@ TARGET_LINK_LIBRARIES(${this_target} "-leina" ) TARGET_LINK_LIBRARIES(${this_target} "-lecore_evas" ) TARGET_LINK_LIBRARIES(${this_target} "-lminicontrol-provider" ) #TARGET_LINK_LIBRARIES(${this_target} "-lcapi-system-runtime-info") +TARGET_LINK_LIBRARIES(${this_target} "-lX11" ) +TARGET_LINK_LIBRARIES(${this_target} "-lXext" ) +TARGET_LINK_LIBRARIES(${this_target} "-lecore_x" ) +TARGET_LINK_LIBRARIES(${this_target} "-llivebox-viewer" ) +TARGET_LINK_LIBRARIES(${this_target} "-llivebox-service" ) +TARGET_LINK_LIBRARIES(${this_target} "-lprovider" ) +TARGET_LINK_LIBRARIES(${this_target} "-lshortcut" ) +TARGET_LINK_LIBRARIES(${this_target} "-lail" ) SET_TARGET_PROPERTIES(${this_target} PROPERTIES diff --git a/src/FShellLiveboxFrame.cpp b/src/FShellLiveboxFrame.cpp new file mode 100644 index 0000000..e4f5a0e --- /dev/null +++ b/src/FShellLiveboxFrame.cpp @@ -0,0 +1,83 @@ +// +// 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 FShellLiveboxFrame.cpp + * @brief This is the implementation for the LiveboxFrame class. + */ + +#include +#include +#include +#include "FShell_LiveboxFrameImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Shell +{ + +LiveboxFrame::LiveboxFrame(void) +{ +} + +LiveboxFrame::~LiveboxFrame(void) +{ +} + +result +LiveboxFrame::Construct(const String& instanceId, const Dimension& size) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + SysLog(NID_APP, "000"); + unique_ptr<_LiveboxFrameImpl> pImpl(_LiveboxFrameImpl::CreateLiveboxFrameImplN(*this, null, null)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysLog(NID_APP, "aaa"); + + _pControlImpl = pImpl.get(); + + r = pImpl->Initialize(instanceId, size); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + SysLog(NID_APP, "bbb"); + + pImpl.release(); + + return r; +} + +result +LiveboxFrame::Construct(const Layout& layout, const String& instanceId, const Dimension& size) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + unique_ptr<_LiveboxFrameImpl> pImpl(_LiveboxFrameImpl::CreateLiveboxFrameImplN(*this, &layout, &layout)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl.get(); + + r = pImpl->Initialize(instanceId, size); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl.release(); + + return r; +} + +}} // Tizen::Shell diff --git a/src/FShellLiveboxManager.cpp b/src/FShellLiveboxManager.cpp new file mode 100644 index 0000000..494134e --- /dev/null +++ b/src/FShellLiveboxManager.cpp @@ -0,0 +1,238 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxManager.cpp + * @brief This is the implementation for the LiveboxManager class. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include "FShell_LiveboxManagerImpl.h" + +using namespace std; +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +namespace Tizen { namespace Shell +{ + +LiveboxManager::LiveboxManager() + :__pLiveboxManagerImpl(null) +{ + +} + +LiveboxManager::~LiveboxManager() +{ +} + +LiveboxManager* +LiveboxManager::GetInstance() +{ + static LiveboxManager* pLiveboxManager = null; + if( pLiveboxManager == null) + { + pLiveboxManager = new LiveboxManager; + SysTryReturn(NID_APP, pLiveboxManager, null, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY" ); + + result r = pLiveboxManager->Construct(); +// SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); + SysAssertf(!IsFailed(r), "Failed to construct LiveboxManager!!"); + SysLog(NID_APP, "LiveboxManager instance is created."); + } + + return pLiveboxManager; +} + +result +LiveboxManager::Construct() +{ + SysAssert(__pLiveboxManagerImpl == null); + + SysLog(NID_APP, "Enter."); + __pLiveboxManagerImpl = _LiveboxManagerImpl::GetInstance(); + SysAssertf(__pLiveboxManagerImpl, "Failed to construct _LiveboxManagerImpl!!"); + + SysLog(NID_APP, "Exit."); + + return E_SUCCESS; +} + +result +LiveboxManager::SetLiveboxProviderFactory(ILiveboxProviderFactory& factory) +{ + return __pLiveboxManagerImpl->SetLiveboxProviderFactory(factory); +} + +result +LiveboxManager::SetLiveboxPopupProviderFactory(ILiveboxPopupProviderFactory& factory) +{ + return __pLiveboxManagerImpl->SetLiveboxPopupProviderFactory(factory); +} + +//result +//LiveboxManager::HandleRequest(const Tizen::Base::String& operationId, Tizen::Base::String* pCategory, Tizen::Base::Collection::IList* pArgs) +//{ +// return __pLiveboxManagerImpl->HandleRequest(operationId, pCategory, pArgs); +//} + +Tizen::Base::Collection::IList* +LiveboxManager::GetLiveboxProviderInfosN() +{ + return __pLiveboxManagerImpl->GetLiveboxProviderInfosN(); +} + +LiveboxProviderInfo* +LiveboxManager::GetLiveboxProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) +{ + // TODO : set configurationAppcontrolAppId + return new LiveboxProviderInfo(appId, providerName); +} + + +/* +result +LiveboxManager::RequestUpdate() +{ + Tizen::App::AppId appId(Tizen::App::_AppInfo::GetAppId()); + + std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(appId)); + int ret = livebox_service_trigger_update(pPackageId.get(), "user,created", "default"); + SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to invoke livebox_service_trigger_update, ret (%d)", ret); + + return E_SUCCESS; +} +*/ + +result +LiveboxManager::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName, const Tizen::Base::String& argument) +{ + __pLiveboxManagerImpl->RequestUpdate(appId, providerName); + + return E_SUCCESS; +} + +//void +//LiveboxManager::TerminateAppIfInvalidState() +//{ +// __pLiveboxManagerImpl->TerminateAppIfInvalidState(); +//} + + +namespace +{ +int AddLiveboxCallback(int ret, int pid, void *data) +{ + if( ret != 0) + { + SysLog(NID_APP, "Error.(%d)", ret); + } + + return 0; +} +} + + +result +LiveboxManager::AddLivebox(const Tizen::App::AppId& targetAppId, const Tizen::Base::String& providerAppId, const Tizen::Base::String& providerName, const Tizen::Base::String& text, const Tizen::Base::String& userInfo) +{ + SysTryReturnResult(NID_APP, providerAppId.IsEmpty()==false, E_INVALID_ARG, "The providerAppId is empty."); + SysTryReturnResult(NID_APP, providerAppId.GetLength() < NATIVE_APP_MAX_APPID_LENGTH, E_INVALID_ARG, "The providerAppId is too long (Maximum %d bytes).", NATIVE_APP_MAX_APPID_LENGTH); + SysTryReturnResult(NID_APP, _PackageManagerImpl::IsAppInstalled(providerAppId) == true, E_APP_NOT_INSTALLED, "The application(%ls) is not installed.", providerAppId.GetPointer()); + + //TODO :: check privilege + String providerId; + if( providerAppId.StartsWith(L"com.samsung", 0) == true ) + { + SysLog(NID_APP, "[E_INVALID_OPERATION] but allowed to test"); + //TODO:return E_INVALID_OPERATION + providerId = providerAppId; + } + else + { + String localPackageId = _PackageManagerImpl::GetPackageIdByAppId(Tizen::App::App::GetInstance()->GetAppId()); + String liveboxProviderPackageId = _PackageManagerImpl::GetPackageIdByAppId(providerAppId); + if( localPackageId != liveboxProviderPackageId) + { + SysLog(NID_APP, "[E_INVALID_OPERATION] but allowed to test"); + //TODO:return E_INVALID_OPERATION + } + providerId = providerAppId + "." + providerName; + } + + PackageInfo packageInfo; + + result r = _PackageManagerImpl::GetInstance()->GetAppPackageInfo(PACKAGE_TYPE_OSP, providerAppId, packageInfo); + SysTryReturn(NID_APP, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + String iconPath = packageInfo.GetAppIconPath(); + + std::unique_ptr pProviderId(_StringConverter::CopyToCharArrayN(providerId)); + std::unique_ptr pName(_StringConverter::CopyToCharArrayN(text)); + std::unique_ptr pContent(_StringConverter::CopyToCharArrayN(userInfo)); + std::unique_ptr pIcon(_StringConverter::CopyToCharArrayN(iconPath)); + + int ret = add_to_home_livebox(pProviderId.get(), pName.get(), LAUNCH_BY_PACKAGE, pContent.get(), pIcon.get(), -1.0l, AddLiveboxCallback, this); + SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "[E_SYSTEM] failed to add_to_home_livebox (%d)", ret); + + return E_SUCCESS; +} + +// c style callback for shortcut_set_request_cb +int LiveboxRequestEventHandler(const char* providerId, const char* text, int type, const char* content_info, const char* icon, int pid, double period, void *data) +{ + SysTryReturn(NID_APP, providerId, 0, E_SYSTEM, "[E_SYSTEM] providerId is null!"); + + LiveboxManager* pLiveboxManager = static_cast(data); + SysTryReturn(NID_APP, pLiveboxManager, 0, E_SYSTEM, "[E_SYSTEM] pLiveboxManager is null!"); + + String appId; + String providerName; + _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, appId, providerName); + + //OnLiveboxAddRequested(const Tizen::Base::AppId& appId, const const Tizen::Base::String& providerName, const Tizen::Base::String& userInfo, const const Tizen::Base::String& text, const Tizen::Base::String& iconPath) + pLiveboxManager->__pLiveboxRequestEventListener->OnLiveboxAddRequested(appId, providerName, content_info, text ); + + return 0; +} + +result +LiveboxManager::SetLiveboxRequestEventHandler(ILiveboxRequestEventListener& listener) +{ + int ret = shortcut_set_request_cb(LiveboxRequestEventHandler, this ); + SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "failed to shortcut_set_request_cb (%d)", ret); + + __pLiveboxRequestEventListener = &listener; + return E_SUCCESS; +} + + +}} // Tizen::Shell diff --git a/src/FShellLiveboxPopup.cpp b/src/FShellLiveboxPopup.cpp new file mode 100644 index 0000000..7c4935c --- /dev/null +++ b/src/FShellLiveboxPopup.cpp @@ -0,0 +1,81 @@ +// +// 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 FShellLiveboxPopup.cpp + * @brief This is the implementation for the LiveboxPopup class. + */ + +#include +#include +#include +#include "FShell_LiveboxPopupImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Shell +{ + +LiveboxPopup::LiveboxPopup(void) +{ +} + +LiveboxPopup::~LiveboxPopup(void) +{ +} + +result +LiveboxPopup::Construct(const String& instanceId, const Dimension& size) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + unique_ptr<_LiveboxPopupImpl> pImpl(_LiveboxPopupImpl::CreateLiveboxPopupImplN(*this, null, null)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl.get(); + + r = pImpl->Initialize(instanceId, size); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl.release(); + + return r; +} + +result +LiveboxPopup::Construct(const Layout& layout, const String& instanceId, const Dimension& size) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + unique_ptr<_LiveboxPopupImpl> pImpl(_LiveboxPopupImpl::CreateLiveboxPopupImplN(*this, &layout, &layout)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl.get(); + + r = pImpl->Initialize(instanceId, size); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl.release(); + + return r; +} + +}} // Tizen::Shell diff --git a/src/FShellLiveboxPopupProvider.cpp b/src/FShellLiveboxPopupProvider.cpp new file mode 100644 index 0000000..8bcb638 --- /dev/null +++ b/src/FShellLiveboxPopupProvider.cpp @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file .cpp + * @brief This is the implementation for the Livebox class. + */ + +#include +#include +#include + +#include "FShell_LiveboxProviderImpl.h" +#include "FShellLiveboxPopupProvider.h" + +namespace Tizen { namespace Shell +{ + +using namespace Tizen::Base; + + + +LiveboxPopupProvider::LiveboxPopupProvider() +{ + SysLog(NID_APP, ""); +} + +LiveboxPopupProvider::~LiveboxPopupProvider() +{ + SysLog(NID_APP, ""); +} + +result +LiveboxPopupProvider::Construct(const String& instanceId) +{ + SysLog(NID_APP, ""); + __pLiveboxProviderImpl = new _LiveboxProviderImpl(instanceId); + SysTryReturnResult(NID_APP, __pLiveboxProviderImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + + return E_SUCCESS; +} + +String +LiveboxPopupProvider::GetId() const +{ + return __pLiveboxProviderImpl->GetId(); +} + +void +LiveboxPopupProvider::SetLiveboxPopup(LiveboxPopup* pLiveboxFrame) +{ + __pLiveboxFrame = pLiveboxFrame; +// return __pLiveboxProviderImpl->SetLiveboxFrame(pLiveboxFrame); +} + +LiveboxPopup* +LiveboxPopupProvider::GetLiveboxPopup() const +{ + return __pLiveboxFrame; +// return __pLiveboxProviderImpl->GetLiveboxFrame(); +} + +}} // Tizen::Shell diff --git a/src/FShellLiveboxProvider.cpp b/src/FShellLiveboxProvider.cpp new file mode 100644 index 0000000..abcba7a --- /dev/null +++ b/src/FShellLiveboxProvider.cpp @@ -0,0 +1,68 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLivebox.cpp + * @brief This is the implementation for the LiveboxProvider class. + */ + +#include +#include +#include + +#include "FShell_LiveboxProviderImpl.h" +#include "FShellLiveboxProvider.h" + +namespace Tizen { namespace Shell +{ + +using namespace Tizen::Base; + +LiveboxProvider::LiveboxProvider() +{ + SysLog(NID_APP, ""); +} + +LiveboxProvider::~LiveboxProvider() +{ + SysLog(NID_APP, ""); +} + +result +LiveboxProvider::Construct(const String& instanceId) +{ + SysLog(NID_APP, ""); + __pLiveboxProviderImpl = new _LiveboxProviderImpl(instanceId); + SysTryReturnResult(NID_APP, __pLiveboxProviderImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + + return E_SUCCESS; +} + +String +LiveboxProvider::GetId() const +{ + return __pLiveboxProviderImpl->GetId(); +} + +result +LiveboxProvider::SetLiveboxFrame(LiveboxFrame* pLiveboxFrame) +{ + return __pLiveboxProviderImpl->SetLiveboxFrame(pLiveboxFrame); +} + +LiveboxFrame* +LiveboxProvider::GetLiveboxFrame() const +{ + return __pLiveboxProviderImpl->GetLiveboxFrame(); +} + +}} // Tizen::Shell diff --git a/src/FShellLiveboxProviderInfo.cpp b/src/FShellLiveboxProviderInfo.cpp new file mode 100644 index 0000000..681dcd8 --- /dev/null +++ b/src/FShellLiveboxProviderInfo.cpp @@ -0,0 +1,115 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxInfo.cpp + * @brief This is the implementation for the LiveboxInfo class. + */ + +#include + +#include + +#include +#include +#include +#include +#include + +#include "FShell_LiveboxProviderInfoImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + + +LiveboxProviderInfo::LiveboxProviderInfo(const Tizen::App::AppId& appId, const Tizen::Base::String& name) +{ + String providerId; + if( appId.StartsWith("com.samsung", 0) == true)// for core livebox (plugin) + { + providerId = appId; + } + else + { + providerId.Format(128, L"%ls.%ls", appId.GetPointer(), name.GetPointer() ); + } + __pLiveboxProviderInfoImpl = new _LiveboxProviderInfoImpl(appId, name, providerId); +} + +LiveboxProviderInfo::LiveboxProviderInfo(const LiveboxProviderInfo& rhs) +{ + SysAssert(rhs.__pLiveboxProviderInfoImpl); + __pLiveboxProviderInfoImpl = new _LiveboxProviderInfoImpl(rhs.__pLiveboxProviderInfoImpl->__appId, rhs.__pLiveboxProviderInfoImpl->__name, rhs.__pLiveboxProviderInfoImpl->__providerId); +} + +/*LiveboxProviderInfo& +LiveboxProviderInfo::operator =(const LiveboxProviderInfo& rhs) +{ + __pLiveboxProviderInfoImpl->__appId = rhs.__pLiveboxProviderInfoImpl->__appId; + __pLiveboxProviderInfoImpl->__name = rhs.__pLiveboxProviderInfoImpl->__name; + __pLiveboxProviderInfoImpl->__providerId = rhs.__pLiveboxProviderInfoImpl->__providerId; + + return *this; +}*/ + +LiveboxProviderInfo::~LiveboxProviderInfo() +{ + delete __pLiveboxProviderInfoImpl; +} + +Tizen::App::AppId +LiveboxProviderInfo::GetAppId() const +{ + SysAssert(__pLiveboxProviderInfoImpl); + return __pLiveboxProviderInfoImpl->GetAppId(); +} + +Tizen::Base::String +LiveboxProviderInfo::GetName() const +{ + SysAssert(__pLiveboxProviderInfoImpl); + return __pLiveboxProviderInfoImpl->GetName(); +} + +Tizen::Base::String +LiveboxProviderInfo::GetDisplayName() const +{ + SysAssert(__pLiveboxProviderInfoImpl); + return __pLiveboxProviderInfoImpl->GetDisplayName(); +} + +Tizen::Base::String +LiveboxProviderInfo::GetIconPath() const +{ + SysAssert(__pLiveboxProviderInfoImpl); + return __pLiveboxProviderInfoImpl->GetIconPath(); +} + +Tizen::Base::String +LiveboxProviderInfo::GetCongiturationAppControlAppId() const +{ + return __pLiveboxProviderInfoImpl->GetCongiturationAppControlAppId(); +} + +Tizen::Base::Collection::IList* +LiveboxProviderInfo::GetSizeInfosN() const +{ + SysAssert(__pLiveboxProviderInfoImpl); + return __pLiveboxProviderInfoImpl->GetSizeInfosN(); +} + +}} // Tizen::Shell diff --git a/src/FShellLiveboxSizeInfo.cpp b/src/FShellLiveboxSizeInfo.cpp new file mode 100644 index 0000000..3531cf6 --- /dev/null +++ b/src/FShellLiveboxSizeInfo.cpp @@ -0,0 +1,69 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxInfo.cpp + * @brief This is the implementation for the LiveboxInfo class. + */ + +#include +#include +#include +#include +#include +#include + +#include "FShell_LiveboxSizeInfoImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +LiveboxSizeInfo::LiveboxSizeInfo(Dimension size, const String& previewImagePath) +{ + __pLiveboxSizeInfoImpl = new _LiveboxSizeInfoImpl(size, previewImagePath); +} + +LiveboxSizeInfo::LiveboxSizeInfo(const LiveboxSizeInfo& rhs) +{ + *__pLiveboxSizeInfoImpl = *rhs.__pLiveboxSizeInfoImpl; +} + +LiveboxSizeInfo& +LiveboxSizeInfo::operator =(const LiveboxSizeInfo& rhs) +{ + *__pLiveboxSizeInfoImpl = *rhs.__pLiveboxSizeInfoImpl; + + return *this; +} + +LiveboxSizeInfo::~LiveboxSizeInfo() +{ +} + +Dimension +LiveboxSizeInfo::GetSize() const +{ + return __pLiveboxSizeInfoImpl->GetSize(); +} + +Tizen::Base::String +LiveboxSizeInfo::GetPreviewImagePath() const +{ + return __pLiveboxSizeInfoImpl->GetPreviewImagePath(); +} + +}} // Tizen::Shell diff --git a/src/FShellLiveboxView.cpp b/src/FShellLiveboxView.cpp new file mode 100644 index 0000000..e443f67 --- /dev/null +++ b/src/FShellLiveboxView.cpp @@ -0,0 +1,69 @@ +// +// 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 FShellLiveboxView.cpp + * @brief This is the implementation for the LiveboxView class. + */ + +#include +#include +#include +#include +#include +#include "FShell_LiveboxViewImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +LiveboxView::LiveboxView(void) +{ +} + +LiveboxView::~LiveboxView(void) +{ +} + +result +LiveboxView::Construct(const String& appId, const Tizen::Graphics::Rectangle& rect) +{ + return Construct(appId, rect, L"default"); +} + +result +LiveboxView::Construct(const String& appId, const Tizen::Graphics::Rectangle& rect, const String& userInfo) +{ + SysAssertf(_pControlImpl == null, "Already constructed. Calling Construct() twice or more on a same instance is not allowed for this class."); + + unique_ptr<_LiveboxViewImpl> pImpl(_LiveboxViewImpl::CreateLiveboxViewImplN(*this)); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pImpl, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + _pControlImpl = pImpl.get(); + + r = pImpl->Initialize(appId, rect, userInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pImpl.release(); + + return r; +} + +}} // Tizen::Shell diff --git a/src/FShell_ILiveboxPopupViewEventListener.h b/src/FShell_ILiveboxPopupViewEventListener.h new file mode 100644 index 0000000..f89ebfd --- /dev/null +++ b/src/FShell_ILiveboxPopupViewEventListener.h @@ -0,0 +1,56 @@ +// +// 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 FShell_ILiveboxPopupViewEventListener.h + * @brief This is the header file for the _ILiveboxPopupViewEventListener interface. + * + * This header file contains the declarations of the _ILiveboxPopupViewEventListener interface. + */ +#ifndef _FSHL_INTERNAL_ILIVEBOX_POPUP_VIEW_EVENT_LISTENER_H_ +#define _FSHL_INTERNAL_ILIVEBOX_POPUP_VIEW_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Shell +{ + +/** + * @interface _ILiveboxPopupViewEventListener + * @brief This interface implements the listener for keypad events. + * @since 2.0 + * + * The _ILiveboxPopupViewEventListener interface enables the implementer to receive the + * software keypad related events. + */ +class _ILiveboxPopupViewEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This is the destructor for this class. + * @since 2.1 + */ + virtual ~_ILiveboxPopupViewEventListener(void) {} + +public: + virtual void OnLiveboxPopupViewOpened(void) = 0; + virtual void OnLiveboxPopupViewClosed(void) = 0; +}; // _ILiveboxPopupViewEventListener + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_ILIVEBOX_POPUP_VIEW_EVENT_LISTENER_H_ diff --git a/src/FShell_LiveboxFrame.cpp b/src/FShell_LiveboxFrame.cpp new file mode 100644 index 0000000..0fbdfa0 --- /dev/null +++ b/src/FShell_LiveboxFrame.cpp @@ -0,0 +1,229 @@ +// +// 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 FShell_LiveboxFrame.cpp + * @brief This is the implementation file for the _LiveboxFrame class. + */ + +#include +#include +#include +#include "FUi_UiKeyEvent.h" +#include "FUi_IUiEventManager.h" +#include "FUi_UiEventManager.h" +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_RootVisualElement.h" +#include "FShell_LiveboxFrame.h" +#include "FShell_LiveboxFramePresenter.h" +#include "FShell_LiveboxLayer.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Shell +{ + +_LiveboxFrame::_LiveboxFrame(void) + : __pLiveboxFramePresenter(new (std::nothrow) _LiveboxFramePresenter(*this)) + , __pLiveboxFrameRootVisualElement(null) + , __pEventManager(null) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pLiveboxFramePresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pEventManager = pEventManager->GetEventManager(); + SysTryReturnVoidResult(NID_UI_CTRL, __pEventManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); +} + +_LiveboxFrame::~_LiveboxFrame(void) +{ + if (__pEventManager) + { + __pEventManager->UnregisterTouchEventHandler(*this); + } + + if (__pLiveboxFrameRootVisualElement) + { + _VisualElement* pVisualElement = GetVisualElement(); + if (pVisualElement) + { + __pLiveboxFrameRootVisualElement->DetachChild(*pVisualElement); + } + } +} + +_LiveboxFrame* +_LiveboxFrame::CreateLiveboxFrameN(void) +{ + unique_ptr<_LiveboxFrame> pLiveboxFrame(new (std::nothrow) _LiveboxFrame()); + SysTryReturn(NID_UI_CTRL, pLiveboxFrame, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLiveboxFrame->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pLiveboxFrame.release(); +} + +result +_LiveboxFrame::Initialize(const String& instanceId, const Dimension& size) +{ + result r = E_SUCCESS; + _VisualElement* pVisualElement = null; + + const int DEFAULT_WIDTH = 172; + const int DEFAULT_HEIGHT = 172; + + Dimension liveboxSize(size); + if (liveboxSize.width <= 0 ) + { + liveboxSize.width = DEFAULT_WIDTH; + } + + if (liveboxSize.height <= 0 ) + { + liveboxSize.height = DEFAULT_HEIGHT; + } + + SetSystemWindow(true); + + Rectangle bounds(0, 0, liveboxSize.width, liveboxSize.height); + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + FloatRectangle fBounds(0.0f, 0.0f, static_cast(bounds.width), static_cast(bounds.height)); + + r = __pLiveboxFramePresenter->Initialize(instanceId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + unique_ptr<_LiveboxLayer> pLayer(new (std::nothrow) _LiveboxLayer(instanceId, *this)); + SysTryReturn(NID_UI_CTRL, pLayer, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pLayer->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxLayer = move(pLayer); + __pLiveboxFrameRootVisualElement = __pLiveboxLayer->GetRootVisualElement(); + + __pLiveboxLayer->SetLayerBounds(bounds); + __pLiveboxLayer->SetShowState(false); + + __pLiveboxFrameRootVisualElement->SetImplicitAnimationEnabled(false); + __pLiveboxFrameRootVisualElement->SetName(L"_LiveboxFrame"); + __pLiveboxFrameRootVisualElement->SetBounds(fBounds); + __pLiveboxFrameRootVisualElement->SetShowState(false); + + pVisualElement = GetVisualElement(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pVisualElement, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxFrameRootVisualElement->AttachChild(*pVisualElement); + + pVisualElement->SetClipChildrenEnabled(false); + pVisualElement->SetShowState(true); + + r = __pEventManager->RegisterTouchEventHandler(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +_LiveboxFrame::GetLiveboxId(void) const +{ + return __pLiveboxFramePresenter->GetLiveboxId(); +} + +result +_LiveboxFrame::SetLayerShowState(bool showState) +{ + result r = E_SUCCESS; + + if (__pLiveboxFrameRootVisualElement) + { + _LiveboxLayer* pLayer = dynamic_cast<_LiveboxLayer*>(__pLiveboxFrameRootVisualElement->GetNativeLayer()); + SysTryReturn(NID_UI_CTRL, pLayer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pLayer->SetShowState(showState); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxFrameRootVisualElement->SetShowState(showState); + } + + return r; +} + +result +_LiveboxFrame::SetLayerBounds(const Rectangle& bounds) +{ + result r = E_SUCCESS; + + if (__pLiveboxFrameRootVisualElement) + { + _LiveboxLayer* pLayer = dynamic_cast<_LiveboxLayer*>(__pLiveboxFrameRootVisualElement->GetNativeLayer()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pLayer, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLayer->SetLayerBounds(bounds); + + FloatRectangle fBounds(0.0f, 0.0f, static_cast(bounds.width), static_cast(bounds.height)); + __pLiveboxFrameRootVisualElement->SetBounds(fBounds); + } + + return r; +} + +void +_LiveboxFrame::OnActivated(void) +{ + result r = SetLayerShowState(true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_LiveboxFrame::OnDeactivated(void) +{ + result r = SetLayerShowState(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_LiveboxFrame::OnBoundsChanged(void) +{ + Rectangle bounds = GetBounds(); + + SetLayerBounds(bounds); +} + +void +_LiveboxFrame::OnDraw(void) +{ + if (__pLiveboxFramePresenter) + { + __pLiveboxFramePresenter->Draw(); + } +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxFrame.h b/src/FShell_LiveboxFrame.h new file mode 100644 index 0000000..b53fe95 --- /dev/null +++ b/src/FShell_LiveboxFrame.h @@ -0,0 +1,85 @@ +// +// 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 FShell_LiveboxFrame.h + * @brief This is the header file for the _LiveboxFrame class. + * + * This header file contains the declarations of the %_LiveboxFrame class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_FRAME_H_ +#define _FSHL_INTERNAL_LIVEBOX_FRAME_H_ + +#include +#include +#include "FUi_Window.h" + +namespace Tizen { namespace Ui +{ +class _IUiEventManager; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Animations +{ +class _RootVisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Shell +{ + +class _LiveboxFramePresenter; +class _LiveboxLayer; + +/** + * @class _LiveboxFrame + * @brief + * @since 2.1 + */ +class _LiveboxFrame + : public Tizen::Ui::_Window +{ +public: + static _LiveboxFrame* CreateLiveboxFrameN(void); + virtual ~_LiveboxFrame(void); + + result Initialize(const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + Tizen::Base::String GetLiveboxId(void) const; + +protected: + _LiveboxFrame(void); + +private: + _LiveboxFrame(const _LiveboxFrame& rhs); + _LiveboxFrame& operator =(const _LiveboxFrame& rhs); + + result SetLayerShowState(bool showState); + result SetLayerBounds(const Tizen::Graphics::Rectangle& bounds); + + virtual void OnActivated(void); + virtual void OnDeactivated(void); + virtual void OnBoundsChanged(void); + virtual void OnDraw(void); + +private: + std::unique_ptr<_LiveboxFramePresenter> __pLiveboxFramePresenter; + std::unique_ptr<_LiveboxLayer> __pLiveboxLayer; + Tizen::Ui::Animations::_RootVisualElement* __pLiveboxFrameRootVisualElement; + Tizen::Ui::_IUiEventManager* __pEventManager; +}; // _LiveboxFrame + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_FRAME_H_ diff --git a/src/FShell_LiveboxFrameImpl.cpp b/src/FShell_LiveboxFrameImpl.cpp new file mode 100644 index 0000000..b5a9324 --- /dev/null +++ b/src/FShell_LiveboxFrameImpl.cpp @@ -0,0 +1,109 @@ +// +// 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. +// + +#include +#include +#include +#include "FShell_LiveboxFrameImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Shell +{ + +const _LiveboxFrameImpl* +_LiveboxFrameImpl::GetInstance(const LiveboxFrame& liveboxFrame) +{ + return static_cast(_ControlImpl::GetInstance(liveboxFrame)); +} + +_LiveboxFrameImpl* +_LiveboxFrameImpl::GetInstance(LiveboxFrame& liveboxFrame) +{ + return static_cast<_LiveboxFrameImpl*>(_ControlImpl::GetInstance(liveboxFrame)); +} + +_LiveboxFrameImpl* +_LiveboxFrameImpl::CreateLiveboxFrameImplN(LiveboxFrame& liveboxFrame, const Layout* pPortraitLayout, const Layout* pLandscapeLayout) +{ + unique_ptr<_LiveboxFrame> pCore(_LiveboxFrame::CreateLiveboxFrameN()); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + unique_ptr<_LiveboxFrameImpl> pImpl(new (std::nothrow) _LiveboxFrameImpl(&liveboxFrame, pCore.get(), pPortraitLayout, pLandscapeLayout)); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pCore.release(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl.release(); +} + +_LiveboxFrameImpl::_LiveboxFrameImpl(LiveboxFrame* pPublic, _LiveboxFrame* pCore, const Layout* pPortraitLayout, const Layout* pLandscapeLayout) + : _WindowImpl(pPublic, pCore, pPortraitLayout, pLandscapeLayout) +{ +} + +_LiveboxFrameImpl::~_LiveboxFrameImpl(void) +{ +} + +const char* +_LiveboxFrameImpl::GetPublicClassName(void) const +{ + return "Tizen::Shell::LiveboxFrame"; +} + +const LiveboxFrame& +_LiveboxFrameImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +LiveboxFrame& +_LiveboxFrameImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _LiveboxFrame& +_LiveboxFrameImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_LiveboxFrame& +_LiveboxFrameImpl::GetCore(void) +{ + return static_cast<_LiveboxFrame&>(_ControlImpl::GetCore()); +} + +result +_LiveboxFrameImpl::Initialize(const String& instanceId, const Dimension& size) +{ + result r = GetCore().Initialize(instanceId, size); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxFrameImpl.h b/src/FShell_LiveboxFrameImpl.h new file mode 100644 index 0000000..8dff6fc --- /dev/null +++ b/src/FShell_LiveboxFrameImpl.h @@ -0,0 +1,60 @@ +// +// 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. +// +#ifndef _FSHL_INTERNAL_LIVEBOX_FRAME_IMPL_H_ +#define _FSHL_INTERNAL_LIVEBOX_FRAME_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FShell_LiveboxFrame.h" + +namespace Tizen { namespace Ui +{ +class Layout; +}} // Tizen::Ui + +namespace Tizen { namespace Shell +{ + +class _LiveboxFrameImpl + : public Tizen::Ui::_WindowImpl +{ +public: + static _LiveboxFrameImpl* CreateLiveboxFrameImplN(LiveboxFrame& liveboxFrame, const Tizen::Ui::Layout* pPortraitLayout, const Tizen::Ui::Layout* pLandscapeLayout); + static const _LiveboxFrameImpl* GetInstance(const LiveboxFrame& liveboxFrame); + static _LiveboxFrameImpl* GetInstance(LiveboxFrame& liveboxFrame); + + virtual ~_LiveboxFrameImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const LiveboxFrame& GetPublic(void) const; + virtual LiveboxFrame& GetPublic(void); + virtual const _LiveboxFrame& GetCore(void) const; + virtual _LiveboxFrame& GetCore(void); + + result Initialize(const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + +protected: + _LiveboxFrameImpl(LiveboxFrame* pPublic, _LiveboxFrame* pCore, const Tizen::Ui::Layout* pPortraitLayout, const Tizen::Ui::Layout* pLandscapeLayout); + +private: + _LiveboxFrameImpl(const _LiveboxFrameImpl& rhs); + _LiveboxFrameImpl& operator =(const _LiveboxFrameImpl& rhs); +}; // _LiveboxFrameImpl + +}} // Tizen::Shell::Ui::Controls + +#endif // _FSHL_INTERNAL_LIVEBOX_FRAME_IMPL_H_ diff --git a/src/FShell_LiveboxFrameModel.cpp b/src/FShell_LiveboxFrameModel.cpp new file mode 100644 index 0000000..3da3977 --- /dev/null +++ b/src/FShell_LiveboxFrameModel.cpp @@ -0,0 +1,50 @@ +// +// 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 FShell_LiveboxFrameModel.cpp + * @brief This is the implementation file for the _LiveboxFrameModel class. + */ + +#include +#include "FShell_LiveboxFrameModel.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Shell +{ + +_LiveboxFrameModel::_LiveboxFrameModel(void) +{ +} + +_LiveboxFrameModel::~_LiveboxFrameModel(void) +{ +} + +void +_LiveboxFrameModel::SetinstanceId(const String& instanceId) +{ + __instanceId = instanceId; +} + +String +_LiveboxFrameModel::GetLiveboxId(void) const +{ + return __instanceId; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxFrameModel.h b/src/FShell_LiveboxFrameModel.h new file mode 100644 index 0000000..1778c5b --- /dev/null +++ b/src/FShell_LiveboxFrameModel.h @@ -0,0 +1,53 @@ +// +// 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 FShell_LiveboxFrameModel.h + * @brief This is the header file for the _LiveboxFrameModel class. + * + * This header file contains the declarations of the %_LiveboxFrameModel class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_FRAME_MODEL_H_ +#define _FSHL_INTERNAL_LIVEBOX_FRAME_MODEL_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class _LiveboxFrameModel + : public Tizen::Base::Object +{ +public: + _LiveboxFrameModel(void); + virtual ~_LiveboxFrameModel(void); + +public: + void SetinstanceId(const Tizen::Base::String& instanceId); + Tizen::Base::String GetLiveboxId(void) const; + +private: + _LiveboxFrameModel(const _LiveboxFrameModel& rhs); + _LiveboxFrameModel& operator =(const _LiveboxFrameModel& rhs); + +private: + Tizen::Base::String __instanceId; +}; // _LiveboxFrameModel + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_FRAME_MODEL_H_ diff --git a/src/FShell_LiveboxFramePresenter.cpp b/src/FShell_LiveboxFramePresenter.cpp new file mode 100644 index 0000000..7ca7cc7 --- /dev/null +++ b/src/FShell_LiveboxFramePresenter.cpp @@ -0,0 +1,67 @@ +// +// 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 FShell_LiveboxFramePresenter.cpp + * @brief This is the implementation file for the _LiveboxFramePresenter class. + */ + +#include +#include +#include "FShell_LiveboxFramePresenter.h" +#include "FShell_LiveboxFrame.h" +#include "FShell_LiveboxFrameModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +_LiveboxFramePresenter::_LiveboxFramePresenter(const _LiveboxFrame& liveboxFrame) + : __pLiveboxFrame(null) + , __pLiveboxFrameModel(new (std::nothrow) _LiveboxFrameModel) +{ + __pLiveboxFrame = const_cast <_LiveboxFrame*>(&liveboxFrame); +} + +_LiveboxFramePresenter::~_LiveboxFramePresenter(void) +{ + __pLiveboxFrame = null; +} + +result +_LiveboxFramePresenter::Initialize(const String& instanceId) +{ + result r = E_SUCCESS; + + __pLiveboxFrameModel->SetinstanceId(instanceId); + + return r; +} + +String +_LiveboxFramePresenter::GetLiveboxId(void) const +{ + return __pLiveboxFrameModel->GetLiveboxId(); +} + +void +_LiveboxFramePresenter::Draw(void) +{ +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxFramePresenter.h b/src/FShell_LiveboxFramePresenter.h new file mode 100644 index 0000000..0a02053 --- /dev/null +++ b/src/FShell_LiveboxFramePresenter.h @@ -0,0 +1,55 @@ +// +// 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 FShell_LiveboxFramePresenter.h + * @brief This is the header file for the _LiveboxFramePresenter class. + * + * This header file contains the declarations of the %_LiveboxFramePresenter class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_FRAME_PRESENTER_H_ +#define _FSHL_INTERNAL_LIVEBOX_FRAME_PRESENTER_H_ + +#include + +namespace Tizen { namespace Shell +{ + +class _LiveboxFrame; +class _LiveboxFrameModel; + +class _LiveboxFramePresenter +{ +public: + _LiveboxFramePresenter(const _LiveboxFrame& liveboxFrame); + virtual ~_LiveboxFramePresenter(void); + + result Initialize(const Tizen::Base::String& instanceId); + Tizen::Base::String GetLiveboxId(void) const; + void Draw(void); + +private: + _LiveboxFramePresenter(const _LiveboxFramePresenter& rhs); + _LiveboxFramePresenter& operator =(const _LiveboxFramePresenter& rhs); + +private: + _LiveboxFrame* __pLiveboxFrame; + std::unique_ptr<_LiveboxFrameModel> __pLiveboxFrameModel; +}; // _LiveboxFramePresenter + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_FRAME_PRESENTER_H_ diff --git a/src/FShell_LiveboxLayer.cpp b/src/FShell_LiveboxLayer.cpp new file mode 100644 index 0000000..374033a --- /dev/null +++ b/src/FShell_LiveboxLayer.cpp @@ -0,0 +1,431 @@ +// +// 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 FShell_LiveboxLayer.cpp + * @brief This is the implementation file for the _LiveboxLayer class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_Window.h" +#include "FShell_LiveboxLayer.h" +#include "FShell_LiveboxManagerImpl.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui; +using namespace Tizen::Shell; + +namespace { + +void* +AllocRenderBuffer(void* pData, int size) +{ + _LiveboxLayer* pLiveboxLayer = static_cast<_LiveboxLayer*>(pData); + SysTryReturn(NID_UI_CTRL, pLiveboxLayer, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + return pLiveboxLayer->AllocCanvas(size); +} + +void +FreeRenderBuffer(void* pData, void* pCanvas) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxLayer* pLiveboxLayer = static_cast<_LiveboxLayer*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxLayer, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + pLiveboxLayer->FreeCanvas(pCanvas); +} + +void +PostRender(void* pData, Evas* pEvas, void* pEventInfo) +{ + _LiveboxLayer* pLiveboxLayer = static_cast<_LiveboxLayer*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxLayer, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + pLiveboxLayer->OnRendered(); +} + +} + +namespace Tizen { namespace Shell { + +_LiveboxLayer::_LiveboxLayer(const Tizen::Base::String& instanceId, const _Window& window) + : __isReleased(false) + , __pEcoreEvas(null) + , __pEvasObject(null) + , __pWindow(&window) + , __pRenderBuffer(null) + , __bufferSize(0) + , __pixmapId(-1) +{ + __instanceId = instanceId; +} + +_LiveboxLayer::~_LiveboxLayer(void) +{ + if (__pEvasObject) + { + evas_object_del(__pEvasObject); + __pEvasObject = null; + } + + if (__pEcoreEvas) + { + ecore_evas_free(__pEcoreEvas); + __pEcoreEvas = null; + } + + __pWindow = null; + __pRenderBuffer = null; + __pixmapId = -1; +} + +result +_LiveboxLayer::OnConstructed(void) +{ + result r = E_SUCCESS; + + Rectangle bounds = __pWindow->GetBounds(); + + __pEcoreEvas = ecore_evas_buffer_allocfunc_new(bounds.width, bounds.height, AllocRenderBuffer, FreeRenderBuffer, this); + SysTryReturn(NID_UI_CTRL, __pEcoreEvas, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + ecore_evas_alpha_set(__pEcoreEvas, EINA_TRUE); + ecore_evas_manual_render_set(__pEcoreEvas, EINA_FALSE); + ecore_evas_resize(__pEcoreEvas, bounds.width, bounds.height); +// ecore_evas_show(__pEcoreEvas); + ecore_evas_activate(__pEcoreEvas); + + Evas* pEvas = ecore_evas_get(__pEcoreEvas); + SysTryCatch(NID_UI_CTRL, pEvas, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + evas_event_callback_add(pEvas, EVAS_CALLBACK_RENDER_FLUSH_POST, PostRender, this); + + __pEvasObject = evas_object_rectangle_add(pEvas); + SysTryCatch(NID_UI_CTRL, __pEvasObject, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + evas_object_resize(__pEvasObject, bounds.width, bounds.height); + evas_object_color_set(__pEvasObject, 0, 0, 0, 255); + + r = Initialize(__pEvasObject); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + r = RegisterTouchEventListener(); + SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; + +CATCH: + if (__pEvasObject) + { + evas_object_del(__pEvasObject); + __pEvasObject = null; + } + + if (__pEcoreEvas) + { + ecore_evas_free(__pEcoreEvas); + __pEcoreEvas = null; + } + + return r; +} + +const Tizen::Ui::_Window* +_LiveboxLayer::GetWindow(void) const +{ + return __pWindow; +} + +String +_LiveboxLayer::GetLiveboxId(void) const +{ + return __instanceId; +} + +int +_LiveboxLayer::GetPixmapId(void) const +{ + return __pixmapId; +} + +void +_LiveboxLayer::SetLayerBounds(const Rectangle& bounds) +{ + ecore_evas_resize(__pEcoreEvas, bounds.width, bounds.height); + + FloatRectangle fBounds(static_cast(bounds.x), static_cast(bounds.y), static_cast(bounds.width), static_cast(bounds.height)); + SetBounds(fBounds); +} + +void* +_LiveboxLayer::AllocCanvas(int size) +{ + SysTryReturn(NID_UI_CTRL, size > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __bufferSize = size; + void* pBuffer = malloc(__bufferSize); + SysTryReturn(NID_UI_CTRL, pBuffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pRenderBuffer = pBuffer; + + __pixmapId = AcquirePixmap(); + SysTryCatch(NID_UI_CTRL, __pixmapId != -1, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SysLog(NID_UI_CTRL, "buffer (0x%x) size (%d) pixmapId (%d)", pBuffer, __bufferSize, __pixmapId); + + __isReleased = false; + + return __pRenderBuffer; + +CATCH: + + if (__pRenderBuffer) + { + free(__pRenderBuffer); + __pRenderBuffer = null; + } + + return null; +} + +void +_LiveboxLayer::FreeCanvas(void* pCanvas) +{ + if (!__isReleased) + { + ReleasePixmap(); + __isReleased = true; + } + + if (pCanvas) + { + free(pCanvas); + } + + __pixmapId = -1; + __pRenderBuffer = null; +} + +result +_LiveboxLayer::SyncPixmap(const Tizen::Graphics::Rectangle& bounds) +{ + SysTryReturn(NID_UI_CTRL, __pRenderBuffer, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + SysLog(NID_UI_CTRL, "buffer (0x%x) size (%d) pixmapId (%d)", __pRenderBuffer, __bufferSize, __pixmapId); + + Display* pDisplay = static_cast(ecore_x_display_get()); + SysTryReturn(NID_UI_CTRL, pDisplay, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = E_SUCCESS; + XShmSegmentInfo xShmSegmentInfo; + XImage* pXImage = null; + GC gc; + Screen* pScreen = null; + Visual* pVisual = null; + + /*const int bitsPerPixel = 32; + int __bufferSize = bounds.width * bounds.height * bitsPerPixel / 8;*/ + + xShmSegmentInfo.shmid = shmget(IPC_PRIVATE, __bufferSize, IPC_CREAT | 0666); + SysTryReturn(NID_UI_CTRL, xShmSegmentInfo.shmid >= 0, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + xShmSegmentInfo.readOnly = False; + xShmSegmentInfo.shmaddr = static_cast(shmat(xShmSegmentInfo.shmid, null, 0)); + SysTryCatch(NID_UI_CTRL, xShmSegmentInfo.shmaddr != (void *)-1, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pScreen = DefaultScreenOfDisplay(pDisplay); + SysTryCatch(NID_UI_CTRL, pScreen, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pVisual = DefaultVisualOfScreen(pScreen); + SysTryCatch(NID_UI_CTRL, pVisual, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + // XCreatePixmap can only uses 24 bits depth only. + pXImage = XShmCreateImage(pDisplay, pVisual, 24, ZPixmap, null, &xShmSegmentInfo, bounds.width, bounds.height); + SysTryCatch(NID_UI_CTRL, pXImage, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pXImage->data = xShmSegmentInfo.shmaddr; + XShmAttach(pDisplay, &xShmSegmentInfo); + XSync(pDisplay, False); + + gc = XCreateGC(pDisplay, static_cast(__pixmapId), 0, null); + SysTryCatch(NID_UI_CTRL, gc, , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + memcpy(pXImage->data, __pRenderBuffer, __bufferSize); + + // Do not send the event. Instead of X event, master will send the updated event to the viewer + XShmPutImage(pDisplay, static_cast(__pixmapId), gc, pXImage, 0, 0, 0, 0, bounds.width, bounds.height, False); + XSync(pDisplay, False); + + XFreeGC(pDisplay, gc); + XShmDetach(pDisplay, &xShmSegmentInfo); + XDestroyImage(pXImage); + + if (xShmSegmentInfo.shmaddr != (void *)-1) + { + shmdt(xShmSegmentInfo.shmaddr); + } + + if (xShmSegmentInfo.shmid >= 0) + { + shmctl(xShmSegmentInfo.shmid, IPC_RMID, 0); + } + + return r; + +CATCH: + + if (pDisplay) + { + XShmDetach(pDisplay, &xShmSegmentInfo); + } + + if (pXImage) + { + XDestroyImage(pXImage); + } + + if (xShmSegmentInfo.shmaddr != (void *)-1) + { + shmdt(xShmSegmentInfo.shmaddr); + } + + if (xShmSegmentInfo.shmid >= 0) + { + shmctl(xShmSegmentInfo.shmid, IPC_RMID, 0); + } + + return E_OUT_OF_MEMORY; +} + +void +_LiveboxLayer::OnRendered(void) +{ + Rectangle bounds = __pWindow->GetBounds(); + + if (__pixmapId == -1) + { + __pixmapId = AcquirePixmap(); + SysTryReturnVoidResult(NID_UI_CTRL, __pixmapId >= 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + } + + result r = SyncPixmap(bounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = Sync(bounds); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +result +_LiveboxLayer::RegisterTouchEventListener(void) +{ + result r = _LiveboxManagerImpl::GetInstance()->SetLiveboxTouchEventListener(__instanceId, *this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +_LiveboxLayer::AcquirePixmap(void) +{ + int pixmapId = -1; + + const _Window* pWindow = GetWindow(); + SysTryReturn(NID_UI_CTRL, pWindow, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + Rectangle bounds = pWindow->GetBounds(); + + result r = _LiveboxManagerImpl::GetInstance()->RequestSharedMemoryId(__instanceId, bounds.width, bounds.height, pixmapId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI_CTRL, "pixmapId(%d) bounds(%d %d %d %d)", pixmapId, bounds.x, bounds.y, bounds.width, bounds.height); + + return pixmapId; +} + +result +_LiveboxLayer::Sync(const Tizen::Graphics::Rectangle& bounds) +{ + result r = _LiveboxManagerImpl::GetInstance()->RequestSyncSharedMemory(__instanceId, bounds.width, bounds.height); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_LiveboxLayer::ReleasePixmap(void) +{ + _LiveboxManagerImpl::GetInstance()->RequestReleaseSharedMemory(__instanceId); +} + +int +_LiveboxLayer::OnTouchEventRecevied(int eventType, double timestamp, double x, double y) +{ + Rectangle bounds = __pWindow->GetBounds(); + + int xPos = bounds.width * x; + int yPos = bounds.height * y; + + Evas* pEvas = ecore_evas_get(__pEcoreEvas); + SysTryReturn(NID_UI_CTRL, pEvas, 0, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + switch (eventType) + { + case BUFFER_EVENT_ENTER: + evas_event_feed_mouse_in(pEvas, timestamp, null); + break; + + case BUFFER_EVENT_LEAVE: + evas_event_feed_mouse_out(pEvas, timestamp, null); + break; + + case BUFFER_EVENT_DOWN: + evas_event_feed_mouse_in(pEvas, timestamp, null); + evas_event_feed_mouse_move(pEvas, xPos, yPos, timestamp + 0.01f, null); + evas_event_feed_mouse_down(pEvas, 1, EVAS_BUTTON_NONE, timestamp + 0.02f, null); + break; + + case BUFFER_EVENT_MOVE: + evas_event_feed_mouse_move(pEvas, xPos, yPos, timestamp, null); + break; + + case BUFFER_EVENT_UP: + evas_event_feed_mouse_up(pEvas, 1, EVAS_BUTTON_NONE, timestamp, null); + evas_event_feed_mouse_out(pEvas, timestamp + 0.01f, null); + break; + + default: + break; + } + + return 0; +} + + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxLayer.h b/src/FShell_LiveboxLayer.h new file mode 100644 index 0000000..d34032e --- /dev/null +++ b/src/FShell_LiveboxLayer.h @@ -0,0 +1,89 @@ +// +// 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 FShell_LiveboxFrame.h + * @brief This is the header file for the _LiveboxLayer class. + * + * This header file contains the declarations of the %_LiveboxLayer class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_LAYER_H_ +#define _FSHL_INTERNAL_LIVEBOX_LAYER_H_ + +#include +#include +#include "FUiAnim_EflLayer.h" +#include "FShell_ILiveboxTouchEventListener.h" + +namespace Tizen { namespace Ui +{ +class _Window; +}} // Tizen::Ui + +namespace Tizen { namespace Shell +{ + +/** + * @class _LiveboxLayer + * @brief + * @since 2.1 + */ +class _LiveboxLayer + : public Tizen::Ui::Animations::_EflLayer + , public Tizen::Shell::_ILiveboxTouchEventListener +{ +public: + _LiveboxLayer(const Tizen::Base::String& instanceId, const Tizen::Ui::_Window& window); + virtual ~_LiveboxLayer(void); + + virtual result OnConstructed(void); + + const Tizen::Ui::_Window* GetWindow(void) const; + Tizen::Base::String GetLiveboxId(void) const; + int GetPixmapId(void) const; + void SetLayerBounds(const Tizen::Graphics::Rectangle& bounds); + void* AllocCanvas(int size); + void FreeCanvas(void* pCanvas); + int EventHandler(int eventType, double timestamp, double x, double y); + result SyncPixmap(const Tizen::Graphics::Rectangle& bounds); + void OnRendered(void); + + virtual result RegisterTouchEventListener(void); + virtual int AcquirePixmap(void); + virtual result Sync(const Tizen::Graphics::Rectangle& bounds); + virtual void ReleasePixmap(void); + virtual int OnTouchEventRecevied(int eventType, double timestamp, double x, double y); + +private: + _LiveboxLayer(const _LiveboxLayer& rhs); + _LiveboxLayer& operator =(const _LiveboxLayer& rhs); + +protected: + bool __isReleased; + +private: + Ecore_Evas* __pEcoreEvas; + Evas_Object* __pEvasObject; + const Tizen::Ui::_Window* __pWindow; + Tizen::Base::String __instanceId; + void* __pRenderBuffer; + int __bufferSize; + int __pixmapId; +}; + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_LAYER_H_ diff --git a/src/FShell_LiveboxManagerImpl.cpp b/src/FShell_LiveboxManagerImpl.cpp new file mode 100644 index 0000000..b84bf7d --- /dev/null +++ b/src/FShell_LiveboxManagerImpl.cpp @@ -0,0 +1,678 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxManagerImpl.cpp + * @brief This is the implementation for the _LiveboxManagerImpl class. + */ + +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include "FShell_LiveboxManagerProxy.h" +#include "FShell_LiveboxManagerImpl.h" + +#include "FShell_LiveboxProviderInfoImpl.h" + +namespace Tizen { namespace Shell +{ + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; +using namespace Tizen::Graphics; + + +namespace +{ +const char LIVEBOX_ON_ADD[] = "Livebox='event=add'"; +const char LIVEBOX_ON_REMOVE[] = "Livebox='event=remove'"; +const char LIVEBOX_ON_UPDATE[] = "Livebox='event=update'"; +const char LIVEBOX_ON_RESIZE[] = "Livebox='event=resize'"; +const char LIVEBOX_ON_TOUCH[] = "Livebox='event=touch'"; +const char LIVEBOX_TRAY_ON_CREATE[] = "LiveboxTray='event=create'"; +const char LIVEBOX_TRAY_ON_DESTROY[] = "LiveboxTray='event=destroy'"; +const char LIVEBOX_TRAY_ON_TOUCH[] = "LiveboxTray='event=touch'"; +} + +_LiveboxManagerImpl::_LiveboxManagerImpl() + :__pLiveboxFactory(null) + ,__pLiveboxPopupProviderFactory(null) + ,__pLiveboxPopupProvider(null) + ,__LiveboxPopupTouchEventListener(null) + ,__messageReceived(false) +{ + SysLog(NID_APP, ""); +} + +_LiveboxManagerImpl::~_LiveboxManagerImpl() +{ + SysLog(NID_APP, ""); + livebox_service_fini(); +} + + +_LiveboxManagerImpl* +_LiveboxManagerImpl::GetInstance() +{ + static _LiveboxManagerImpl* __pLiveboxManagerImpl = null; + if( __pLiveboxManagerImpl == null) + { + __pLiveboxManagerImpl = new (std::nothrow)_LiveboxManagerImpl; + SysTryReturn(NID_APP, __pLiveboxManagerImpl, null, E_OUT_OF_MEMORY, "Allocating new _LiveboxManagerProxy failed."); + + result r = __pLiveboxManagerImpl->Construct(); + SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return __pLiveboxManagerImpl; +} + +result +_LiveboxManagerImpl::Construct() +{ + SysLog(NID_APP, "Enter."); + + __liveBoxes.Construct(); + __touchEventListeners.Construct(); + + int ret = livebox_service_init(); + SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "[E_SYSTEM] Failed to invoke livebox_service_init, ret (%d)", ret); + + Tizen::App::_AppImpl::GetInstance()->SetAppControlProviderInternalEventListener(this); + + SysLog(NID_APP, "Exit."); + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::SetLiveboxProviderFactory(ILiveboxProviderFactory& factory) +{ + __pLiveboxFactory = &factory; + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::SetLiveboxPopupProviderFactory(ILiveboxPopupProviderFactory& factory) +{ + __pLiveboxPopupProviderFactory = &factory; + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::SetLiveboxTouchEventListener(const String& instanceId, _ILiveboxTouchEventListener& listener) +{ + return __touchEventListeners.Add(instanceId, &listener); +} + +result +_LiveboxManagerImpl::SetLiveboxPopupEventListener(_ILiveboxTouchEventListener& listener) +{ + __LiveboxPopupTouchEventListener = &listener; + + return E_SUCCESS; +} + +// c style callback for livebox_service_get_pkglist +int GetLiveboxProviderInfoCallback(const char *packageId, const char *pProviderId, int is_prime, void *data) +{ + SysLog(NID_APP, "%s, %s", packageId, pProviderId); + + IList* pLiveboxProviderInfos = static_cast(data); + SysTryReturn(NID_APP, pLiveboxProviderInfos, 0, E_SYSTEM, "[E_SYSTEM] system error."); + + String providerId(pProviderId); + + String appId; + String name; + + if( providerId.StartsWith("com.samsung", 0) == true)// for core livebox (plugin) + { + appId = providerId; + name = L""; + } + else + { + /*int index = 0; + providerId.IndexOf(".", 11, index); + providerId.SubString(0, index, appId); + providerId.SubString(index+1, name);*/ + _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, appId, name); + } + + LiveboxProviderInfo* pInfo = new LiveboxProviderInfo(appId, name); + pLiveboxProviderInfos->Add(*pInfo); + _LiveboxProviderInfoImpl::GetImpl(*pInfo)->__isDefault = is_prime; + + return 0; +} + +int GetConfigurableLiveboxInfosCallback(const char* pConfigurationAppControlAppId, const char* pIcon, const char* pDisplayName, const char* pExtraKey, const char* pExtraData, void* data) +{ +// SysLog(NID_APP, "pConfigurationAppControlAppId(%s), pDisplayName(%s)", pConfigurationAppControlAppId, pDisplayName); + + String configurationAppControlAppId(pConfigurationAppControlAppId); + IList* pLiveboxProviderInfos = static_cast(data); + SysTryReturn(NID_APP, pLiveboxProviderInfos, 0, E_SYSTEM, "[E_SYSTEM] system error."); + + for(int i = 0; i < pLiveboxProviderInfos->GetCount(); i ++ ) + { + LiveboxProviderInfo* pProviderInfo = (LiveboxProviderInfo*)pLiveboxProviderInfos->GetAt(i); + SysAssert(pProviderInfo); + + String shortcutPackageId; + configurationAppControlAppId.SubString(0, 10, shortcutPackageId); + + String liveboxPackageId; + pProviderInfo->GetAppId().SubString(0, 10, liveboxPackageId); + + if( shortcutPackageId == liveboxPackageId) + { + _LiveboxProviderInfoImpl::GetImpl(*pProviderInfo)->__configurationAppControlAppId = configurationAppControlAppId; + _LiveboxProviderInfoImpl::GetImpl(*pProviderInfo)->__displayName = pDisplayName; + SysLog(NID_APP, "pConfigurationAppControlAppId(%s), pDisplayName(%s), pExtraKey(%s), pExtraData(%s)", pConfigurationAppControlAppId, pDisplayName, pExtraKey, pExtraData); + break; + } + } + + return 0; +} + +Tizen::Base::Collection::IList* +_LiveboxManagerImpl::GetLiveboxProviderInfosN() +{ + std::unique_ptr pLiveboxProviders(new ArrayList()); + SysTryReturn(NID_APP, pLiveboxProviders.get(), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory"); + + pLiveboxProviders->Construct(); + int ret = livebox_service_get_pkglist(GetLiveboxProviderInfoCallback, pLiveboxProviders.get()); + SysTryReturn(NID_APP, ret >= 0, null, E_SYSTEM, "[E_SYSTEM] Failed to invoke livebox_service_get_pkglist, ret (%d)", ret); + + ret = shortcut_get_list(null, GetConfigurableLiveboxInfosCallback, pLiveboxProviders.get()); + SysTryReturn(NID_APP, ret >= 0, null, E_SYSTEM, "[E_SYSTEM] Failed to invoke shortcut_get_list, ret (%d)", ret); + + return pLiveboxProviders.release(); +} + +LiveboxProviderInfo* +_LiveboxManagerImpl::GetLiveboxProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) +{ + return new LiveboxProviderInfo(appId, providerName); +} + + +result +_LiveboxManagerImpl::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) +{ + + _LiveboxManagerProxy::GetInstance()->RequestUpdate(appId, providerName); + return E_SUCCESS; +} + +bool +_LiveboxManagerImpl::ContainsLivebox(const String& instanceId) const +{ + bool isCreated = false; + __liveBoxes.ContainsKey(instanceId, isCreated); + + return isCreated; +} + +void +_LiveboxManagerImpl::TerminateAppIfInvalidState() +{ + if( __messageReceived == false ) + { + Tizen::App::App::GetInstance()->Terminate(); + } +} + +void +_LiveboxManagerImpl::OnAppControlRequestReceivedN(RequestId reqId, const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::String& category, const Tizen::Base::String* pDataType, const Tizen::Base::String* pUriScheme, Tizen::Base::Collection::IList* pArgs) +{ + if( pArgs == null && pArgs->GetCount() == 0) + { + SysAssertf(pArgs, "[E_SYSTEN] pArgs should not be null."); + return; + } + __messageReceived = true; + + SysLog(NID_APP, "operationId(%ls), argc(%d)", operationId.GetPointer(), pArgs->GetCount()); + + String *pInstanceId = dynamic_cast(pArgs->GetAt(0)); + SysTryReturnVoidResult(NID_APP, pInstanceId, E_FAILURE, "[E_FAILURE] pId is null."); + + String *pName = dynamic_cast(pArgs->GetAt(1)); + SysTryReturnVoidResult(NID_APP, pInstanceId, E_FAILURE, "[E_FAILURE] pName is null"); + + String *pParam = dynamic_cast(pArgs->GetAt(2)); + SysTryReturnVoidResult(NID_APP, pParam, E_FAILURE, "[E_FAILURE] pParam is null"); + + SysLog(NID_APP, "id(%ls), name(%ls), param(%ls)", pInstanceId->GetPointer(), pName->GetPointer(), pParam->GetPointer()); + + if(this->ContainsLivebox(*pInstanceId) == false) + { + SysLog(NID_APP, "no livebox instance, creating.."); + + int width = 0; + int height = 0; + String* pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnVoidResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, width); + + pValue = dynamic_cast(pArgs->GetAt(4)); + SysTryReturnVoidResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, height); + + this->CreateLivebox( *pName, *pInstanceId, width, height, null); + + if( operationId == LIVEBOX_ON_RESIZE) + { + SysLog(NID_APP, "operation is resize, but livebox is already recreated with new size, so OnSize won't be called."); + return; + } + } + + if( operationId.StartsWith(L"LiveboxTray", 0) == true) + { + SysTryReturnVoidResult(NID_APP, __pLiveboxPopupProviderFactory, E_FAILURE, "[E_FAILURE] __pLiveboxPopupProviderFactory is null"); + HandleLiveboxPopupRequest(operationId, pArgs); + } + else + { + SysTryReturnVoidResult(NID_APP, __pLiveboxFactory, E_FAILURE, "[E_FAILURE] __pLiveboxFactory is null"); + HandleLiveboxRequest(operationId, pArgs); + } + SysLog(NID_APP, "Exit"); +} + +result +_LiveboxManagerImpl::HandleLiveboxRequest(const Tizen::Base::String& operationId, Tizen::Base::Collection::IList* pArgs) +{ + if( pArgs == null && pArgs->GetCount() < 3) + { + SysAssertf(pArgs, "[E_SYSTEN] pArgs should not be null."); + return E_SYSTEM; + } + + SysLog(NID_APP, "operationId(%ls), argc(%d)", operationId.GetPointer(), pArgs->GetCount()); + + String *pInstanceId = dynamic_cast(pArgs->GetAt(0)); + SysTryReturnResult(NID_APP, pInstanceId, E_FAILURE, "[E_FAILURE] pId is null."); + + /*String *pName = dynamic_cast(pArgs->GetAt(1)); + SysTryReturnResult(NID_APP, pInstanceId, E_FAILURE, "[E_FAILURE] pName is null"); + + String *pParam = dynamic_cast(pArgs->GetAt(2)); + SysTryReturnResult(NID_APP, pParam, E_FAILURE, "[E_FAILURE] pName is null"); + + SysLog(NID_APP, "id(%ls), name(%d)", pInstanceId->GetPointer(), pName->GetPointer());*/ + + /*if( operationId == LIVEBOX_ON_ADD ) + { + int w = 0; + int h = 0; + String* pValue = dynamic_cast(pArgs->GetAt(2)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, w); + + pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, h); + + this->__pLiveboxEventListener->OnLiveboxAdded(*pId, width, height, pArgs); + }*/ + + if (operationId == LIVEBOX_ON_RESIZE) + { + int width = 0; + int height = 0; + String* pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, width); + + pValue = dynamic_cast(pArgs->GetAt(4)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, height); + + this->ResizeLivebox(*pInstanceId, width, height); + } + else if (operationId == LIVEBOX_ON_UPDATE) + { + int width = 0; + int height = 0; + String* pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE], "); + Integer::Parse(*pValue, width); + + pValue = dynamic_cast(pArgs->GetAt(4)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, height); + + this->UpdateLivebox(*pInstanceId, width, height); + } + else if (operationId == LIVEBOX_ON_REMOVE) + { + this->RemoveLivebox(*pInstanceId); + } + else if (operationId == LIVEBOX_ON_TOUCH) + { + SysAssertf(pArgs->GetCount() == 7, "invalid argc(%d)", pArgs->GetCount() ); + + int eventType = 0; + double timeStamp = 0.0f; + double x = 0.0f; + double y = 0.0f; + + String* pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, eventType); + + pValue = dynamic_cast(pArgs->GetAt(4)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Double::Parse(*pValue, timeStamp); + + pValue = dynamic_cast(pArgs->GetAt(5)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Double::Parse(*pValue, x); + + pValue = dynamic_cast(pArgs->GetAt(6)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Double::Parse(*pValue, y); + + this->ForwardTouchEvent(*pInstanceId, eventType, timeStamp, x, y); + } + SysLog(NID_APP, "Exit"); + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::HandleLiveboxPopupRequest(const Tizen::Base::String& operationId, Tizen::Base::Collection::IList* pArgs) +{ + SysTryReturnResult(NID_APP, __pLiveboxPopupProviderFactory, E_FAILURE, "[E_FAILURE] __pLiveboxPopupProviderFactory is null"); + if( pArgs == null && pArgs->GetCount() < 3) + { + SysAssertf(pArgs, "[E_SYSTEN] pArgs should not be null."); + return E_SYSTEM; + } + + String *pInstanceId = dynamic_cast(pArgs->GetAt(0)); + SysTryReturnResult(NID_APP, pInstanceId, E_FAILURE, "[E_FAILURE] pId is null."); + + /*String *pName = dynamic_cast(pArgs->GetAt(1)); + SysTryReturnResult(NID_APP, pInstanceId, E_FAILURE, "[E_FAILURE] pName is null"); + + String *pParam = dynamic_cast(pArgs->GetAt(2)); + SysTryReturnResult(NID_APP, pParam, E_FAILURE, "[E_FAILURE] pName is null"); + + SysLog(NID_APP, "id(%ls), name(%d)", pInstanceId->GetPointer(), pName->GetPointer());*/ + + if (operationId == LIVEBOX_TRAY_ON_CREATE) + { + int width = 0; + int height = 0; + + String* pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, width); + + pValue = dynamic_cast(pArgs->GetAt(4)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, height); + + this->CreateLiveboxPopupProvider(*pInstanceId); + return E_SUCCESS; + } + else if (operationId == LIVEBOX_TRAY_ON_DESTROY) + { + this->DestroyLiveboxPopupProvider(*pInstanceId); + return E_SUCCESS; + } + else if (operationId == LIVEBOX_TRAY_ON_TOUCH) + { + SysAssertf(pArgs->GetCount() == 6, "invalid argc(%d)", pArgs->GetCount() ); + + int eventType = 0; + double timeStamp = 0.0f; + double x = 0.0f; + double y = 0.0f; + + String* pValue = dynamic_cast(pArgs->GetAt(2)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Integer::Parse(*pValue, eventType); + + pValue = dynamic_cast(pArgs->GetAt(3)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Double::Parse(*pValue, timeStamp); + + pValue = dynamic_cast(pArgs->GetAt(4)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Double::Parse(*pValue, x); + + pValue = dynamic_cast(pArgs->GetAt(5)); + SysTryReturnResult(NID_APP, pValue, E_FAILURE, "[E_FAILURE]"); + Double::Parse(*pValue, y); + + ForwardTouchEventForPD(*pInstanceId, eventType, timeStamp, x, y); + } + else + { + SysLog(NID_APP, "unexpected case(%ls)", operationId.GetPointer() ); + } + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::CreateLivebox(const String& name, const String& instanceId, int width, int height, const String& userInfo) +{ + SysLog(NID_APP, "instanceId(%ls), w:%d, h:%d", instanceId.GetPointer(), width, height); + SysTryReturnResult(NID_APP, __pLiveboxFactory, E_FAILURE, "[E_INVALID_OPERATION] __pLiveboxFactory should not be null"); + + LiveboxProvider* pLivebox = __pLiveboxFactory->CreateInstance(name, width, height, userInfo); + SysTryReturnResult(NID_APP, pLivebox, E_INVALID_OPERATION, "[E_INVALID_OPERATION]"); + + pLivebox->Construct(instanceId); + __liveBoxes.Add(instanceId, pLivebox); + + pLivebox->OnLiveboxProviderInitializing(width, height, userInfo); + + SysTryReturnResult(NID_APP, pLivebox->GetLiveboxFrame(), E_INVALID_OPERATION, "[E_INVALID_OPERATION]"); + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::UpdateLivebox(const String& instanceId, int width, int height) +{ + SysLog(NID_APP, "instanceId(%ls), w:%d, h:%d", instanceId.GetPointer(), width, height); + + LiveboxProvider* pLivebox = null; + __liveBoxes.GetValue(instanceId, pLivebox); + SysTryReturnResult(NID_APP, pLivebox, E_INVALID_OPERATION, "[E_INVALID_OPERATION]"); + + pLivebox->OnLiveboxProviderUpdating(L""); + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::ResizeLivebox(const String& instanceId, int width, int height) +{ + SysLog(NID_APP, "instanceId(%ls), w:%d, h:%d", instanceId.GetPointer(), width, height); + + LiveboxProvider* pLivebox = null; + __liveBoxes.GetValue(instanceId, pLivebox); + SysTryReturnResult(NID_APP, pLivebox, E_SYSTEM, "[E_SYSTEM]"); + + LiveboxFrame* pLiveBoxFrame = pLivebox->GetLiveboxFrame(); + SysTryReturnResult(NID_APP, pLiveBoxFrame, E_INVALID_STATE, "[E_INVALID_STATE]"); + + return pLiveBoxFrame->SetSize(Dimension(width, height)); +} + +result +_LiveboxManagerImpl::RemoveLivebox(const String& instanceId) +{ + SysLog(NID_APP, "instanceId(%ls)", instanceId.GetPointer() ); +// __pLiveboxEventListener->OnLiveboxRemoved(instanceId); + + LiveboxProvider* pLivebox = null; + __liveBoxes.GetValue(instanceId, pLivebox); + __liveBoxes.Remove(instanceId); + if( pLivebox != null) + { + delete pLivebox; + } + +// this->__pLiveboxEventListener->OnLiveboxRemoved(instanceId); + if( this->__liveBoxes.GetCount() == 0) + { + Tizen::App::App::GetInstance()->Terminate(); + } + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::CreateLiveboxPopupProvider(const String& instanceId) +{ + SysLog(NID_APP, "instanceId(%ls)", instanceId.GetPointer()); + SysTryReturnResult(NID_APP, __pLiveboxPopupProviderFactory, E_FAILURE, "[E_INVALID_OPERATION] __pLiveboxPopupProviderFactory should not be null"); + + LiveboxProvider* pLivebox = null; + __liveBoxes.GetValue(instanceId, pLivebox); + SysTryReturnResult(NID_APP, pLivebox, E_INVALID_OPERATION, "[E_INVALID_OPERATION]"); + + LiveboxPopupProvider* pPd = __pLiveboxPopupProviderFactory->CreateInstance(L"test", L""); + __pLiveboxPopupProvider = pPd; + + __pLiveboxPopupProvider->Construct(instanceId); + __pLiveboxPopupProvider->OnLiveboxPopupProviderInitializing(L""); + + LiveboxPopup* pLiveBoxFrame = pPd->GetLiveboxPopup(); + SysTryReturnResult(NID_APP, pLiveBoxFrame, E_INVALID_OPERATION, "[E_INVALID_OPERATION]"); + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::DestroyLiveboxPopupProvider(const String& instanceId) +{ + SysLog(NID_APP, "instanceId(%ls)", instanceId.GetPointer()); + + if( __pLiveboxPopupProvider != null) + { + __pLiveboxPopupProvider->OnLiveboxPopupProviderTerminating(); + delete __pLiveboxPopupProvider; + __pLiveboxPopupProvider = null; + } + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::ForwardTouchEvent(const String& instanceId, int eventType, double timeStamp, double x, double y) +{ + SysLog(NID_APP, "instanceId(%ls), eventType(%d), timeStamp(%f), x(%f), y(%f)", instanceId.GetPointer(), eventType, timeStamp, x, y); + + _ILiveboxTouchEventListener* pTouchEventListener = null; + __touchEventListeners.GetValue(instanceId, pTouchEventListener); + SysTryReturnResult(NID_APP, pTouchEventListener, E_INVALID_STATE, "[E_INVALID_STATE]"); + + pTouchEventListener->OnTouchEventRecevied(eventType, timeStamp, x, y); + + return E_SUCCESS; +} + +result +_LiveboxManagerImpl::ForwardTouchEventForPD(const String& instanceId, int eventType, double timeStamp, double x, double y) +{ + SysTryReturnResult(NID_APP, __LiveboxPopupTouchEventListener, E_INVALID_STATE, "[E_INVALID_STATE]"); + __LiveboxPopupTouchEventListener->OnTouchEventRecevied(eventType, timeStamp, x, y); + + return E_SUCCESS; +} +////////////////////////////////////////////////////////////////////////// +// buffer APIs +////////////////////////////////////////////////////////////////////////// + +result +_LiveboxManagerImpl::RequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int& shmId) +{ + return _LiveboxManagerProxy::GetInstance()->RequestSharedMemoryId(instanceId, width, height, shmId); +} + +result +_LiveboxManagerImpl::RequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int& shmId) +{ + return _LiveboxManagerProxy::GetInstance()->RequestSharedMemoryIdForPD(instanceId, width, height, shmId); +} + +result +_LiveboxManagerImpl::RequestReleaseSharedMemory(const Tizen::Base::String& instanceId) +{ + return _LiveboxManagerProxy::GetInstance()->RequestReleaseSharedMemory(instanceId); +} + +result +_LiveboxManagerImpl::RequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId) +{ + return _LiveboxManagerProxy::GetInstance()->RequestReleaseSharedMemoryForPD(instanceId); +} + +result +_LiveboxManagerImpl::RequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height) +{ + return _LiveboxManagerProxy::GetInstance()->RequestSyncSharedMemory(instanceId, width, height); +} + +result +_LiveboxManagerImpl::RequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId) +{ + return _LiveboxManagerProxy::GetInstance()->RequestSyncSharedMemoryForPD(instanceId); +} + +// helper + +result +_LiveboxManagerImpl::ExtractAppIdAndProviderName(const Tizen::Base::String& providerId, Tizen::App::AppId& appId, Tizen::Base::String& providerName) +{ + int index = 0; + + providerId.IndexOf(".", 11, index); + providerId.SubString(0, index, appId); + providerId.SubString(index+1, providerName); + + return E_SUCCESS; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxManagerIpcMessage.cpp b/src/FShell_LiveboxManagerIpcMessage.cpp new file mode 100644 index 0000000..a0d2e5d --- /dev/null +++ b/src/FShell_LiveboxManagerIpcMessage.cpp @@ -0,0 +1,41 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxManagerIpcMessage.cpp + * @brief This file contains IPC message class generated by macros. + */ + +#define IPC_MESSAGE_IMPL +#include "FShell_LiveboxManagerIpcMessage.h" + +// Generate constructors. +#include "ipc/struct_constructor_macros.h" +#include "FShell_LiveboxManagerIpcMessage.h" +// Generate destructors. + +#include "ipc/struct_destructor_macros.h" +#include "FShell_LiveboxManagerIpcMessage.h" + +// Generate param traits write methods. +#include "ipc/param_traits_write_macros.h" +namespace IPC +{ +#include "FShell_LiveboxManagerIpcMessage.h" +} // namespace IPC + +// Generate param traits read methods. +#include "ipc/param_traits_read_macros.h" +namespace IPC +{ +#include "FShell_LiveboxManagerIpcMessage.h" +} // namespace IPC diff --git a/src/FShell_LiveboxManagerProxy.cpp b/src/FShell_LiveboxManagerProxy.cpp new file mode 100644 index 0000000..96618bd --- /dev/null +++ b/src/FShell_LiveboxManagerProxy.cpp @@ -0,0 +1,204 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxManagerProxy.cpp + * @brief This is the implementation for the _LiveboxManagerProxy class. + */ + +#include +#include +#include "FShell_LiveboxManagerImpl.h" +#include "FShell_LiveboxManagerProxy.h" + +namespace Tizen { namespace Shell { + +namespace +{ +const char IPC_SERVER_NAME[] = "osp.shell.ipcserver.liveboxmanager"; +}; + +using namespace Tizen::Io; + + +_LiveboxManagerProxy::_LiveboxManagerProxy() + : __pIpcClient(null) +{ + SysLog(NID_APP, ""); +} + +_LiveboxManagerProxy::~_LiveboxManagerProxy() +{ + delete __pIpcClient; +} + +_LiveboxManagerProxy* +_LiveboxManagerProxy::GetInstance() +{ + static std::unique_ptr<_LiveboxManagerProxy> __pLiveboxProxy(null); + if( __pLiveboxProxy.get() == null) + { + std::unique_ptr<_LiveboxManagerProxy> pLiveboxProxy(new (std::nothrow)_LiveboxManagerProxy); + SysTryReturn(NID_APP, pLiveboxProxy.get(), null, E_OUT_OF_MEMORY, "Allocating new _LiveboxManagerProxy failed!"); + + result r = pLiveboxProxy->Construct(); + SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxProxy = std::move(pLiveboxProxy); + } + + return __pLiveboxProxy.get(); +} + +result +_LiveboxManagerProxy::Construct(void) +{ + SysLog(NID_APP, "Enter."); + + __pIpcClient = new (std::nothrow) _IpcClient(); + SysTryReturnResult(NID_APP, __pIpcClient != null, E_OUT_OF_MEMORY, "_IpcClient creation failed."); + + result r = __pIpcClient->Construct(IPC_SERVER_NAME, this); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "_IpcClient constructing faliied [%s].", GetErrorMessage(r)); + + SysLog(NID_APP, "Exit."); + return E_SUCCESS; +} + +result +_LiveboxManagerProxy::RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysLog(NID_APP, "Enter."); +// String providerId; +// if( providerName.IsEmpty() == true) +// { +// providerId = appId; +// } +// else +// { +// providerId = appId + "." + providerName; +// } + + result ret = E_SUCCESS; + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestUpdate(appId, providerName, &ret)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + + return ret; +} + + +result +_LiveboxManagerProxy::RequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int& shmId ) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestSharedMemoryId(instanceId, width, height, &shmId)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + SysLog(NID_APP, "shmId(%d) is retrieved from livebox-service", shmId); + + return E_SUCCESS; +} + +result +_LiveboxManagerProxy::RequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int& shmId ) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestSharedMemoryIdForPD(instanceId, width, height, &shmId)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + SysLog(NID_APP, "shmId(%d) is retrieved from livebox-service", shmId); + + return E_SUCCESS; +} + +result +_LiveboxManagerProxy::RequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysLog(NID_APP, ""); + + result ret = E_FAILURE; + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestSyncSharedMemory(instanceId, width, height, &ret)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + return E_SUCCESS; +} + +result +_LiveboxManagerProxy::RequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysLog(NID_APP, ""); + + result ret = E_FAILURE; + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestSyncSharedMemoryForPD(instanceId, &ret)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + return E_SUCCESS; +} + +result +_LiveboxManagerProxy::RequestReleaseSharedMemory(const Tizen::Base::String& instanceId) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysLog(NID_APP, ""); + + result ret = E_FAILURE; + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestReleaseSharedMemory(instanceId, &ret)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + return E_SUCCESS; +} + +result +_LiveboxManagerProxy::RequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId) +{ + SysTryReturnResult(NID_APP, __pIpcClient != null, E_INVALID_STATE, "__pIpcClient instance must not be null."); + SysLog(NID_APP, ""); + + result ret = E_FAILURE; + std::auto_ptr pMsg (new (std::nothrow) LiveboxManager_RequestReleaseSharedMemoryForPD(instanceId, &ret)); + result r = __pIpcClient->SendRequest(*pMsg.get()); + SysTryReturn(NID_APP, !IsFailed(r), r, r, "SendRequest is failed."); + return E_SUCCESS; +} + + +result +_LiveboxManagerProxy::OnTouchEventReceived(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y ) +{ + return _LiveboxManagerImpl::GetInstance()->ForwardTouchEvent(instanceId, eventType, timeStamp, x, y); +} + +result +_LiveboxManagerProxy::OnTouchEventReceivedForPD(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y ) +{ + return _LiveboxManagerImpl::GetInstance()->ForwardTouchEventForPD(instanceId, eventType, timeStamp, x, y); +} + +void +_LiveboxManagerProxy::OnIpcResponseReceived(_IpcClient& client, const IPC::Message& message) +{ + SysLog(NID_APP, "Enter."); + IPC_BEGIN_MESSAGE_MAP(_LiveboxManagerProxy, message) + IPC_MESSAGE_HANDLER_EX(LiveboxManager_SendTouchEvent, &client, OnTouchEventReceived ) + IPC_MESSAGE_HANDLER_EX(LiveboxManager_SendTouchEventForPD, &client, OnTouchEventReceivedForPD ) + IPC_END_MESSAGE_MAP() + + SysLog(NID_APP, "Exit."); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopup.cpp b/src/FShell_LiveboxPopup.cpp new file mode 100644 index 0000000..9e2acba --- /dev/null +++ b/src/FShell_LiveboxPopup.cpp @@ -0,0 +1,295 @@ +// +// 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 FShell_LiveboxPopup.cpp + * @brief This is the implementation file for the _LiveboxPopup class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "FUi_UiKeyEvent.h" +#include "FUi_IUiEventManager.h" +#include "FUi_UiEventManager.h" +#include "FUiAnim_DisplayManager.h" +#include "FUiAnim_RootVisualElement.h" +#include "FShell_LiveboxLayer.h" +#include "FShell_LiveboxPopup.h" +#include "FShell_LiveboxPopupPresenter.h" +#include "FShell_LiveboxManagerImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Ui::Controls; + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupLayer + : public _LiveboxLayer +{ +public: + _LiveboxPopupLayer(const String& instanceId, const _Window& window); + virtual ~_LiveboxPopupLayer(void); + +private: + _LiveboxPopupLayer(const _LiveboxPopupLayer& rhs); + _LiveboxPopupLayer& operator =(const _LiveboxPopupLayer& rhs); + + virtual result RegisterTouchEventListener(void); + virtual int AcquirePixmap(void); + virtual result Sync(const Tizen::Graphics::Rectangle& bounds); + virtual void ReleasePixmap(void); +}; + +_LiveboxPopupLayer::_LiveboxPopupLayer(const String& instanceId, const _Window& window) + : _LiveboxLayer(instanceId, window) +{ +} + +_LiveboxPopupLayer::~_LiveboxPopupLayer(void) +{ + if (!__isReleased) + { + ReleasePixmap(); + __isReleased = true; + } +} + +result +_LiveboxPopupLayer::RegisterTouchEventListener(void) +{ + result r = _LiveboxManagerImpl::GetInstance()->SetLiveboxPopupEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +int +_LiveboxPopupLayer::AcquirePixmap(void) +{ + int pixmapId = -1; + + const _Window* pWindow = GetWindow(); + SysTryReturn(NID_UI_CTRL, pWindow, -1, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + Rectangle bounds = pWindow->GetBounds(); + + result r = _LiveboxManagerImpl::GetInstance()->RequestSharedMemoryIdForPD(GetLiveboxId(), bounds.width, bounds.height, pixmapId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, -1, r, "[%s] Propagating.", GetErrorMessage(r)); + + SysLog(NID_UI_CTRL, "pixmapId(%d) bounds(%d %d %d %d)", pixmapId, bounds.x, bounds.y, bounds.width, bounds.height); + + return pixmapId; +} + +result +_LiveboxPopupLayer::Sync(const Tizen::Graphics::Rectangle& bounds) +{ + result r = _LiveboxManagerImpl::GetInstance()->RequestSyncSharedMemoryForPD(GetLiveboxId()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_LiveboxPopupLayer::ReleasePixmap(void) +{ + _LiveboxManagerImpl::GetInstance()->RequestReleaseSharedMemoryForPD(GetLiveboxId()); +} + +_LiveboxPopup::_LiveboxPopup(void) + : __pLiveboxPopupPresenter(new (std::nothrow) _LiveboxPopupPresenter(*this)) + , __pLiveboxPopupRootVisualElement(null) + , __pEventManager(null) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pLiveboxPopupPresenter, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + _UiEventManager* pEventManager = _UiEventManager::GetInstance(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + __pEventManager = pEventManager->GetEventManager(); + SysTryReturnVoidResult(NID_UI_CTRL, __pEventManager, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); +} + +_LiveboxPopup::~_LiveboxPopup(void) +{ + if (__pEventManager) + { + __pEventManager->UnregisterTouchEventHandler(*this); + } + + if (__pLiveboxPopupRootVisualElement) + { + _VisualElement* pVisualElement = GetVisualElement(); + if (pVisualElement) + { + __pLiveboxPopupRootVisualElement->DetachChild(*pVisualElement); + } + } +} + +_LiveboxPopup* +_LiveboxPopup::CreateLiveboxPopupN(void) +{ + unique_ptr<_LiveboxPopup> pLiveboxPopup(new (std::nothrow) _LiveboxPopup()); + SysTryReturn(NID_UI_CTRL, pLiveboxPopup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLiveboxPopup->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pLiveboxPopup.release(); +} + +result +_LiveboxPopup::Initialize(const String& instanceId, const Tizen::Graphics::Dimension& size) +{ + result r = E_SUCCESS; + _VisualElement* pVisualElement = null; + + SetSystemWindow(true); + + Rectangle bounds(0, 0, size.width, size.height); + r = SetBounds(bounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + FloatRectangle fBounds(0.0f, 0.0f, static_cast(bounds.width), static_cast(bounds.height)); + + r = __pLiveboxPopupPresenter->Initialize(instanceId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + unique_ptr<_LiveboxPopupLayer> pLayer(new (std::nothrow) _LiveboxPopupLayer(instanceId, *this)); + SysTryReturn(NID_UI_CTRL, pLayer, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pLayer->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxPopupLayer = move(pLayer); + __pLiveboxPopupRootVisualElement = __pLiveboxPopupLayer->GetRootVisualElement(); + + __pLiveboxPopupLayer->SetLayerBounds(bounds); + __pLiveboxPopupLayer->SetShowState(false); + + __pLiveboxPopupRootVisualElement->SetImplicitAnimationEnabled(false); + __pLiveboxPopupRootVisualElement->SetName(L"_LiveboxPopup"); + __pLiveboxPopupRootVisualElement->SetBounds(fBounds); + __pLiveboxPopupRootVisualElement->SetShowState(false); + + pVisualElement = GetVisualElement(); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pVisualElement, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxPopupRootVisualElement->AttachChild(*pVisualElement); + + pVisualElement->SetClipChildrenEnabled(false); + pVisualElement->SetShowState(true); + + __pEventManager->RegisterTouchEventHandler(*this); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +String +_LiveboxPopup::GetLiveboxId(void) const +{ + return __pLiveboxPopupPresenter->GetLiveboxId(); +} + +result +_LiveboxPopup::SetLayerShowState(bool showState) +{ + result r = E_SUCCESS; + + if (__pLiveboxPopupRootVisualElement) + { + _LiveboxPopupLayer* pLayer = dynamic_cast<_LiveboxPopupLayer*>(__pLiveboxPopupRootVisualElement->GetNativeLayer()); + SysTryReturn(NID_UI_CTRL, pLayer, E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + r = pLayer->SetShowState(showState); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxPopupRootVisualElement->SetShowState(showState); + } + + return r; +} + +result +_LiveboxPopup::SetLayerBounds(const Rectangle& bounds) +{ + result r = E_SUCCESS; + + if (__pLiveboxPopupRootVisualElement) + { + _LiveboxPopupLayer* pLayer = dynamic_cast<_LiveboxPopupLayer*>(__pLiveboxPopupRootVisualElement->GetNativeLayer()); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pLayer, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLayer->SetLayerBounds(bounds); + + FloatRectangle fBounds(0.0f, 0.0f, static_cast(bounds.width), static_cast(bounds.height)); + __pLiveboxPopupRootVisualElement->SetBounds(fBounds); + } + + return r; +} + +void +_LiveboxPopup::OnActivated(void) +{ + result r = SetLayerShowState(true); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_LiveboxPopup::OnDeactivated(void) +{ + result r = SetLayerShowState(false); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); +} + +void +_LiveboxPopup::OnBoundsChanged(void) +{ + Rectangle bounds = GetBounds(); + + SetLayerBounds(bounds); +} + +void +_LiveboxPopup::OnDraw(void) +{ + if (__pLiveboxPopupPresenter) + { + __pLiveboxPopupPresenter->Draw(); + } +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopup.h b/src/FShell_LiveboxPopup.h new file mode 100644 index 0000000..81e27a3 --- /dev/null +++ b/src/FShell_LiveboxPopup.h @@ -0,0 +1,85 @@ +// +// 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 FShell_LiveboxPopup.h + * @brief This is the header file for the _LiveboxPopup class. + * + * This header file contains the declarations of the %_LiveboxPopup class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_H_ + +#include +#include +#include "FUi_Window.h" + +namespace Tizen { namespace Ui +{ +class _IUiEventManager; +}} // Tizen::Ui + +namespace Tizen { namespace Ui { namespace Animations +{ +class _RootVisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupPresenter; +class _LiveboxPopupLayer; + +/** + * @class _LiveboxPopup + * @brief + * @since 2.1 + */ +class _LiveboxPopup + : public Tizen::Ui::_Window +{ +public: + static _LiveboxPopup* CreateLiveboxPopupN(void); + virtual ~_LiveboxPopup(void); + + result Initialize(const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + Tizen::Base::String GetLiveboxId(void) const; + +protected: + _LiveboxPopup(void); + +private: + _LiveboxPopup(const _LiveboxPopup& rhs); + _LiveboxPopup& operator =(const _LiveboxPopup& rhs); + + result SetLayerShowState(bool showState); + result SetLayerBounds(const Tizen::Graphics::Rectangle& bounds); + + virtual void OnActivated(void); + virtual void OnDeactivated(void); + virtual void OnBoundsChanged(void); + virtual void OnDraw(void); + +private: + std::unique_ptr<_LiveboxPopupPresenter> __pLiveboxPopupPresenter; + std::unique_ptr<_LiveboxPopupLayer> __pLiveboxPopupLayer; + Tizen::Ui::Animations::_RootVisualElement* __pLiveboxPopupRootVisualElement; + Tizen::Ui::_IUiEventManager* __pEventManager; +}; // _LiveboxPopup + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_H_ diff --git a/src/FShell_LiveboxPopupImpl.cpp b/src/FShell_LiveboxPopupImpl.cpp new file mode 100644 index 0000000..fc9e530 --- /dev/null +++ b/src/FShell_LiveboxPopupImpl.cpp @@ -0,0 +1,109 @@ +// +// 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. +// + +#include +#include +#include +#include "FShell_LiveboxPopupImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; + +namespace Tizen { namespace Shell +{ + +const _LiveboxPopupImpl* +_LiveboxPopupImpl::GetInstance(const LiveboxPopup& liveboxPopup) +{ + return static_cast(_ControlImpl::GetInstance(liveboxPopup)); +} + +_LiveboxPopupImpl* +_LiveboxPopupImpl::GetInstance(LiveboxPopup& liveboxPopup) +{ + return static_cast<_LiveboxPopupImpl*>(_ControlImpl::GetInstance(liveboxPopup)); +} + +_LiveboxPopupImpl* +_LiveboxPopupImpl::CreateLiveboxPopupImplN(LiveboxPopup& liveboxPopup, const Layout* pPortraitLayout, const Layout* pLandscapeLayout) +{ + unique_ptr<_LiveboxPopup> pCore(_LiveboxPopup::CreateLiveboxPopupN()); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + unique_ptr<_LiveboxPopupImpl> pImpl(new (std::nothrow) _LiveboxPopupImpl(&liveboxPopup, pCore.get(), pPortraitLayout, pLandscapeLayout)); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pCore.release(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl.release(); +} + +_LiveboxPopupImpl::_LiveboxPopupImpl(LiveboxPopup* pPublic, _LiveboxPopup* pCore, const Layout* pPortraitLayout, const Layout* pLandscapeLayout) + : _WindowImpl(pPublic, pCore, pPortraitLayout, pLandscapeLayout) +{ +} + +_LiveboxPopupImpl::~_LiveboxPopupImpl(void) +{ +} + +const char* +_LiveboxPopupImpl::GetPublicClassName(void) const +{ + return "Tizen::Shell::LiveboxPopup"; +} + +const LiveboxPopup& +_LiveboxPopupImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +LiveboxPopup& +_LiveboxPopupImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _LiveboxPopup& +_LiveboxPopupImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_LiveboxPopup& +_LiveboxPopupImpl::GetCore(void) +{ + return static_cast<_LiveboxPopup&>(_ControlImpl::GetCore()); +} + +result +_LiveboxPopupImpl::Initialize(const String& instanceId, const Dimension& size) +{ + result r = GetCore().Initialize(instanceId, size); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupImpl.h b/src/FShell_LiveboxPopupImpl.h new file mode 100644 index 0000000..7dfeb25 --- /dev/null +++ b/src/FShell_LiveboxPopupImpl.h @@ -0,0 +1,55 @@ +// +// 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. +// +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_IMPL_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_IMPL_H_ + +#include +#include "FUi_WindowImpl.h" +#include "FShell_LiveboxPopup.h" + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupImpl + : public Tizen::Ui::_WindowImpl +{ +public: + static _LiveboxPopupImpl* CreateLiveboxPopupImplN(LiveboxPopup& liveboxPopup, const Tizen::Ui::Layout* pPortraitLayout, const Tizen::Ui::Layout* pLandscapeLayout); + static const _LiveboxPopupImpl* GetInstance(const LiveboxPopup& liveboxPopup); + static _LiveboxPopupImpl* GetInstance(LiveboxPopup& liveboxPopup); + + virtual ~_LiveboxPopupImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const LiveboxPopup& GetPublic(void) const; + virtual LiveboxPopup& GetPublic(void); + virtual const _LiveboxPopup& GetCore(void) const; + virtual _LiveboxPopup& GetCore(void); + + result Initialize(const Tizen::Base::String& instanceId, const Tizen::Graphics::Dimension& size); + +protected: + _LiveboxPopupImpl(LiveboxPopup* pPublic, _LiveboxPopup* pCore, const Tizen::Ui::Layout* pPortraitLayout, const Tizen::Ui::Layout* pLandscapeLayout); + +private: + _LiveboxPopupImpl(const _LiveboxPopupImpl& rhs); + _LiveboxPopupImpl& operator =(const _LiveboxPopupImpl& rhs); +}; // _LiveboxPopupImpl + +}} // Tizen::Shell::Ui::Controls + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_IMPL_H_ diff --git a/src/FShell_LiveboxPopupModel.cpp b/src/FShell_LiveboxPopupModel.cpp new file mode 100644 index 0000000..b87436e --- /dev/null +++ b/src/FShell_LiveboxPopupModel.cpp @@ -0,0 +1,50 @@ +// +// 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 FShell_LiveboxPopupModel.cpp + * @brief This is the implementation file for the _LiveboxPopupModel class. + */ + +#include +#include "FShell_LiveboxPopupModel.h" + +using namespace Tizen::Base; + +namespace Tizen { namespace Shell +{ + +_LiveboxPopupModel::_LiveboxPopupModel(void) +{ +} + +_LiveboxPopupModel::~_LiveboxPopupModel(void) +{ +} + +void +_LiveboxPopupModel::SetinstanceId(const String& instanceId) +{ + __instanceId = instanceId; +} + +String +_LiveboxPopupModel::GetLiveboxId(void) const +{ + return __instanceId; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupModel.h b/src/FShell_LiveboxPopupModel.h new file mode 100644 index 0000000..f843ebd --- /dev/null +++ b/src/FShell_LiveboxPopupModel.h @@ -0,0 +1,53 @@ +// +// 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 FShell_LiveboxPopupModel.h + * @brief This is the header file for the _LiveboxPopupModel class. + * + * This header file contains the declarations of the %_LiveboxPopupModel class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_MODEL_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_MODEL_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupModel + : public Tizen::Base::Object +{ +public: + _LiveboxPopupModel(void); + virtual ~_LiveboxPopupModel(void); + +public: + void SetinstanceId(const Tizen::Base::String& instanceId); + Tizen::Base::String GetLiveboxId(void) const; + +private: + _LiveboxPopupModel(const _LiveboxPopupModel& rhs); + _LiveboxPopupModel& operator =(const _LiveboxPopupModel& rhs); + +private: + Tizen::Base::String __instanceId; +}; // _LiveboxPopupModel + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_MODEL_H_ diff --git a/src/FShell_LiveboxPopupPresenter.cpp b/src/FShell_LiveboxPopupPresenter.cpp new file mode 100644 index 0000000..012226f --- /dev/null +++ b/src/FShell_LiveboxPopupPresenter.cpp @@ -0,0 +1,67 @@ +// +// 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 FShell_LiveboxPopupPresenter.cpp + * @brief This is the implementation file for the _LiveboxPopupPresenter class. + */ + +#include +#include +#include "FShell_LiveboxPopupPresenter.h" +#include "FShell_LiveboxPopup.h" +#include "FShell_LiveboxPopupModel.h" + +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +_LiveboxPopupPresenter::_LiveboxPopupPresenter(const _LiveboxPopup& liveBoxTray) + : __pLiveboxPopup(null) + , __pLiveboxPopupModel(new (std::nothrow) _LiveboxPopupModel) +{ + __pLiveboxPopup = const_cast <_LiveboxPopup*>(&liveBoxTray); +} + +_LiveboxPopupPresenter::~_LiveboxPopupPresenter(void) +{ + __pLiveboxPopup = null; +} + +result +_LiveboxPopupPresenter::Initialize(const Tizen::Base::String& instanceId) +{ + result r = E_SUCCESS; + + __pLiveboxPopupModel->SetinstanceId(instanceId); + + return r; +} + +String +_LiveboxPopupPresenter::GetLiveboxId(void) const +{ + return __pLiveboxPopupModel->GetLiveboxId(); +} + +void +_LiveboxPopupPresenter::Draw(void) +{ +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupPresenter.h b/src/FShell_LiveboxPopupPresenter.h new file mode 100644 index 0000000..446ed13 --- /dev/null +++ b/src/FShell_LiveboxPopupPresenter.h @@ -0,0 +1,56 @@ +// +// 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 FShell_LiveboxPopupPresenter.h + * @brief This is the header file for the _LiveboxPopupPresenter class. + * + * This header file contains the declarations of the %_LiveboxPopupPresenter class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_PRESENTER_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_PRESENTER_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopup; +class _LiveboxPopupModel; + +class _LiveboxPopupPresenter +{ +public: + _LiveboxPopupPresenter(const _LiveboxPopup& liveBoxTray); + virtual ~_LiveboxPopupPresenter(void); + + result Initialize(const Tizen::Base::String& instanceId); + Tizen::Base::String GetLiveboxId(void) const; + void Draw(void); + +private: + _LiveboxPopupPresenter(const _LiveboxPopupPresenter& rhs); + _LiveboxPopupPresenter& operator =(const _LiveboxPopupPresenter& rhs); + +private: + _LiveboxPopup* __pLiveboxPopup; + std::unique_ptr<_LiveboxPopupModel> __pLiveboxPopupModel; +}; // _LiveboxPopupPresenter + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_PRESENTER_H_ diff --git a/src/FShell_LiveboxPopupProviderImpl.cpp b/src/FShell_LiveboxPopupProviderImpl.cpp new file mode 100644 index 0000000..8bcb638 --- /dev/null +++ b/src/FShell_LiveboxPopupProviderImpl.cpp @@ -0,0 +1,72 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file .cpp + * @brief This is the implementation for the Livebox class. + */ + +#include +#include +#include + +#include "FShell_LiveboxProviderImpl.h" +#include "FShellLiveboxPopupProvider.h" + +namespace Tizen { namespace Shell +{ + +using namespace Tizen::Base; + + + +LiveboxPopupProvider::LiveboxPopupProvider() +{ + SysLog(NID_APP, ""); +} + +LiveboxPopupProvider::~LiveboxPopupProvider() +{ + SysLog(NID_APP, ""); +} + +result +LiveboxPopupProvider::Construct(const String& instanceId) +{ + SysLog(NID_APP, ""); + __pLiveboxProviderImpl = new _LiveboxProviderImpl(instanceId); + SysTryReturnResult(NID_APP, __pLiveboxProviderImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY]"); + + return E_SUCCESS; +} + +String +LiveboxPopupProvider::GetId() const +{ + return __pLiveboxProviderImpl->GetId(); +} + +void +LiveboxPopupProvider::SetLiveboxPopup(LiveboxPopup* pLiveboxFrame) +{ + __pLiveboxFrame = pLiveboxFrame; +// return __pLiveboxProviderImpl->SetLiveboxFrame(pLiveboxFrame); +} + +LiveboxPopup* +LiveboxPopupProvider::GetLiveboxPopup() const +{ + return __pLiveboxFrame; +// return __pLiveboxProviderImpl->GetLiveboxFrame(); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupView.cpp b/src/FShell_LiveboxPopupView.cpp new file mode 100644 index 0000000..e876bc8 --- /dev/null +++ b/src/FShell_LiveboxPopupView.cpp @@ -0,0 +1,343 @@ +// +// 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 FShell_LiveboxPopupView.cpp + * @brief This is the implementation file for the _LiveboxPopupView class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FShell_LiveboxPopupView.h" +#include "FShell_LiveboxPopupViewPresenter.h" +#include "FShell_LiveboxPopupViewEvent.h" +#include "FShell_LiveboxView.h" +#include "FShell_ILiveboxPopupViewEventListener.h" +#include "FUiAnim_VisualElement.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; + +namespace Tizen { namespace Shell +{ + +const wchar_t* OPEN_ANIMATION = L"Open"; +const wchar_t* CLOSE_ANIMATION = L"Close"; + +_LiveboxPopupView::_LiveboxPopupView(_LiveboxView& liveBoxView) + : __pLiveboxPopupViewPresenter(new (std::nothrow) _LiveboxPopupViewPresenter(*this)) + , __pLiveboxView(&liveBoxView) + , __pLiveboxPopupViewEvent(_LiveboxPopupViewEvent::CreateInstanceN(*this)) + , __firstUpdated(false) +{ + int ret = livebox_create_pd(__pLiveboxView->__pLivebox, OnLiveboxPopupCreated, this); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_SYSTEM, "[E_SYSTEM] A system error occurred."); +} + +_LiveboxPopupView::~_LiveboxPopupView(void) +{ + if (livebox_has_pd(__pLiveboxView->__pLivebox)) + { + livebox_destroy_pd(__pLiveboxView->__pLivebox, OnLiveboxPopupDestroyed, this); + } + + __pLiveboxView = null; +} + +_LiveboxPopupView* +_LiveboxPopupView::CreateLiveboxPopupN(_LiveboxView& liveBoxView) +{ + SysTryReturn(NID_UI_CTRL, livebox_has_pd(liveBoxView.__pLivebox), null, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + unique_ptr<_LiveboxPopupView> pLiveboxPopup(new (std::nothrow) _LiveboxPopupView(liveBoxView)); + SysTryReturn(NID_UI_CTRL, pLiveboxPopup, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLiveboxPopup->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pLiveboxPopup.release(); +} + +result +_LiveboxPopupView::Initialize(void) +{ + return E_SUCCESS; +} + +result +_LiveboxPopupView::AddLiveboxPopupEventListener(const _ILiveboxPopupViewEventListener& listener) +{ + result r = __pLiveboxPopupViewEvent->AddListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +result +_LiveboxPopupView::RemoveLiveboxPopupEventListener(const _ILiveboxPopupViewEventListener& listener) +{ + result r = __pLiveboxPopupViewEvent->RemoveListener(listener); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +Bitmap* +_LiveboxPopupView::GetBitmap(void) const +{ + return __pBitmap.get(); +} + +void +_LiveboxPopupView::FireLiveboxPopupEvent(bool open) +{ + if (__pLiveboxPopupViewEvent) + { + IEventArg* pEventArg = _LiveboxPopupViewEvent::CreateLiveboxPopupViewEventArgN(open); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pEventArg != null, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxPopupViewEvent->Fire(*pEventArg); + } +} + +void +_LiveboxPopupView::GetTouchPostion(const Tizen::Graphics::Point& point, double& x, double& y) +{ + Rectangle bounds = GetBounds(); + + x = static_cast(point.x) / static_cast(bounds.width); + y = static_cast(point.y) / static_cast(bounds.height); +} + +void +_LiveboxPopupView::PlayAnimation(bool open) +{ + const int ANIMATION1_DURATION = 100; + const int ANIMATION2_DURATION = 300; + + _VisualElement* pVisualElement = GetVisualElement(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, r, "[%s] Propagating.", GetErrorMessage(r)); + + VisualElementAnimationGroup animationGroup; + animationGroup.SetVisualElementAnimationStatusEventListener(this); + + FloatRectangle bounds = pVisualElement->GetBounds(); + FloatRectangle startBounds(0.0f, bounds.y, bounds.width, 0.0f); + FloatRectangle endBounds(bounds); + if (!open) + { + startBounds = bounds; + endBounds = FloatRectangle(0.0f, bounds.y, bounds.width, 0.0f); + } + + VisualElementPropertyAnimation animation1; + animation1.SetPropertyName(L"bounds"); + animation1.SetStartValue(Variant(startBounds)); + animation1.SetEndValue(Variant(endBounds)); + animation1.SetDuration(ANIMATION1_DURATION); + + animationGroup.AddAnimation(animation1); + + float startOpacity = 0.0f; + float endOpacity = 1.0f; + if (!open) + { + startOpacity = 1.0f; + endOpacity = 0.0f; + } + + VisualElementPropertyAnimation animation2; + animation2.SetPropertyName(L"opacity"); + animation2.SetStartValue(Variant(startOpacity)); + animation2.SetEndValue(Variant(endOpacity)); + animation2.SetDuration(ANIMATION2_DURATION); + + animationGroup.AddAnimation(animation2); + + String keyName = (open) ? OPEN_ANIMATION : CLOSE_ANIMATION; + pVisualElement->AddAnimation(keyName, animationGroup); +} + +result +_LiveboxPopupView::OnAttached(void) +{ + if (__firstUpdated) + { + PlayAnimation(true); + } + + return E_SUCCESS; +} + +void +_LiveboxPopupView::OnActivated(void) +{ + SetTouchCapture(); +} + +void +_LiveboxPopupView::OnDeactivated(void) +{ + ReleaseTouchCapture(); +} + +bool +_LiveboxPopupView::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + double x = 0.0f; + double y = 0.0f; + + GetTouchPostion(touchInfo.GetCurrentPosition(), x, y); + + livebox_content_event(__pLiveboxView->__pLivebox, PD_MOUSE_DOWN, x, y); + + return false; +} + +bool +_LiveboxPopupView::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + Rectangle clientBounds(GetClientBounds()); + Point touchPoint(touchInfo.GetCurrentPosition()); + + if (!clientBounds.Contains(touchPoint)) + { + FireLiveboxPopupEvent(false); + PlayAnimation(false); + } + + double x = 0.0f; + double y = 0.0f; + + GetTouchPostion(touchInfo.GetCurrentPosition(), x, y); + + livebox_content_event(__pLiveboxView->__pLivebox, PD_MOUSE_UP, x, y); + + return false; +} + +bool +_LiveboxPopupView::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + double x = 0.0f; + double y = 0.0f; + + GetTouchPostion(touchInfo.GetCurrentPosition(), x, y); + + livebox_content_event(__pLiveboxView->__pLivebox, PD_MOUSE_MOVE, x, y); + + return false; +} + +void +_LiveboxPopupView::OnBoundsChanged(void) +{ +} + +void +_LiveboxPopupView::OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target) +{ +} + +void +_LiveboxPopupView::OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally) +{ + if (keyName == CLOSE_ANIMATION) + { + SysLog(NID_UI_CTRL, "Close LiveboxPopup"); + Close(); + } +} + +void +_LiveboxPopupView::OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount) +{ +} + +void +_LiveboxPopupView::OnDraw(void) +{ + __pLiveboxPopupViewPresenter->Draw(); +} + +void +_LiveboxPopupView::OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Dimension& size) +{ + SetSize(size); + + __pBitmap.reset(const_cast(&bitmap)); + + if (!__firstUpdated) + { + PlayAnimation(true); + __firstUpdated = true; + } + else + { + if (__pBitmap.get() == null) + { + SysLog(NID_UI_CTRL, "Bitmap is invalid."); + return; + } + + Invalidate(false); + } +} + +void +_LiveboxPopupView::OnLiveboxPopupCreated(struct livebox *pLivebox, int ret, void* pData) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxPopupView* pLiveboxViewManager = static_cast<_LiveboxPopupView*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); +} + +void +_LiveboxPopupView::OnLiveboxPopupDestroyed(struct livebox *pLivebox, int ret, void* pData) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxPopupView* pLiveboxViewManager = static_cast<_LiveboxPopupView*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupView.h b/src/FShell_LiveboxPopupView.h new file mode 100644 index 0000000..e44caf2 --- /dev/null +++ b/src/FShell_LiveboxPopupView.h @@ -0,0 +1,113 @@ +// +// 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 FShell_LiveboxPopupView.h + * @brief This is the header file for the _LiveboxPopupView class. + * + * This header file contains the declarations of the %_LiveboxPopupView class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_H_ + +#include +#include +#include "FUi_Window.h" + +namespace Tizen { namespace Base +{ +class String; +}} // Tizen::Base + +namespace Tizen { namespace Graphics +{ +class Bitmap; +class Dimension; +class Point; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui { namespace Animations +{ +class VisualElementAnimation; +class VisualElement; +}}} // Tizen::Ui::Animations + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupViewPresenter; +class _LiveboxPopupViewEvent; +class _LiveboxView; +class _ILiveboxPopupViewEventListener; + +/** + * @class _LiveboxPopupView + * @brief + * @since 2.1 + */ +class _LiveboxPopupView + : public Tizen::Ui::_Window + , public Tizen::Ui::Animations::IVisualElementAnimationStatusEventListener +{ +public: + static _LiveboxPopupView* CreateLiveboxPopupN(_LiveboxView& liveBoxView); + virtual ~_LiveboxPopupView(void); + + result Initialize(void); + result AddLiveboxPopupEventListener(const _ILiveboxPopupViewEventListener& listener); + result RemoveLiveboxPopupEventListener(const _ILiveboxPopupViewEventListener& listener); + Tizen::Graphics::Bitmap* GetBitmap(void) const; + +protected: + _LiveboxPopupView(_LiveboxView& liveBoxView); + +private: + _LiveboxPopupView(const _LiveboxPopupView& rhs); + _LiveboxPopupView& operator =(const _LiveboxPopupView& rhs); + + void FireLiveboxPopupEvent(bool open); + void GetTouchPostion(const Tizen::Graphics::Point& point, double& x, double& y); + void PlayAnimation(bool open); + + virtual result OnAttached(void); + virtual void OnActivated(void); + virtual void OnDeactivated(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); + virtual void OnBoundsChanged(void); + virtual void OnVisualElementAnimationStarted(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target); + virtual void OnVisualElementAnimationFinished(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, bool completedNormally); + virtual void OnVisualElementAnimationRepeated(const Tizen::Ui::Animations::VisualElementAnimation& animation, const Tizen::Base::String& keyName, Tizen::Ui::Animations::VisualElement& target, long currentRepeatCount); + virtual void OnDraw(void); + + void OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Dimension& size); + + static void OnLiveboxPopupCreated(struct livebox *pLivebox, int ret, void* pData); + static void OnLiveboxPopupDestroyed(struct livebox *pLivebox, int ret, void* pData); + +private: + friend class _LiveboxViewManager; + std::unique_ptr<_LiveboxPopupViewPresenter> __pLiveboxPopupViewPresenter; + std::unique_ptr __pBitmap; + _LiveboxView* __pLiveboxView; + std::unique_ptr<_LiveboxPopupViewEvent> __pLiveboxPopupViewEvent; + bool __firstUpdated; +}; // _LiveboxPopupView + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_H_ diff --git a/src/FShell_LiveboxPopupViewEvent.cpp b/src/FShell_LiveboxPopupViewEvent.cpp new file mode 100644 index 0000000..2cf0174 --- /dev/null +++ b/src/FShell_LiveboxPopupViewEvent.cpp @@ -0,0 +1,122 @@ +// +// 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 FShell_LiveboxPopupViewEvent.cpp +* @brief This is the implementation for the _LiveboxPopupViewEvent class. +*/ + +#include +#include +#include +#include "FShell_ILiveboxPopupViewEventListener.h" +#include "FShell_LiveboxPopupViewEvent.h" + +using namespace Tizen::Base; +using namespace Tizen::Base::Runtime; +using namespace Tizen::Ui; + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupEventArg + : public Object + , public IEventArg +{ +public: + _LiveboxPopupEventArg(bool open); + virtual ~_LiveboxPopupEventArg(void); + + bool IsOpened(void) const; + +private: + bool __opened; + +}; // _LiveboxPopupEventArg + +_LiveboxPopupEventArg::_LiveboxPopupEventArg(bool open) + : __opened(open) +{ +} + +_LiveboxPopupEventArg::~_LiveboxPopupEventArg(void) +{ +} + +bool +_LiveboxPopupEventArg::IsOpened(void) const +{ + return __opened; +} + +_LiveboxPopupViewEvent::_LiveboxPopupViewEvent(const _Control& source) + : __pSource(null) +{ + result r = _Event::Initialize(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pSource = &source; + SetLastResult(E_SUCCESS); +} + +_LiveboxPopupViewEvent::~_LiveboxPopupViewEvent(void) +{ +} + +_LiveboxPopupViewEvent* +_LiveboxPopupViewEvent::CreateInstanceN(const _Control& source) +{ + _LiveboxPopupViewEvent* pLiveboxPopupEvent = new (std::nothrow) _LiveboxPopupViewEvent(source); + SysTryReturn(NID_UI_CTRL, pLiveboxPopupEvent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pLiveboxPopupEvent; +} + +const _Control* +_LiveboxPopupViewEvent::GetSource(void) const +{ + return __pSource; +} + +void +_LiveboxPopupViewEvent::FireImpl(IEventListener& pListener, const IEventArg& arg) +{ + _ILiveboxPopupViewEventListener* pLiveboxPopupViewEventListener = dynamic_cast<_ILiveboxPopupViewEventListener*>(&pListener); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxPopupViewEventListener, E_INVALID_ARG, "[E_INVALID_ARG] The invalid listener was given.\n"); + + const _LiveboxPopupEventArg* pLiveboxPopupEventArg = dynamic_cast (&arg); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxPopupEventArg, E_INVALID_ARG, "[E_INVALID_ARG] The invalid Event Argument was given.\n"); + + if ( pLiveboxPopupEventArg->IsOpened() ) + { + pLiveboxPopupViewEventListener->OnLiveboxPopupViewOpened(); + } + else + { + pLiveboxPopupViewEventListener->OnLiveboxPopupViewClosed(); + } +} + +IEventArg* +_LiveboxPopupViewEvent::CreateLiveboxPopupViewEventArgN(bool open) +{ + _LiveboxPopupEventArg* pEventArg = new (std::nothrow) _LiveboxPopupEventArg(open); + SysTryReturn(NID_UI_CTRL, pEventArg != null, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory shortage."); + + return pEventArg; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupViewEvent.h b/src/FShell_LiveboxPopupViewEvent.h new file mode 100644 index 0000000..b85117a --- /dev/null +++ b/src/FShell_LiveboxPopupViewEvent.h @@ -0,0 +1,65 @@ +// +// 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 FShell_LiveboxPopupViewEvent.h + * @brief This is the header file for _LiveboxPopupViewEvent class. + * + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_EVENT_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_EVENT_H_ + +#include +#include + +namespace Tizen { namespace Ui +{ +class _Control; +}} // Tizen::Ui + + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupViewEvent + : public Tizen::Base::Runtime::_Event +{ +public: + _LiveboxPopupViewEvent(const Tizen::Ui::_Control& source); + virtual ~_LiveboxPopupViewEvent(void); + + static _LiveboxPopupViewEvent* CreateInstanceN(const Tizen::Ui::_Control& source); + +public: + const Tizen::Ui::_Control* GetSource(void) const; + + static Tizen::Base::Runtime::IEventArg* CreateLiveboxPopupViewEventArgN(bool open); + +protected: + virtual void FireImpl(Tizen::Base::Runtime::IEventListener& pListener, const Tizen::Base::Runtime::IEventArg& arg); + +private: + _LiveboxPopupViewEvent(const _LiveboxPopupViewEvent& rhs); + _LiveboxPopupViewEvent& operator=(const _LiveboxPopupViewEvent& rhs); + +private: + const Tizen::Ui::_Control* __pSource; +}; // _LiveboxPopupViewEvent + +}} // Tizen::Shell + + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_EVENT_H_ diff --git a/src/FShell_LiveboxPopupViewPresenter.cpp b/src/FShell_LiveboxPopupViewPresenter.cpp new file mode 100644 index 0000000..f3a2627 --- /dev/null +++ b/src/FShell_LiveboxPopupViewPresenter.cpp @@ -0,0 +1,57 @@ +// +// 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 FShell_LiveboxPopupViewPresenter.cpp + * @brief This is the implementation file for the _LiveboxPopupViewPresenter class. + */ + +#include +#include +#include "FShell_LiveboxPopupViewPresenter.h" +#include "FShell_LiveboxPopupView.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +_LiveboxPopupViewPresenter::_LiveboxPopupViewPresenter(const _LiveboxPopupView& liveboxPopupView) + : __pLiveboxPopupView(null) +{ + __pLiveboxPopupView = const_cast <_LiveboxPopupView*>(&liveboxPopupView); +} + +_LiveboxPopupViewPresenter::~_LiveboxPopupViewPresenter(void) +{ + __pLiveboxPopupView = null; +} + +void +_LiveboxPopupViewPresenter::Draw(void) +{ + Bitmap* pBitmap = __pLiveboxPopupView->GetBitmap(); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_SYSTEM, "Bitmap is invalid."); + + unique_ptr pCanvas(__pLiveboxPopupView->GetCanvasN()); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pCanvas->DrawBitmap(Point(0, 0), *pBitmap); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxPopupViewPresenter.h b/src/FShell_LiveboxPopupViewPresenter.h new file mode 100644 index 0000000..a7d2270 --- /dev/null +++ b/src/FShell_LiveboxPopupViewPresenter.h @@ -0,0 +1,49 @@ +// +// 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 FShell_LiveboxPopupViewPresenter.h + * @brief This is the header file for the _LiveboxPopupViewPresenter class. + * + * This header file contains the declarations of the %_LiveboxPopupViewPresenter class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_PRESENTER_H_ +#define _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_PRESENTER_H_ + +namespace Tizen { namespace Shell +{ + +class _LiveboxPopupView; + +class _LiveboxPopupViewPresenter +{ +public: + _LiveboxPopupViewPresenter(const _LiveboxPopupView& liveboxPopupView); + virtual ~_LiveboxPopupViewPresenter(void); + + void Draw(void); + +private: + _LiveboxPopupViewPresenter(const _LiveboxPopupViewPresenter& rhs); + _LiveboxPopupViewPresenter& operator =(const _LiveboxPopupViewPresenter& rhs); + +private: + _LiveboxPopupView* __pLiveboxPopupView; +}; // _LiveboxPopupViewPresenter + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_POPUP_VIEW_PRESENTER_H_ diff --git a/src/FShell_LiveboxProviderImpl.cpp b/src/FShell_LiveboxProviderImpl.cpp new file mode 100644 index 0000000..951f304 --- /dev/null +++ b/src/FShell_LiveboxProviderImpl.cpp @@ -0,0 +1,60 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxProviderImpl.cpp + * @brief This is the implementation for the _LiveboxProviderImpl class. + */ + +#include +#include + +//#include +#include "FShell_LiveboxProviderImpl.h" + +namespace Tizen { namespace Shell +{ + +using namespace Tizen::Base; + +_LiveboxProviderImpl::_LiveboxProviderImpl(const String& id) + :__id(id) + ,__pLiveboxFrame(null) +{ + +} + +_LiveboxProviderImpl::~_LiveboxProviderImpl() +{ + +} + +const String& +_LiveboxProviderImpl::GetId() const +{ + return __id; +} + +result +_LiveboxProviderImpl::SetLiveboxFrame(LiveboxFrame* pLiveboxFrame) +{ + __pLiveboxFrame = pLiveboxFrame; + return E_SUCCESS; +} + +LiveboxFrame* +_LiveboxProviderImpl::GetLiveboxFrame() const +{ + return __pLiveboxFrame; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxProviderInfoImpl.cpp b/src/FShell_LiveboxProviderInfoImpl.cpp new file mode 100644 index 0000000..910c76d --- /dev/null +++ b/src/FShell_LiveboxProviderInfoImpl.cpp @@ -0,0 +1,137 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxInfoImpl.cpp + * @brief This is the implementation for the _LiveboxInfoImpl class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include "FShell_LiveboxProviderInfoImpl.h" + +namespace Tizen { namespace Shell { + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + + +_LiveboxProviderInfoImpl::_LiveboxProviderInfoImpl(const Tizen::App::AppId& appId, const Tizen::Base::String& name, const Tizen::Base::String& providerId) +{ + __appId = appId; + __name = name; + __providerId = providerId; + + std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(__providerId)); + __displayName = livebox_service_i18n_name(pPackageId.get(), null); +} + +/*_LiveboxProviderInfoImpl::_LiveboxProviderInfoImpl(const _LiveboxProviderInfoImpl& rhs) +{ + __appId = rhs.__appId; + __name = rhs.__name; + __providerId = rhs.__providerId; +} + +_LiveboxProviderInfoImpl& +_LiveboxProviderInfoImpl::operator =(const _LiveboxProviderInfoImpl& rhs) +{ + __appId = rhs.__appId; + __name = rhs.__name; + __providerId = rhs.__providerId; + + return *this; +}*/ + +_LiveboxProviderInfoImpl::~_LiveboxProviderInfoImpl() +{ +} + +Tizen::App::AppId +_LiveboxProviderInfoImpl::GetAppId() const +{ + return __appId; +} + +Tizen::Base::String +_LiveboxProviderInfoImpl::GetName() const +{ + return __name; +} + +Tizen::Base::String +_LiveboxProviderInfoImpl::GetDisplayName() const +{ +/* std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(__providerId)); + __displayName = livebox_service_i18n_name(pPackageId.get(), null);*/ + return __displayName; +} + +Tizen::Base::String +_LiveboxProviderInfoImpl::GetIconPath() const +{ + std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(__providerId)); + String iconPath = livebox_service_i18n_icon(pPackageId.get(), null); + + return iconPath; +} + +Tizen::Base::String +_LiveboxProviderInfoImpl::GetCongiturationAppControlAppId() const +{ + return __configurationAppControlAppId; +} + +Tizen::Base::Collection::IList* +_LiveboxProviderInfoImpl::GetSizeInfosN() const +{ + const int SUPPORTED_SIZE_TYPE_MAX = 6; + + int supportedSizeCount = SUPPORTED_SIZE_TYPE_MAX; + int widthArray[SUPPORTED_SIZE_TYPE_MAX]; + int heightArray[SUPPORTED_SIZE_TYPE_MAX]; + + std::unique_ptr pPackageId(_StringConverter::CopyToCharArrayN(__providerId)); + livebox_service_get_supported_sizes(pPackageId.get(), &supportedSizeCount , widthArray, heightArray); + + SysTryReturn(NID_APP, supportedSizeCount > 0, null, E_INVALID_ARG, "[E_INVALID_ARG] There is no livebox of provider(%ls)",__providerId.GetPointer() ); + + ArrayList* pSizes = new ArrayList; + pSizes->Construct(); + Dimension size(0, 0); + String previewImagePath; + + for(int i = 0; i < supportedSizeCount; i++) + { + size.SetSize(widthArray[i], heightArray[i]); + previewImagePath = livebox_service_preview(pPackageId.get(), livebox_service_size_type(size.width, size.height) ); + pSizes->Add( *new LiveboxSizeInfo(size, previewImagePath) ); + } + return pSizes; +} + + +_LiveboxProviderInfoImpl* +_LiveboxProviderInfoImpl::GetImpl(const LiveboxProviderInfo& liveboxProviderInfo) +{ + return static_cast<_LiveboxProviderInfoImpl*>(liveboxProviderInfo.__pLiveboxProviderInfoImpl); +} + +} /* namespace Livebox */ +} /* namespace Samsung */ diff --git a/src/FShell_LiveboxSizeInfoImpl.cpp b/src/FShell_LiveboxSizeInfoImpl.cpp new file mode 100644 index 0000000..190278f --- /dev/null +++ b/src/FShell_LiveboxSizeInfoImpl.cpp @@ -0,0 +1,73 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxSizeInfoImpl.cpp + * @brief This is the implementation for the _LiveboxSizeInfoImpl class. + */ + +#include +#include +#include +#include +#include +#include + +#include "FShell_LiveboxProviderInfoImpl.h" +#include "FShell_LiveboxSizeInfoImpl.h" + + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +_LiveboxSizeInfoImpl::_LiveboxSizeInfoImpl(Dimension size, const String& previewImagePath) +{ + __size = size; + __previewImagePath = previewImagePath; +} + +_LiveboxSizeInfoImpl::_LiveboxSizeInfoImpl(const _LiveboxSizeInfoImpl& rhs) +{ + __size = rhs.__size; + __previewImagePath = rhs.__previewImagePath; +} + +_LiveboxSizeInfoImpl& +_LiveboxSizeInfoImpl::operator =(const _LiveboxSizeInfoImpl& rhs) +{ + __size = rhs.__size; + __previewImagePath = rhs.__previewImagePath; + + return *this; +} + +_LiveboxSizeInfoImpl::~_LiveboxSizeInfoImpl() +{ +} + +Dimension +_LiveboxSizeInfoImpl::GetSize() const +{ + return __size; +} + +Tizen::Base::String +_LiveboxSizeInfoImpl::GetPreviewImagePath() const +{ + return __previewImagePath; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxView.cpp b/src/FShell_LiveboxView.cpp new file mode 100644 index 0000000..734c13f --- /dev/null +++ b/src/FShell_LiveboxView.cpp @@ -0,0 +1,392 @@ +// +// 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 FShell_LiveboxView.cpp + * @brief This is the implementation file for the _LiveboxView class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FUi_TouchFlickGestureDetector.h" +#include "FShell_LiveboxView.h" +#include "FShell_LiveboxViewPresenter.h" +#include "FShell_LiveboxPopupView.h" +#include "FShell_LiveboxViewManager.h" +#include "FUiAnim_VisualElement.h" + +using namespace std; +using namespace Tizen::App; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Ui; +using namespace Tizen::Ui::Controls; +using namespace Tizen::Ui::Animations; +using namespace Tizen::Media; + +namespace Tizen { namespace Shell +{ + +const int ANIMATION_DURATION = 150; + +_LiveboxView::_LiveboxView(void) + : __pLiveboxViewPresenter(new (std::nothrow) _LiveboxViewPresenter(*this)) + , __pLivebox(null) + , __pLiveboxViewManager(null) + , __resizeFromRemote(false) + , __updated(false) +{ + __pLiveboxViewManager = _LiveboxViewManager::GetInstance(); + SysTryReturnVoidResult(NID_UI_CTRL, __pLiveboxViewManager, E_SYSTEM, "[E_SYSTEM] A system error occurred."); +} + +_LiveboxView::~_LiveboxView(void) +{ + __pLiveboxViewManager->RemoveLiveboxView(this); + + if (__pLiveboxPopupView) + { + __pLiveboxPopupView->RemoveLiveboxPopupEventListener(*this); + } + + if (__pTouchFlickGestureDetector) + { + RemoveGestureDetector(*__pTouchFlickGestureDetector); + } +} + +_LiveboxView* +_LiveboxView::CreateLiveboxViewN(void) +{ + unique_ptr<_LiveboxView> pLiveboxView(new (std::nothrow) _LiveboxView()); + SysTryReturn(NID_UI_CTRL, pLiveboxView, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + pLiveboxView->AcquireHandle(); + + SetLastResult(E_SUCCESS); + + return pLiveboxView.release(); +} + +result +_LiveboxView::Initialize(const String& appId, const Tizen::Graphics::Rectangle& rect, const String& userInfo) +{ + result r = SetBounds(rect); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pLiveboxViewPresenter->Initialize(appId); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + int width = 0; + int height = 0; + + unique_ptr pByteBuffer(_ImageDecoder::DecodeToBufferN(__pLiveboxViewPresenter->GetAppIconPath(), MEDIA_PIXEL_FORMAT_BGRA8888, width, height)); + unique_ptr pBitmap(_BitmapImpl::GetNonScaledBitmapN(*pByteBuffer.get(), Dimension(width, height), BITMAP_PIXEL_FORMAT_ARGB8888)); + + __pAppIconBitmap = move(pBitmap); + + unique_ptr<_TouchFlickGestureDetector> pTouchFlickGestureDetector(new (std::nothrow) _TouchFlickGestureDetector()); + SysTryReturn(NID_UI_CTRL, pTouchFlickGestureDetector, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pTouchFlickGestureDetector->SetDelayTouchEventEnabled(true); + + r = AddGestureDetector(*pTouchFlickGestureDetector.get()); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pTouchFlickGestureDetector->AddGestureListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTouchFlickGestureDetector = move(pTouchFlickGestureDetector); + + __pLivebox = __pLiveboxViewManager->AddLiveboxView(this, userInfo); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, __pLivebox, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +_LiveboxPopupView* +_LiveboxView::GetLiveboxPopup(void) const +{ + return __pLiveboxPopupView.get(); +} + +String +_LiveboxView::GetAppId(void) const +{ + return __pLiveboxViewPresenter->GetAppId(); +} + +Bitmap* +_LiveboxView::GetAppIconBitmap(void) const +{ + return __pAppIconBitmap.get(); +} + +Bitmap* +_LiveboxView::GetBitmap(void) const +{ + return __pBitmap.get(); +} + +bool +_LiveboxView::IsUpdated(void) const +{ + return __updated; +} + +livebox* +_LiveboxView::GetNativeLivebox(void) const +{ + return __pLivebox; +} + +result +_LiveboxView::OpenLiveboxPopup(void) +{ + result r = E_SUCCESS; + Dimension size = __pLiveboxViewManager->GetLiveboxPopupSize(__pLivebox); + Rectangle trayBounds(0, 0, size.width, size.height); + Rectangle absoluteBounds = GetAbsoluteBounds(); + + if (!__pLiveboxPopupView) + { + unique_ptr<_LiveboxPopupView> pLiveboxPopupView(_LiveboxPopupView::CreateLiveboxPopupN(*this)); + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pLiveboxPopupView, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pLiveboxPopupView->Initialize(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = pLiveboxPopupView->AddLiveboxPopupEventListener(*this); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxPopupView = move(pLiveboxPopupView); + } + + trayBounds.y = absoluteBounds.y + absoluteBounds.height; + + r = __pLiveboxPopupView->SetBounds(trayBounds); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pLiveboxPopupView->SetOwner(this); + + r = __pLiveboxPopupView->Open(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +void +_LiveboxView::GetTouchPostion(const Point& point, double& x, double& y) const +{ + Rectangle bounds = GetBounds(); + + x = static_cast(point.x) / static_cast(bounds.width); + y = static_cast(point.y) / static_cast(bounds.height); +} + +void +_LiveboxView::PlayClickAnimation(void) +{ + VisualElementPropertyAnimation animation; + animation.SetPropertyName(L"transform.scale.xy"); + animation.SetEndValue(Variant(FloatPoint(0.8f, 0.8f))); + animation.SetDuration(ANIMATION_DURATION); + animation.SetAutoReverseEnabled(true); + + _VisualElement* pVisualElement = GetVisualElement(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, r, "[%s] Propagating.", GetErrorMessage(r)); + + pVisualElement->AddAnimation(L"Scale", animation); +} + +void +_LiveboxView::PlayFlickAnimation(void) +{ + const int DISTANCE = 30; + + _VisualElement* pVisualElement = GetVisualElement(); + result r = GetLastResult(); + SysTryReturnVoidResult(NID_UI_CTRL, pVisualElement, r, "[%s] Propagating.", GetErrorMessage(r)); + + FloatRectangle startBounds(pVisualElement->GetBounds()); + FloatRectangle endBounds(startBounds); + endBounds.y = startBounds.y + DISTANCE; + + VisualElementPropertyAnimation animation; + animation.SetPropertyName(L"bounds"); + animation.SetStartValue(Variant(startBounds)); + animation.SetEndValue(Variant(endBounds)); + animation.SetDuration(ANIMATION_DURATION); + animation.SetAutoReverseEnabled(true); + + pVisualElement->AddAnimation(L"Scale", animation); +} + +result +_LiveboxView::OnAttachedToMainTree(void) +{ + result r = E_SUCCESS; + + return r; +} + +result +_LiveboxView::OnDetachingFromMainTree(void) +{ + result r = E_SUCCESS; + + return r; +} + +bool +_LiveboxView::OnFlickGestureDetected(_TouchFlickGestureDetector& gesture) +{ + PlayFlickAnimation(); + + _FlickDirection direction = gesture.GetDirection(); + if (direction == _FLICK_DIRECTION_DOWN) + { + OpenLiveboxPopup(); + } + + return false; +} + +bool +_LiveboxView::OnFlickGestureCanceled(_TouchFlickGestureDetector& gesture) +{ + return false; +} + +void +_LiveboxView::OnBoundsChanged(void) +{ + Dimension size(GetSize()); + + if (!__resizeFromRemote) + { + __pLiveboxViewManager->SetLiveboxSize(*this, size); + __updated = false; + } +} + +bool +_LiveboxView::OnTouchPressed(const _Control& source, const _TouchInfo& touchInfo) +{ + int type = livebox_lb_type(__pLivebox); + if ((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) + { + double x = 0.0f; + double y = 0.0f; + GetTouchPostion(touchInfo.GetCurrentPosition(), x, y); + + livebox_content_event(__pLivebox, LB_MOUSE_DOWN, x, y); + } + + return false; +} + +bool +_LiveboxView::OnTouchReleased(const _Control& source, const _TouchInfo& touchInfo) +{ + Rectangle clientBounds(GetClientBounds()); + Point touchPoint(touchInfo.GetCurrentPosition()); + + if (clientBounds.Contains(touchPoint)) + { + PlayClickAnimation(); + } + + double x = 0.0f; + double y = 0.0f; + GetTouchPostion(touchInfo.GetCurrentPosition(), x, y); + + int type = livebox_lb_type(__pLivebox); + if ((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) + { + livebox_content_event(__pLivebox, LB_MOUSE_UP, x, y); + } + else + { + livebox_click(__pLivebox, x, y); + } + + return false; +} + +bool +_LiveboxView::OnTouchMoved(const _Control& source, const _TouchInfo& touchInfo) +{ + int type = livebox_lb_type(__pLivebox); + if ((type == LB_TYPE_BUFFER) || (type == LB_TYPE_PIXMAP)) + { + double x = 0.0f; + double y = 0.0f; + GetTouchPostion(touchInfo.GetCurrentPosition(), x, y); + + livebox_content_event(__pLivebox, LB_MOUSE_MOVE, x, y); + } + + return false; +} + +void +_LiveboxView::OnLiveboxPopupViewOpened(void) +{ +} + +void +_LiveboxView::OnLiveboxPopupViewClosed(void) +{ +} + +void +_LiveboxView::OnDraw(void) +{ + __pLiveboxViewPresenter->Draw(); +} + +void +_LiveboxView::OnLiveboxUpdated(const Bitmap& bitmap, const Dimension& size) +{ + __resizeFromRemote = true; + SetSize(size); + __resizeFromRemote = false; + __updated = true; + + __pBitmap.reset(const_cast(&bitmap)); + + Invalidate(false); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxView.h b/src/FShell_LiveboxView.h new file mode 100644 index 0000000..43678ef --- /dev/null +++ b/src/FShell_LiveboxView.h @@ -0,0 +1,118 @@ +// +// 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 FShell_LiveboxView.h + * @brief This is the header file for the _LiveboxView class. + * + * This header file contains the declarations of the %_LiveboxView class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_VIEW_H_ +#define _FSHL_INTERNAL_LIVEBOX_VIEW_H_ + +#include +#include "FUi_Control.h" +#include "FUi_ITouchFlickGestureEventListener.h" +#include "FShell_ILiveboxPopupViewEventListener.h" + +namespace Tizen { namespace Base +{ +class String; +}} // Tizen::Base + +namespace Tizen { namespace Graphics +{ +class Bitmap; +class Dimension; +class Point; +}} // Tizen::Graphics + +namespace Tizen { namespace Ui +{ +class _TouchFlickGestureDetector; +}} // Tizen::Ui + +namespace Tizen { namespace Shell +{ + +class _LiveboxViewPresenter; +class _LiveboxPopupView; + +/** + * @class _LiveboxView + * @brief + * @since 2.1 + */ +class _LiveboxView + : public Tizen::Ui::_Control + , public Tizen::Ui::_ITouchFlickGestureEventListener + , public _ILiveboxPopupViewEventListener +{ +public: + static _LiveboxView* CreateLiveboxViewN(void); + virtual ~_LiveboxView(void); + + result Initialize(const Tizen::Base::String& appId, const Tizen::Graphics::Rectangle& rect, const Tizen::Base::String& userInfo); + _LiveboxPopupView* GetLiveboxPopup(void) const; + Tizen::Base::String GetAppId(void) const; + Tizen::Graphics::Bitmap* GetAppIconBitmap(void) const; + Tizen::Graphics::Bitmap* GetBitmap(void) const; + bool IsUpdated(void) const; + +protected: + _LiveboxView(void); + +private: + _LiveboxView(const _LiveboxView& rhs); + _LiveboxView& operator =(const _LiveboxView& rhs); + + struct livebox* GetNativeLivebox(void) const; + result OpenLiveboxPopup(void); + void GetTouchPostion(const Tizen::Graphics::Point& point, double& x, double& y) const; + void PlayClickAnimation(void); + void PlayFlickAnimation(void); + + virtual result OnAttachedToMainTree(void); + virtual result OnDetachingFromMainTree(void); + virtual bool OnFlickGestureDetected(Tizen::Ui::_TouchFlickGestureDetector& gesture); + virtual bool OnFlickGestureCanceled(Tizen::Ui::_TouchFlickGestureDetector& gesture); + virtual void OnBoundsChanged(void); + virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); + virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); + virtual bool OnTouchMoved(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchInfo); + virtual void OnLiveboxPopupViewOpened(void); + virtual void OnLiveboxPopupViewClosed(void); + virtual void OnDraw(void); + + void OnLiveboxUpdated(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Dimension& size); + +private: + std::unique_ptr<_LiveboxViewPresenter> __pLiveboxViewPresenter; + std::unique_ptr __pBitmap; + std::unique_ptr __pAppIconBitmap; + struct livebox* __pLivebox; + friend class _LiveboxViewManager; + class _LiveboxViewManager* __pLiveboxViewManager; + friend class _LiveboxPopupView; + std::unique_ptr<_LiveboxPopupView> __pLiveboxPopupView; + std::unique_ptr __pTouchFlickGestureDetector; + bool __resizeFromRemote; + bool __updated; +}; // _LiveboxView + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_VIEW_H_ diff --git a/src/FShell_LiveboxViewImpl.cpp b/src/FShell_LiveboxViewImpl.cpp new file mode 100644 index 0000000..a49a2b0 --- /dev/null +++ b/src/FShell_LiveboxViewImpl.cpp @@ -0,0 +1,110 @@ +// +// 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. +// + +#include +#include +#include +#include +#include +#include "FShell_LiveboxViewImpl.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; + +namespace Tizen { namespace Shell +{ + +const _LiveboxViewImpl* +_LiveboxViewImpl::GetInstance(const LiveboxView& liveBoxView) +{ + return static_cast(_ControlImpl::GetInstance(liveBoxView)); +} + +_LiveboxViewImpl* +_LiveboxViewImpl::GetInstance(LiveboxView& liveBoxView) +{ + return static_cast<_LiveboxViewImpl*>(_ControlImpl::GetInstance(liveBoxView)); +} + +_LiveboxViewImpl* +_LiveboxViewImpl::CreateLiveboxViewImplN(LiveboxView& liveBoxView) +{ + unique_ptr<_LiveboxView> pCore(_LiveboxView::CreateLiveboxViewN()); + result r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, pCore, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + unique_ptr<_LiveboxViewImpl> pImpl(new (std::nothrow) _LiveboxViewImpl(&liveBoxView, pCore.get())); + SysTryReturn(NID_UI_CTRL, pImpl, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pCore.release(); + + r = GetLastResult(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + return pImpl.release(); +} + +_LiveboxViewImpl::_LiveboxViewImpl(LiveboxView* pPublic, _LiveboxView* pCore) + : _ContainerImpl(pPublic, pCore) +{ +} + +_LiveboxViewImpl::~_LiveboxViewImpl(void) +{ +} + +const char* +_LiveboxViewImpl::GetPublicClassName(void) const +{ + return "Tizen::Shell::LiveboxView"; +} + +const LiveboxView& +_LiveboxViewImpl::GetPublic(void) const +{ + return static_cast(_ControlImpl::GetPublic()); +} + +LiveboxView& +_LiveboxViewImpl::GetPublic(void) +{ + return static_cast(_ControlImpl::GetPublic()); +} + +const _LiveboxView& +_LiveboxViewImpl::GetCore(void) const +{ + return static_cast(_ControlImpl::GetCore()); +} + +_LiveboxView& +_LiveboxViewImpl::GetCore(void) +{ + return static_cast<_LiveboxView&>(_ControlImpl::GetCore()); +} + +result +_LiveboxViewImpl::Initialize(const String& appId, const Tizen::Graphics::Rectangle& rect, const String& userInfo) +{ + result r = GetCore().Initialize(appId, rect, userInfo); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return r; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxViewImpl.h b/src/FShell_LiveboxViewImpl.h new file mode 100644 index 0000000..bba5e55 --- /dev/null +++ b/src/FShell_LiveboxViewImpl.h @@ -0,0 +1,65 @@ +// +// 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. +// +#ifndef _FSHL_INTERNAL_LIVEBOX_VIEW_IMPL_H_ +#define _FSHL_INTERNAL_LIVEBOX_VIEW_IMPL_H_ + +#include +#include "FUi_ContainerImpl.h" +#include "FShell_LiveboxView.h" + +namespace Tizen { namespace Base +{ +class String; +}} + +namespace Tizen { namespace Graphics +{ +class Point; +}} + +namespace Tizen { namespace Shell +{ + +class _LiveboxViewImpl + : public Tizen::Ui::_ContainerImpl +{ +public: + static _LiveboxViewImpl* CreateLiveboxViewImplN(LiveboxView& liveBoxView); + static const _LiveboxViewImpl* GetInstance(const LiveboxView& liveBoxView); + static _LiveboxViewImpl* GetInstance(LiveboxView& liveBoxView); + + virtual ~_LiveboxViewImpl(void); + + virtual const char* GetPublicClassName(void) const; + virtual const LiveboxView& GetPublic(void) const; + virtual LiveboxView& GetPublic(void); + virtual const _LiveboxView& GetCore(void) const; + virtual _LiveboxView& GetCore(void); + + result Initialize(const Tizen::Base::String& appId, const Tizen::Graphics::Rectangle& rect, const Tizen::Base::String& userInfo); + +protected: + _LiveboxViewImpl(LiveboxView* pPublic, _LiveboxView* pCore); + +private: + _LiveboxViewImpl(const _LiveboxViewImpl& rhs); + _LiveboxViewImpl& operator =(const _LiveboxViewImpl& rhs); +}; // _LiveboxViewImpl + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_VIEW_IMPL_H_ diff --git a/src/FShell_LiveboxViewManager.cpp b/src/FShell_LiveboxViewManager.cpp new file mode 100644 index 0000000..190beb0 --- /dev/null +++ b/src/FShell_LiveboxViewManager.cpp @@ -0,0 +1,487 @@ +// +// 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 FShell_LiveboxViewManager.cpp + * @brief This is the implementation file for the _LiveboxView class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "FShell_LiveboxViewManager.h" +#include "FShell_LiveboxView.h" +#include "FShell_LiveboxPopupView.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::Graphics; +using namespace Tizen::Media; + +namespace Tizen { namespace Graphics +{ +result _CreateCoordinateTransformer(_ICoordinateSystemTransformer*&, _LogicalResolution, _BaseScreenSize, _PhysicalResolution, _BaseScreenSize); +} } // Tizen::Graphics + +namespace Tizen { namespace Shell +{ + +const int LIVEBOX_SIZE_1 = 175; +const int LIVEBOX_SIZE_2 = 354; +const int LIVEBOX_SIZE_4 = 712; + +struct _LiveboxSizeInfo +{ + int type; + int width; + int height; +}; + +const _LiveboxSizeInfo LIVEBOX_SIZE_INFO[] = +{ + { LB_SIZE_TYPE_1x1, LIVEBOX_SIZE_1, LIVEBOX_SIZE_1 }, + { LB_SIZE_TYPE_2x1, LIVEBOX_SIZE_2, LIVEBOX_SIZE_1 }, + { LB_SIZE_TYPE_2x2, LIVEBOX_SIZE_2, LIVEBOX_SIZE_2 }, + { LB_SIZE_TYPE_4x1, LIVEBOX_SIZE_4, LIVEBOX_SIZE_1 }, + { LB_SIZE_TYPE_4x2, LIVEBOX_SIZE_4, LIVEBOX_SIZE_2 }, + { LB_SIZE_TYPE_4x4, LIVEBOX_SIZE_4, LIVEBOX_SIZE_4 } + +}; + +_LiveboxViewManager* +_LiveboxViewManager::GetInstance(void) +{ + static _LiveboxViewManager instance; + return &instance; +} + +livebox* +_LiveboxViewManager::AddLiveboxView(_LiveboxView* pLiveboxView, const String& userInfo) +{ + SysTryReturn(NID_UI_CTRL, pLiveboxView, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + unique_ptr pAppId(_StringConverter::CopyToCharArrayN(pLiveboxView->GetAppId())); + SysTryReturn(NID_UI_CTRL, pAppId, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + unique_ptr pContent(_StringConverter::CopyToCharArrayN(userInfo)); + SysTryReturn(NID_UI_CTRL, pContent, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + const char* pCluster = "user,created"; + const char* pCategory = "default"; + + livebox* pLivebox = livebox_add_with_size(pAppId.get(), pContent.get(), pCluster, pCategory, GetLiveboxSizeType(pLiveboxView->GetSize()), 1, OnLiveboxAdded, this); + SysTryReturn(NID_UI_CTRL, pLivebox, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); +/* + livebox* pLivebox = livebox_add(pAppId.get(), pContent.get(), pCluster, pCategory, 1, OnLiveboxAdded, this); + SysTryReturn(NID_UI_CTRL, pLivebox, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); +*/ + __pViewMap->Add(pLivebox, pLiveboxView); + + return pLivebox; +} + +void +_LiveboxViewManager::RemoveLiveboxView(_LiveboxView* pLiveboxView) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxView, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + livebox* pLivebox = pLiveboxView->GetNativeLivebox(); + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + __pViewMap->Remove(pLivebox); + + livebox_del(pLivebox, OnLiveboxDeleted, this); + + __pViewMap->Remove(pLivebox); +} + +_LiveboxView* +_LiveboxViewManager::GetLiveboxView(livebox* pLivebox) const +{ + _LiveboxView* pLiveboxView = null; + __pViewMap->GetValue(pLivebox, pLiveboxView); + + return pLiveboxView; +} + +Dimension +_LiveboxViewManager::GetLiveboxSize(livebox* pLivebox) const +{ + SysTryReturn(NID_UI_CTRL, pLivebox, Dimension(0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + int width = 0; + int height = 0; + + int type = livebox_size(pLivebox); + livebox_service_get_size(type, &width, &height); + + return Dimension(width, height); +} + +Dimension +_LiveboxViewManager::GetLiveboxPopupSize(livebox* pLivebox) const +{ + SysTryReturn(NID_UI_CTRL, pLivebox, Dimension(0, 0), E_SYSTEM, "[E_SYSTEM] A system error occurred."); + + int width = 0; + int height = 0; + + livebox_get_pdsize(pLivebox, &width, &height); + + return Dimension(width, height); +} + +void +_LiveboxViewManager::SetLiveboxSize(const _LiveboxView& liveboxView, const Dimension& size) +{ + livebox* pLivebox = liveboxView.GetNativeLivebox(); + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + int sizeType = GetLiveboxSizeType(size); + + livebox_resize(pLivebox, sizeType, OnLiveboxResized, this); +} + +_LiveboxViewManager::_LiveboxViewManager(void) +{ +// _LogicalResolution sourceResolution = RESOLUTION_LOGICAL_720; +// _PhysicalResolution destResolution = _CoordinateSystem::GetInstance()->GetPhysicalResolution(); + + livebox_init(ecore_x_display_get()); + livebox_subscribe_group("*", "*"); + + __eventHandler.reset(livebox_set_event_handler(OnLiveboxEventReceived, this)); + SysTryReturnVoidResult(NID_UI_CTRL, __eventHandler == 0, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + __faultEventHandler.reset(livebox_set_fault_handler(OnLiveboxFaultReceived, this)); + SysTryReturnVoidResult(NID_UI_CTRL, __faultEventHandler == 0, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + unique_ptr > pViewMap(new (std::nothrow) HashMapT); + SysTryReturnVoidResult(NID_UI_CTRL, pViewMap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pViewMap->Construct(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pViewMap = move(pViewMap); + +// r = _CreateCoordinateTransformer(__pCoordinateTransformer, sourceResolution, BASE_SCREEN_SIZE_NORMAL, destResolution, BASE_SCREEN_SIZE_NORMAL); +// SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r)); +} + +_LiveboxViewManager::~_LiveboxViewManager(void) +{ +} + +int +_LiveboxViewManager::GetLiveboxSizeType(const Tizen::Graphics::Dimension& size) const +{ + int sizeType = LB_SIZE_TYPE_UNKNOWN; + + int sizetypeCount = sizeof(LIVEBOX_SIZE_INFO) / sizeof(_LiveboxSizeInfo); + for ( int i = 0; i < sizetypeCount; ++ i) + { + if (size.width <= LIVEBOX_SIZE_INFO[i].width && size.height <= LIVEBOX_SIZE_INFO[i].height) + { + sizeType = LIVEBOX_SIZE_INFO[i].type; + break; + } + } + + SysLog(NID_UI_CTRL, "[%d %d] type [%d][%d]", size.width, size.height, sizeType, sizetypeCount); + + return sizeType; +} + +MediaPixelFormat +_LiveboxViewManager::GetPixelFormat(BitmapPixelFormat format) const +{ + MediaPixelFormat out = MEDIA_PIXEL_FORMAT_NONE; + + switch(format) + { + case BITMAP_PIXEL_FORMAT_RGB565: + out = MEDIA_PIXEL_FORMAT_RGB565LE; + break; + + case BITMAP_PIXEL_FORMAT_ARGB8888: + out = MEDIA_PIXEL_FORMAT_BGRA8888; + break; + + case BITMAP_PIXEL_FORMAT_R8G8B8A8: + out = MEDIA_PIXEL_FORMAT_RGBA8888; + break; + + default: + break; + } + + return out; +} + +Bitmap* +_LiveboxViewManager::GetBitmapN(const String& fileName) const +{ + int width = 0; + int height = 0; + + MediaPixelFormat format = GetPixelFormat(BITMAP_PIXEL_FORMAT_ARGB8888); + + unique_ptr pByteBuffer(_ImageDecoder::DecodeToBufferN(fileName, format, width, height)); + SysTryReturn(NID_UI_CTRL, pByteBuffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + unique_ptr pBitmap(_BitmapImpl::GetNonScaledBitmapN(*pByteBuffer, Dimension(width, height), BITMAP_PIXEL_FORMAT_ARGB8888)); + SysTryReturn(NID_UI_CTRL, pBitmap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + return pBitmap.release(); +} + +Bitmap* +_LiveboxViewManager::GetBitmapN(void* pBuffer, const Dimension& size) const +{ + SysTryReturn(NID_UI_CTRL, pBuffer, null, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + byte* pTempBuffer = static_cast(pBuffer); + const int BITS_PER_PIXEL = 32; + int length = size.width * size.height * BITS_PER_PIXEL / 8; + + unique_ptr pByteBuffer(new (std::nothrow) ByteBuffer()); + SysTryReturn(NID_UI_CTRL, pByteBuffer, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pByteBuffer->Construct(pTempBuffer, 0, length, length); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r)); + + unique_ptr pBitmap(_BitmapImpl::GetNonScaledBitmapN(*pByteBuffer.get(), Dimension(size.width, size.height), BITMAP_PIXEL_FORMAT_ARGB8888)); + SysTryReturn(NID_UI_CTRL, pBitmap, null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + return pBitmap.release(); +} + +void +_LiveboxViewManager::OnLiveboxCreated(livebox* pLivebox) +{ +} + +void +_LiveboxViewManager::OnLiveboxUpdated(livebox* pLivebox) +{ + _LiveboxView* pLiveboxView = GetLiveboxView(pLivebox); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxView, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + int type = livebox_lb_type(pLivebox); + + SysLog(NID_UI_CTRL, "type (%d)", type); + + switch (type) + { + case LB_TYPE_IMAGE: + { + unique_ptr pBitmap(GetBitmapN(livebox_filename(pLivebox))); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pLiveboxView->OnLiveboxUpdated(*pBitmap.get(), GetLiveboxSize(pLivebox)); + pBitmap.release(); + } + break; + + case LB_TYPE_BUFFER: + case LB_TYPE_PIXMAP: + { + void* pBuffer = livebox_acquire_fb(pLivebox); + SysTryReturnVoidResult(NID_UI_CTRL, pBuffer, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + Dimension sourceSize = GetLiveboxSize(pLivebox); + unique_ptr pBitmap(GetBitmapN(pBuffer, sourceSize)); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pLiveboxView->OnLiveboxUpdated(*pBitmap.get(), sourceSize); + livebox_release_fb(pBuffer); + pBitmap.release(); + } + break; + + case LB_TYPE_TEXT: + break; + + default: + break; + } +} + +void +_LiveboxViewManager::OnLiveboxDeleted(livebox* pLivebox) +{ +} + +void +_LiveboxViewManager::OnLiveboxPinUpChanged(livebox* pLivebox) +{ +} + +void +_LiveboxViewManager::OnLiveboxPopupUpdated(livebox* pLivebox) +{ + _LiveboxView* pLiveboxView = GetLiveboxView(pLivebox); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxView, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + _LiveboxPopupView* pLiveboxPopupView = pLiveboxView->GetLiveboxPopup(); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxPopupView, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + int type = livebox_pd_type(pLivebox); + + SysLog(NID_UI_CTRL, "type (%d)", type); + + switch (type) + { + case PD_TYPE_TEXT: + break; + + case PD_TYPE_BUFFER: + case PD_TYPE_PIXMAP: + { + void* pBuffer = livebox_acquire_pdfb(pLivebox); + SysTryReturnVoidResult(NID_UI_CTRL, pBuffer, E_SYSTEM, "[E_SYSTEM] A system error occured."); + + Dimension sourceSize = GetLiveboxPopupSize(pLivebox); + unique_ptr pBitmap(GetBitmapN(pBuffer, sourceSize)); + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pLiveboxPopupView->OnLiveboxUpdated(*pBitmap.get(), sourceSize); + livebox_release_pdfb(pBuffer); + pBitmap.release(); + } + break; + + default: + break; + } +} + +int +_LiveboxViewManager::OnLiveboxEventReceived(livebox* pLivebox, livebox_event_type eventType, void* pData) +{ + SysTryReturn(NID_UI_CTRL, pLivebox, EXIT_SUCCESS, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxViewManager* pLiveboxViewManager = static_cast<_LiveboxViewManager*>(pData); + SysTryReturn(NID_UI_CTRL, pLiveboxViewManager, EXIT_SUCCESS, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + switch (eventType) + { + case LB_EVENT_LB_UPDATED: + pLiveboxViewManager->OnLiveboxUpdated(pLivebox); + break; + + case LB_EVENT_PD_UPDATED: + pLiveboxViewManager->OnLiveboxPopupUpdated(pLivebox); + break; + + case LB_EVENT_CREATED: + pLiveboxViewManager->OnLiveboxCreated(pLivebox); + break; + + case LB_EVENT_DELETED: + pLiveboxViewManager->OnLiveboxDeleted(pLivebox); + break; + + case LB_EVENT_GROUP_CHANGED: + break; + + case LB_EVENT_PINUP_CHANGED: + pLiveboxViewManager->OnLiveboxPinUpChanged(pLivebox); + break; + + case LB_EVENT_PERIOD_CHANGED: + break; + + default: + SysLog(NID_UI_CTRL, "Not supported event type: %d", eventType); + break; + } + + return EXIT_SUCCESS; +} + +int +_LiveboxViewManager::OnLiveboxFaultReceived(livebox_fault_type faultType, const char* pAppId, const char* pFilename, const char* pFuncName, void* pData) +{ + if (faultType == LB_FAULT_DEACTIVATED) + { + SysLog(NID_UI_CTRL, "type (%d) packageName (%s) fileName (%s) funcName (%s)", faultType, pAppId, pFilename, pFuncName); + livebox_activate(pAppId, OnLiveboxActivated, pData); + } + + return EXIT_SUCCESS; +} + +void +_LiveboxViewManager::OnLiveboxActivated(livebox* pLivebox, int ret, void* pData) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxViewManager* pLiveboxViewManager = static_cast<_LiveboxViewManager*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); +} + +void +_LiveboxViewManager::OnLiveboxAdded(livebox* pLivebox, int ret, void* pData) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxViewManager* pLiveboxViewManager = static_cast<_LiveboxViewManager*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); +} + +void +_LiveboxViewManager::OnLiveboxDeleted(livebox* pLivebox, int ret, void* pData) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxViewManager* pLiveboxViewManager = static_cast<_LiveboxViewManager*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); +} + +void +_LiveboxViewManager::OnLiveboxResized(livebox* pLivebox, int ret, void* pData) +{ + SysTryReturnVoidResult(NID_UI_CTRL, pLivebox, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + SysTryReturnVoidResult(NID_UI_CTRL, ret == 0, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + _LiveboxViewManager* pLiveboxViewManager = static_cast<_LiveboxViewManager*>(pData); + SysTryReturnVoidResult(NID_UI_CTRL, pLiveboxViewManager, E_INVALID_ARG, "[E_INVALID_ARG] The argument is invalid."); + + pLiveboxViewManager->OnLiveboxUpdated(pLivebox); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxViewManager.h b/src/FShell_LiveboxViewManager.h new file mode 100644 index 0000000..8304940 --- /dev/null +++ b/src/FShell_LiveboxViewManager.h @@ -0,0 +1,122 @@ +// +// 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 FShell_LiveboxViewManager.h + * @brief This is the header file for the _LiveboxViewManager class. + * + * This header file contains the declarations of the %_LiveboxViewManager class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_VIEW_MANAGER_H_ +#define _FSHL_INTERNAL_LIVEBOX_VIEW_MANAGER_H_ + +#include +#include +#include + +struct livebox; + +namespace Tizen { namespace Base +{ +class String; +}} + +namespace Tizen { namespace Base { namespace Collection +{ +template class HashMapT; +}}} + +namespace Tizen { namespace Graphics +{ +class Bitmap; +class Dimension; +class _ICoordinateSystemTransformer; +}} // Tizen::Graphics + +namespace Tizen { namespace Shell +{ +class _LiveboxView; + +/** + * @class _LiveboxViewManager + * @brief + * @since 2.1 + */ +class _LiveboxViewManager +{ +public: + static _LiveboxViewManager* GetInstance(void); + livebox* AddLiveboxView(_LiveboxView* pLiveboxView, const Tizen::Base::String& userInfo); + void RemoveLiveboxView(_LiveboxView* pLiveboxView); + _LiveboxView* GetLiveboxView(livebox* pLivebox) const; + Tizen::Graphics::Dimension GetLiveboxSize(livebox* pLivebox) const; + Tizen::Graphics::Dimension GetLiveboxPopupSize(livebox* pLivebox) const; + void SetLiveboxSize(const _LiveboxView& liveboxView, const Tizen::Graphics::Dimension& size); + +private: + _LiveboxViewManager(void); + ~_LiveboxViewManager(void); + _LiveboxViewManager(const _LiveboxViewManager& rhs); + _LiveboxViewManager& operator =(const _LiveboxViewManager& rhs); + + int GetLiveboxSizeType(const Tizen::Graphics::Dimension& size) const; + Tizen::Media::MediaPixelFormat GetPixelFormat(Tizen::Graphics::BitmapPixelFormat format) const; + Tizen::Graphics::Bitmap* GetBitmapN(const Tizen::Base::String& fileName) const; + Tizen::Graphics::Bitmap* GetBitmapN(void* pBuffer, const Tizen::Graphics::Dimension& size) const; + + void OnLiveboxCreated(livebox* pLivebox); + void OnLiveboxUpdated(livebox* pLivebox); + void OnLiveboxDeleted(livebox* pLivebox); + void OnLiveboxPinUpChanged(livebox* pLivebox); + void OnLiveboxPopupUpdated(livebox* pLivebox); + + static int OnLiveboxEventReceived(livebox* pLivebox, livebox_event_type eventType, void* pData); + static int OnLiveboxFaultReceived(livebox_fault_type faultType, const char* pAppId, const char* pFilename, const char *pFuncName, void* pData); + static void OnLiveboxActivated(livebox* pLivebox, int ret, void* pData); + static void OnLiveboxAdded(livebox* pLivebox, int ret, void* pData); + static void OnLiveboxDeleted(livebox *pLivebox, int ret, void* pData); + static void OnLiveboxResized(livebox* pLivebox, int ret, void* pData); + +private: + struct _EventHandlerDeleter + { + typedef int pointer; + + void operator()(int) + { + livebox_unset_event_handler(OnLiveboxEventReceived); + } + }; + + struct _FaultEventHandlerDeleter + { + typedef int pointer; + + void operator()(int) + { + livebox_unset_fault_handler(OnLiveboxFaultReceived); + } + }; + + std::unique_ptr > __pViewMap; + std::unique_ptr __pCoordinateTransformer; + std::unique_ptr __eventHandler; + std::unique_ptr __faultEventHandler; +}; + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_VIEW_MANAGER_H_ diff --git a/src/FShell_LiveboxViewModel.cpp b/src/FShell_LiveboxViewModel.cpp new file mode 100644 index 0000000..80082ef --- /dev/null +++ b/src/FShell_LiveboxViewModel.cpp @@ -0,0 +1,101 @@ +// +// 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 FShell_LiveboxViewModel.cpp + * @brief This is the implementation file for the _LiveboxViewModel class. + */ + +#include +#include +#include +#include +#include +#include +#include "FShell_LiveboxViewModel.h" + +using namespace std; +using namespace Tizen::App; +using namespace Tizen::Base; + +namespace Tizen { namespace Shell +{ + +_LiveboxViewModel::_LiveboxViewModel(void) +{ +} + +_LiveboxViewModel::~_LiveboxViewModel(void) +{ +} + +void +_LiveboxViewModel::SetAppId(const Tizen::Base::String& appId) +{ + __appId = appId; + + PackageInfo packageInfo; + + result r = _PackageManagerImpl::GetInstance()->GetAppPackageInfo(PACKAGE_TYPE_OSP, appId, packageInfo); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __appName = packageInfo.GetAppName(); + __appIconPath = packageInfo.GetAppIconPath(); + + if (__appIconPath.IsEmpty() || __appIconPath.Equals(L"(null)", false)) + { + ail_appinfo_h ai; + unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); + SysTryReturnVoidResult(NID_UI_CTRL, pAppId, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + ail_error_e ret = ail_get_appinfo(pAppId.get(), &ai); + result r = E_SYSTEM; + SysTryReturnVoidResult(NID_UI_CTRL, ret == AIL_ERROR_OK, r, "[%s] Propagating.", GetErrorMessage(r)); + + char* pAppIconPath = null; + ret = ail_appinfo_get_str(ai, AIL_PROP_ICON_STR, &pAppIconPath); + + if (pAppIconPath) + { + String iconPath(pAppIconPath); + __appIconPath = iconPath; + } + + ail_destroy_appinfo(ai); + } + + SysLog(NID_UI_CTRL, "(%ls %s)", __appName.GetPointer(), __appIconPath.GetPointer()); +} + +String +_LiveboxViewModel::GetAppId(void) const +{ + return __appId; +} + +String +_LiveboxViewModel::GetAppName(void) const +{ + return __appName; +} + +String +_LiveboxViewModel::GetAppIconPath(void) const +{ + return __appIconPath; +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxViewModel.h b/src/FShell_LiveboxViewModel.h new file mode 100644 index 0000000..1e2cec8 --- /dev/null +++ b/src/FShell_LiveboxViewModel.h @@ -0,0 +1,57 @@ +// +// 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 FShell_LiveboxViewModel.h + * @brief This is the header file for the _LiveboxViewModel class. + * + * This header file contains the declarations of the %_LiveboxViewModel class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_VIEW_MODEL_H_ +#define _FSHL_INTERNAL_LIVEBOX_VIEW_MODEL_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class _LiveboxViewModel + : public Tizen::Base::Object +{ +public: + _LiveboxViewModel(void); + virtual ~_LiveboxViewModel(void); + +public: + void SetAppId(const Tizen::Base::String& appId); + Tizen::Base::String GetAppId(void) const; + Tizen::Base::String GetAppName(void) const; + Tizen::Base::String GetAppIconPath(void) const; + +private: + _LiveboxViewModel(const _LiveboxViewModel& rhs); + _LiveboxViewModel& operator =(const _LiveboxViewModel& rhs); + +private: + Tizen::Base::String __appId; + Tizen::Base::String __appName; + Tizen::Base::String __appIconPath; +}; // _LiveboxViewModel + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_VIEW_MODEL_H_ diff --git a/src/FShell_LiveboxViewPresenter.cpp b/src/FShell_LiveboxViewPresenter.cpp new file mode 100644 index 0000000..c18c22a --- /dev/null +++ b/src/FShell_LiveboxViewPresenter.cpp @@ -0,0 +1,175 @@ +// +// 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 FShell_LiveboxViewPresenter.cpp + * @brief This is the implementation file for the _LiveboxViewPresenter class. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include "FShell_LiveboxViewPresenter.h" +#include "FShell_LiveboxView.h" +#include "FShell_LiveboxViewModel.h" + +using namespace std; +using namespace Tizen::Base; +using namespace Tizen::Graphics; +using namespace Tizen::Graphics::_Text; + +namespace Tizen { namespace Shell +{ + +_LiveboxViewPresenter::_LiveboxViewPresenter(const _LiveboxView& liveBoxView) + : __pLiveboxView(const_cast <_LiveboxView*>(&liveBoxView)) + , __pLiveboxViewModel(new (std::nothrow) _LiveboxViewModel()) +{ + SysTryReturnVoidResult(NID_UI_CTRL, __pLiveboxViewModel, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); +} + +_LiveboxViewPresenter::~_LiveboxViewPresenter(void) +{ + __pLiveboxView = null; +} + +result +_LiveboxViewPresenter::Initialize(const String& appId) +{ + const int FONT_SIZE = 10; + + __pLiveboxViewModel->SetAppId(appId); + + unique_ptr pFont(new (std::nothrow) Font()); + SysTryReturn(NID_UI_CTRL, pFont, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = pFont->Construct(FONT_STYLE_PLAIN, FONT_SIZE); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + std::unique_ptr pTextObject(new (std::nothrow) TextObject()); + SysTryReturn(NID_UI_CTRL, pTextObject, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + r = pTextObject->Construct(); + SysTryReturn(NID_UI_CTRL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + pTextObject->SetWrap(TEXT_OBJECT_WRAP_TYPE_WORD); + pTextObject->SetAction(TEXT_OBJECT_ACTION_TYPE_ABBREV); + + __pFont = move(pFont); + __pTextObject = move(pTextObject); + + return r; +} + +String +_LiveboxViewPresenter::GetAppId(void) const +{ + return __pLiveboxViewModel->GetAppId(); +} + +String +_LiveboxViewPresenter::GetAppName(void) const +{ + return __pLiveboxViewModel->GetAppName(); +} + +String +_LiveboxViewPresenter::GetAppIconPath(void) const +{ + return __pLiveboxViewModel->GetAppIconPath(); +} + +void +_LiveboxViewPresenter::Draw(void) +{ + Bitmap* pBitmap = null; + bool updated = __pLiveboxView->IsUpdated(); + + if (updated) + { + pBitmap = __pLiveboxView->GetBitmap(); + } + else + { + pBitmap = __pLiveboxView->GetAppIconBitmap(); + } + + SysTryReturnVoidResult(NID_UI_CTRL, pBitmap, E_SYSTEM, "Bitmap is invalid."); + + Dimension liveboxSize = __pLiveboxView->GetSize(); + int bitmapWidth = pBitmap->GetWidth(); + int bitmapHeight = pBitmap->GetHeight(); + + Point point(0, 0); + + if (!updated) + { + if (liveboxSize.width != bitmapWidth) + { + point.x = (liveboxSize.width / 2) - (bitmapWidth / 2); + } + + if (liveboxSize.height != bitmapHeight) + { + point.y = (liveboxSize.height / 2) - (bitmapHeight / 2); + } + } + + unique_ptr pCanvas(__pLiveboxView->GetCanvasN()); + SysTryReturnVoidResult(NID_UI_CTRL, pCanvas, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + pCanvas->DrawBitmap(point, *pBitmap); + + if (!updated) + { + DrawText(*pCanvas); + } +} + +void +_LiveboxViewPresenter::DrawText(Canvas& canvas) +{ + const int TEXT_OBJECT_HEIGHT = 20; + + String appName(GetAppName()); + + unique_ptr pSimpleText(new (std::nothrow) TextSimple(appName.GetPointer(), appName.GetLength())); + SysTryReturnVoidResult(NID_UI_CTRL, pSimpleText, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory is insufficient."); + + result r = __pTextObject->AppendElement(*pSimpleText); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + Rectangle liveboxBounds(__pLiveboxView->GetBounds()); + + __pTextObject->SetBounds(Rectangle(0, liveboxBounds.height - TEXT_OBJECT_HEIGHT, liveboxBounds.width, TEXT_OBJECT_HEIGHT)); + __pTextObject->SetAlignment(TEXT_OBJECT_ALIGNMENT_CENTER | TEXT_OBJECT_ALIGNMENT_MIDDLE); + __pTextObject->SetFont(__pFont.get(), 0, __pTextObject->GetTextLength()); + + r = __pTextObject->Compose(); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + r = __pTextObject->Draw(*_CanvasImpl::GetInstance(canvas)); + SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + pSimpleText.release(); +} + +}} // Tizen::Shell diff --git a/src/FShell_LiveboxViewPresenter.h b/src/FShell_LiveboxViewPresenter.h new file mode 100644 index 0000000..785f10e --- /dev/null +++ b/src/FShell_LiveboxViewPresenter.h @@ -0,0 +1,72 @@ +// +// 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 FShell_LiveboxViewPresenter.h + * @brief This is the header file for the _LiveboxViewPresenter class. + * + * This header file contains the declarations of the %_LiveboxViewPresenter class. + */ +#ifndef _FSHL_INTERNAL_LIVEBOX_VIEW_PRESENTER_H_ +#define _FSHL_INTERNAL_LIVEBOX_VIEW_PRESENTER_H_ + +#include + +namespace Tizen { namespace Graphics +{ +class Font; +class Canvas; +}} // Tizen::Graphics + +namespace Tizen { namespace Graphics { namespace _Text +{ +class TextObject; +}}} // Tizen::Graphics::_Text + +namespace Tizen { namespace Shell +{ + +class _LiveboxView; +class _LiveboxViewModel; + +class _LiveboxViewPresenter +{ +public: + _LiveboxViewPresenter(const _LiveboxView& liveBoxView); + virtual ~_LiveboxViewPresenter(void); + + result Initialize(const Tizen::Base::String& appId); + Tizen::Base::String GetAppId(void) const; + Tizen::Base::String GetAppName(void) const; + Tizen::Base::String GetAppIconPath(void) const; + + void Draw(void); + void DrawText(Tizen::Graphics::Canvas& canvas); + +private: + _LiveboxViewPresenter(const _LiveboxViewPresenter& rhs); + _LiveboxViewPresenter& operator =(const _LiveboxViewPresenter& rhs); + +private: + _LiveboxView* __pLiveboxView; + std::unique_ptr<_LiveboxViewModel> __pLiveboxViewModel; + std::unique_ptr __pFont; + std::unique_ptr __pTextObject; +}; // _LiveboxViewPresenter + +}} // Tizen::Shell + +#endif // _FSHL_INTERNAL_LIVEBOX_VIEW_PRESENTER_H_ diff --git a/src/inc/FShell_ILiveboxTouchEventListener.h b/src/inc/FShell_ILiveboxTouchEventListener.h new file mode 100644 index 0000000..db1c87f --- /dev/null +++ b/src/inc/FShell_ILiveboxTouchEventListener.h @@ -0,0 +1,39 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_ILiveboxTouchEventListener.h + * @brief This is the header file for the _ILiveboxTouchEventListener interface. + * + * This header file contains the declarations of the _ILiveboxTouchEventListener interface. + */ + +#ifndef _FSHL_ILIVEBOX_TOUCH_EVENT_LISTENER_H_ +#define _FSHL_ILIVEBOX_TOUCH_EVENT_LISTENER_H_ + +#include + +namespace Tizen { namespace Shell +{ + +class _ILiveboxTouchEventListener +: public Tizen::Base::Runtime::IEventListener +{ +public: + virtual ~_ILiveboxTouchEventListener() {}; + + virtual int OnTouchEventRecevied(int eventType, double timestamp, double x, double y) = 0; +}; + +}} // Tizen::Shell + +#endif /* _FSHL_ILIVEBOX_TOUCH_EVENT_LISTENER_H_ */ diff --git a/src/inc/FShell_LiveboxManagerImpl.h b/src/inc/FShell_LiveboxManagerImpl.h new file mode 100644 index 0000000..20056d7 --- /dev/null +++ b/src/inc/FShell_LiveboxManagerImpl.h @@ -0,0 +1,116 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxManagerImpl.h + * @brief This is the header file for the _LiveboxManagerImpl class. + * + * This header file contains the declarations of the _LiveboxManagerImpl class. + */ + +#ifndef FShell_LiveboxMANAGERIMPL_H_ +#define FShell_LiveboxMANAGERIMPL_H_ + +#include +#include +#include +#include +#include +#include +//#include + + +namespace Tizen { namespace Shell { + +class LiveboxFrame; +class LiveboxPopup; + +class LiveboxProviderInfo; + +class ILiveboxProviderFactory; +class ILiveboxPopupProviderFactory; +class LiveboxProvider; +class LiveboxPopupProvider; +class _ILiveboxTouchEventListener; +class _LiveboxManagerProxy; + + +class _OSP_EXPORT_ _LiveboxManagerImpl + : public Tizen::App::IAppControlProviderEventListener + , public Tizen::Base::Object +{ +public: + static _LiveboxManagerImpl* GetInstance(); + + // API impl + result SetLiveboxProviderFactory(ILiveboxProviderFactory& factory); + result SetLiveboxPopupProviderFactory(ILiveboxPopupProviderFactory& factory); + + Tizen::Base::Collection::IList* GetLiveboxProviderInfosN(); + LiveboxProviderInfo* GetLiveboxProviderInfoN(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName); + + result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName); + + // internal API + result RequestSharedMemoryId(const Tizen::Base::String& instanceId, int width, int height, int& shmId); + result RequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int width, int height, int& shmId); + result RequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height); + result RequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId); + result RequestReleaseSharedMemory(const Tizen::Base::String& instanceId); + result RequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId); + + // internal + result SetLiveboxTouchEventListener(const Tizen::Base::String& instanceId, _ILiveboxTouchEventListener& listener); + result SetLiveboxPopupEventListener(_ILiveboxTouchEventListener& listener); + + result ForwardTouchEvent(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y); + result ForwardTouchEventForPD(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y); + + // helper + static result ExtractAppIdAndProviderName(const Tizen::Base::String& providerId, Tizen::App::AppId& appId, Tizen::Base::String& providerName); + + void TerminateAppIfInvalidState(); + +private: + _LiveboxManagerImpl(); + virtual ~_LiveboxManagerImpl(); + result Construct(); + + result CreateLivebox(const Tizen::Base::String& name, const Tizen::Base::String& instanceId, int width, int height, const Tizen::Base::String& userInfo); + result UpdateLivebox(const Tizen::Base::String& instanceId, int width, int height); + result ResizeLivebox(const Tizen::Base::String& instanceId, int width, int height); + result RemoveLivebox(const Tizen::Base::String& instanceId); + result CreateLiveboxPopupProvider(const Tizen::Base::String& instanceId); + result DestroyLiveboxPopupProvider(const Tizen::Base::String& instanceId); + + bool ContainsLivebox(const Tizen::Base::String& instanceId) const; + + virtual void OnAppControlRequestReceivedN(RequestId reqId, const Tizen::Base::String& providerId, const Tizen::Base::String& operationId, const Tizen::Base::String& category, const Tizen::Base::String* pDataType, const Tizen::Base::String* pUriScheme, Tizen::Base::Collection::IList* pArgs); + result HandleLiveboxRequest(const Tizen::Base::String& operationId, Tizen::Base::Collection::IList* pArgs); + result HandleLiveboxPopupRequest(const Tizen::Base::String& operationId, Tizen::Base::Collection::IList* pArgs); + +private: + // for livebox + ILiveboxProviderFactory* __pLiveboxFactory; + Tizen::Base::Collection::HashMapT __liveBoxes; + Tizen::Base::Collection::HashMapT __touchEventListeners; + + // for PD + ILiveboxPopupProviderFactory* __pLiveboxPopupProviderFactory; + LiveboxPopupProvider* __pLiveboxPopupProvider; + _ILiveboxTouchEventListener* __LiveboxPopupTouchEventListener; + + bool __messageReceived; +}; + +}} // Tizen::Shell +#endif /* FShell_LiveboxMANAGERIMPL_H_ */ diff --git a/src/inc/FShell_LiveboxManagerIpcMessage.h b/src/inc/FShell_LiveboxManagerIpcMessage.h new file mode 100644 index 0000000..e4897e4 --- /dev/null +++ b/src/inc/FShell_LiveboxManagerIpcMessage.h @@ -0,0 +1,36 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// +/** + * @file .h + * @brief This is the header file for the LiveboxManagerService Ipc message types. + */ + +#include +#include + +#include "ipc/ipc_message_macros.h" +#include "FIo_IpcCommonParamTraits.h" + + +#define IPC_MESSAGE_START AppManagerServiceStart + +IPC_SYNC_MESSAGE_CONTROL2_1(LiveboxManager_RequestUpdate, Tizen::Base::String, Tizen::Base::String, result) +IPC_SYNC_MESSAGE_CONTROL3_1(LiveboxManager_RequestSharedMemoryId, Tizen::Base::String, int, int, int) +IPC_SYNC_MESSAGE_CONTROL3_1(LiveboxManager_RequestSharedMemoryIdForPD, Tizen::Base::String, int, int, int) +IPC_SYNC_MESSAGE_CONTROL3_1(LiveboxManager_RequestSyncSharedMemory, Tizen::Base::String, int, int, result) +IPC_SYNC_MESSAGE_CONTROL1_1(LiveboxManager_RequestSyncSharedMemoryForPD, Tizen::Base::String, result) +IPC_SYNC_MESSAGE_CONTROL1_1(LiveboxManager_RequestReleaseSharedMemory, Tizen::Base::String, result) +IPC_SYNC_MESSAGE_CONTROL1_1(LiveboxManager_RequestReleaseSharedMemoryForPD, Tizen::Base::String, result) +IPC_MESSAGE_CONTROL5(LiveboxManager_SendTouchEvent, Tizen::Base::String, int, double, double, double) +IPC_MESSAGE_CONTROL5(LiveboxManager_SendTouchEventForPD, Tizen::Base::String, int, double, double, double) + + diff --git a/src/inc/FShell_LiveboxManagerProxy.h b/src/inc/FShell_LiveboxManagerProxy.h new file mode 100644 index 0000000..ae4ecaf --- /dev/null +++ b/src/inc/FShell_LiveboxManagerProxy.h @@ -0,0 +1,61 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxManagerProxy.h + * @brief This is the header file for the _LiveboxManagerProxy class. + * + * This header file contains the declarations of the _LiveboxManagerProxy class. + */ + +#ifndef _FSHL_LIVEBOXMANAGERPROXY_H_ +#define _FSHL_LIVEBOXMANAGERPROXY_H_ + +#include +#include +#include + +namespace Tizen { namespace Shell { + +class _LiveboxManagerProxy + : public Tizen::Io::_IIpcClientEventListener + , public Tizen::Base::Object +{ +public: + _LiveboxManagerProxy(); + virtual ~_LiveboxManagerProxy(); + + static _LiveboxManagerProxy* GetInstance(); + result Construct(void); + + result RequestUpdate(const Tizen::App::AppId& appId, const Tizen::Base::String& providerName); + + result RequestSharedMemoryId(const Tizen::Base::String& instanceId, int w, int h, int& shmId); + result RequestSharedMemoryIdForPD(const Tizen::Base::String& instanceId, int w, int h, int& shmId); + result RequestSyncSharedMemory(const Tizen::Base::String& instanceId, int width, int height); + result RequestSyncSharedMemoryForPD(const Tizen::Base::String& instanceId); + result RequestReleaseSharedMemory(const Tizen::Base::String& instanceId); + result RequestReleaseSharedMemoryForPD(const Tizen::Base::String& instanceId); + + result OnTouchEventReceived(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y ); + result OnTouchEventReceivedForPD(const Tizen::Base::String& instanceId, int eventType, double timeStamp, double x, double y ); + +private: + virtual void OnIpcResponseReceived(Tizen::Io::_IpcClient& client, const IPC::Message& message); + +private: + Tizen::Io::_IpcClient* __pIpcClient; +}; + +}} // Tizen::Shell + +#endif /* _FSHL_LIVEBOXMANAGERPROXY_H_ */ diff --git a/src/inc/FShell_LiveboxPopupProviderImpl.h b/src/inc/FShell_LiveboxPopupProviderImpl.h new file mode 100644 index 0000000..fa0bc78 --- /dev/null +++ b/src/inc/FShell_LiveboxPopupProviderImpl.h @@ -0,0 +1,173 @@ +// +// Tizen C++ SDK +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShellLiveboxPopupProvider.h + * @brief This is the header file for the LiveboxPopupProvider class. + * + * This header file contains the declarations of the %LiveboxPopupProvider class. + */ + +#ifndef _FSHL_LIVEBOX_POPUP_PROVIDER_H_ +#define _FSHL_LIVEBOX_POPUP_PROVIDER_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class LiveboxFrame; +class LiveboxPopup; + +/** + * @class LiveboxPopupProvider + * @brief This class is the abstract base class of all Livebox popup provider + * + * @since 2.1 + * + * The %LiveboxPopupProvider class is a base class which represents a Livebox provider + */ +class _OSP_EXPORT_ LiveboxPopupProvider +: public Tizen::Base::Object +{ +public: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + LiveboxPopupProvider(); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~LiveboxPopupProvider(); + +protected: + /** + * Called when the Livebox popup provider is required to be created @n + * + * @since 2.1 + * + * @param[in] width The width of the Livebox + * @param[in] height The height of the Livebox + * @param[in] userInfo User information that specifed when the Livebox is added + * + * @remarks LiveboxPopup should be created and set here + * @see SetLiveboxPopup + */ + virtual void OnLiveboxPopupProviderInitializing(const Tizen::Base::String& userInfo) = 0; + + /** + * Called when the Livebox popup provider is required to be destroyed @n + * + * @since 2.1 + */ + virtual void OnLiveboxPopupProviderTerminating() = 0; + + /** + * Gets the Livebox's Id. + * + * @since 2.1 + * + * @return The Livebox Id + */ + Tizen::Base::String GetId() const; + + /** + * Sets the frame to the Livebox + * + * @since 2.1 + * + * @return An error code + * @param[in] frame The frame to be set to the Livebox + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application. + * @exception E_SYSTEM A system error has occurred. + */ + void SetLiveboxPopup(Tizen::Shell::LiveboxPopup* pLiveboxPopup); + + /** + * Get the frame from the Livebox + * + * @since 2.1 + * + * @return The LiveBoxFrame instnace, or null if any LiveboxFrame is set yet. + * @param[in] frame The frame to be set to the Livebox + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The specified input parameter is invalid. + * @exception E_OBJ_ALREADY_EXIST The frame to be added is already registered with the UI application. + * @exception E_SYSTEM A system error has occurred. + */ + Tizen::Shell::LiveboxPopup* GetLiveboxPopup() const; + +private: + /** + * Initializes this instance of %LiveboxPopupProvider + * + * @since 2.1 + */ + result Construct(const Tizen::Base::String& instanceId); + + /* + * The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxPopupProvider(const LiveboxPopupProvider& rhs); + + /* + * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + * + * @since 2.1 + */ + LiveboxPopupProvider& operator =(const LiveboxPopupProvider& rhs); + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxPopupProvider_Reserved1(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxPopupProvider_Reserved2(void) {} + + // + // This method is for internal use only. Using this method can cause behavioral, + // security-related, and consistency-related issues in the application. + // + // @since 2.1 + // + virtual void LiveboxPopupProvider_Reserved3(void) {} + +private: + Tizen::Shell::LiveboxPopup* __pLiveboxFrame; + class _LiveboxProviderImpl* __pLiveboxProviderImpl; + + friend class _LiveboxManagerImpl; +}; + +} /* namespace Livebox */ +} /* namespace Samsung */ +#endif /* _FSHL_LIVEBOX_POPUP_PROVIDER_H_ */ diff --git a/src/inc/FShell_LiveboxProviderImpl.h b/src/inc/FShell_LiveboxProviderImpl.h new file mode 100644 index 0000000..29ef674 --- /dev/null +++ b/src/inc/FShell_LiveboxProviderImpl.h @@ -0,0 +1,50 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxProviderImpl.h + * @brief This is the header file for the _LiveboxProviderImpl class. + * + * This header file contains the declarations of the _LiveboxProviderImpl class. + */ + +#ifndef FShell_LiveboxIMPL_H_ +#define FShell_LiveboxIMPL_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +class LiveboxFrame; + +class _LiveboxProviderImpl + : public Tizen::Base::Object +{ +public: + _LiveboxProviderImpl(const Tizen::Base::String& id); + virtual ~_LiveboxProviderImpl(); + + const Tizen::Base::String& GetId() const; + result SetLiveboxFrame(LiveboxFrame* pLiveboxFrame); + LiveboxFrame* GetLiveboxFrame() const; + +private: + Tizen::Base::String __id; + LiveboxFrame* __pLiveboxFrame; + class LiveboxProvider* __pLivebox; +}; + +}} // Tizen::Shell + +#endif /* FShell_LiveboxIMPL_H_ */ diff --git a/src/inc/FShell_LiveboxProviderInfoImpl.h b/src/inc/FShell_LiveboxProviderInfoImpl.h new file mode 100644 index 0000000..3010227 --- /dev/null +++ b/src/inc/FShell_LiveboxProviderInfoImpl.h @@ -0,0 +1,165 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxInfoImpl.h + * @brief This is the header file for the _LiveboxInfoImpl class. + * + * This header file contains the declarations of the _LiveboxInfoImpl class. + */ + +#ifndef _FSHL_LIVEBOXINFOIMPL_H_ +#define _FSHL_LIVEBOXINFOIMPL_H_ + +#include +#include +#include +//#include + +namespace Tizen { namespace Shell { + +class _OSP_EXPORT_ _LiveboxProviderInfoImpl + : public Tizen::Base::Object +{ +public: + + /** + * This is the constructor that initializes an instance of %LiveboxProviderInfo with the specified values. + * + * @since 2.1 + */ + _LiveboxProviderInfoImpl(const Tizen::App::AppId& appId, const Tizen::Base::String& name, const Tizen::Base::String& providerId); + + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~_LiveboxProviderInfoImpl(); + + /** + * Gets the application ID. + * + * @since 2.1 + * + * @return The application ID + */ + Tizen::App::AppId GetAppId() const; + + /** + * Gets the Livebox provider name + * + * @since 2.1 + * + * @return The application ID + */ + Tizen::Base::String GetName() const; + + /** + * Gets the display name of the Livbox @n + * If the system language setting is changed, this method returns the localized application name. + * The display name is displayed in applications that showing Livebox like Launcher, and so on. + * + * @since 2.1 + * + * @return The display name of the Livbox + */ + Tizen::Base::String GetDisplayName() const; + + /** + * Gets the icon path of the application. + * + * @since 2.1 + * + * @return The icon path of the application, @n + * An empty string is returned if there is no value. + */ + Tizen::Base::String GetIconPath() const; + + Tizen::Base::String GetCongiturationAppControlAppId() const; + + /** + * Gets a list of LiveboxSizeInfo of the Livebox + * + * @since 2.1 + * + * @return A pointer to the array list that contains all LiveboxSizeInfo of the LiveboxProvider@n + * else @c null if an error occurs + * @exception E_SUCCESS The method is successful. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + Tizen::Base::Collection::IList* GetSizeInfosN() const; + + static _LiveboxProviderInfoImpl* GetImpl(const LiveboxProviderInfo& liveboxProviderInfo); + +private: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + _LiveboxProviderInfoImpl(); + + /** + * This is the copy constructor for the %LiveboxProviderInfo class. + * + * @since 2.1 + * + * @param[in] value An instance of %LiveboxProviderInfo + */ + _LiveboxProviderInfoImpl(const _LiveboxProviderInfoImpl& rhs); + + /** + * Assigns the value of the specified instance of %LiveboxProviderInfo to the current instance of %LiveboxProviderInfo. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LiveboxProviderInfo + */ + _LiveboxProviderInfoImpl& operator =(const _LiveboxProviderInfoImpl& rhs); + +public: + Tizen::Base::String __configurationAppControlAppId; //TODO:temporary public + Tizen::Base::String __displayName; //TODO:temporary public + bool __isDefault;//TODO:temporary public + +private: + Tizen::Base::String __appId; + Tizen::Base::String __name; + Tizen::Base::String __providerId; + + +// Tizen::Base::String __iconPath; + Tizen::Base::Collection::ArrayList __sizeInfos; + + friend class LiveboxProviderInfo; +// friend class _LiveboxManagerImpl; +}; + +/*class _LiveboxInfoImpl { +public: + _LiveboxInfoImpl(); + virtual ~_LiveboxInfoImpl(); + +// result Construct(const Tizen::App::AppId& appId, Tizen::Base::Collection::IListT& dimensions); + + const Tizen::App::AppId& GetAppId() const; + Tizen::Base::Collection::ArrayListT* GetSupprtedDimensionsN() const; + +private: + Tizen::App::AppId __appId; + Tizen::Base::Collection::ArrayListT __supportedDimensions; +};*/ + +}} // Tizen::Shell +#endif /* _FSHL_LIVEBOXINFOIMPL_H_ */ diff --git a/src/inc/FShell_LiveboxSizeInfoImpl.h b/src/inc/FShell_LiveboxSizeInfoImpl.h new file mode 100644 index 0000000..f9ec2fd --- /dev/null +++ b/src/inc/FShell_LiveboxSizeInfoImpl.h @@ -0,0 +1,107 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FShell_LiveboxSizeInfoImpl.h + * @brief This is the header file for the %_LiveboxSizeInfoImpl class. + * + * This header file contains the declarations of the %_LiveboxSizeInfoImpl class. + */ + +#ifndef _FSHL_LIVEBOX_SIZE_INFO_IMPL_H_ +#define _FSHL_LIVEBOX_SIZE_INFO_IMPL_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +/** + * @class _LiveboxSizeInfoImpl + * @brief This class contains size and preview image path for the size + * + * @since 2.1 + */ +class _OSP_EXPORT_ _LiveboxSizeInfoImpl + : public Tizen::Base::Object +{ +public: + /** + * This destructor overrides Tizen::Base::Object::~Object(). + * + * @since 2.1 + */ + virtual ~_LiveboxSizeInfoImpl(); + + /** + * This is the copy constructor for the %LiveboxSizeInfo class. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LiveboxSizeInfo + */ + _LiveboxSizeInfoImpl(const _LiveboxSizeInfoImpl& rhs); + + /** + * Assigns the value of the specified instance of %LiveboxSizeInfo to the current instance of %LiveboxSizeInfo. + * + * @since 2.1 + * + * @param[in] rhs An instance of %LiveboxSizeInfo + */ + _LiveboxSizeInfoImpl& operator =(const _LiveboxSizeInfoImpl& rhs); + + /** + * Gets the size + * + * @since 2.1 + * + * @return A size + */ + Tizen::Graphics::Dimension GetSize() const; + + /** + * Gets the image path for preview + * + * @since 2.1 + * + * @return The image path for preview + */ + Tizen::Base::String GetPreviewImagePath() const; + +private: + /** + * This is the default constructor for this class. + * + * @since 2.1 + */ + _LiveboxSizeInfoImpl(); + + /** + * This is the constructor that initializes an instance of %_LiveboxSizeInfoImpl with the specified values. + * + * @since 2.1 + */ + _LiveboxSizeInfoImpl(Tizen::Graphics::Dimension size, const Tizen::Base::String& previewImagePath); + +private: + Tizen::Graphics::Dimension __size; + Tizen::Base::String __previewImagePath; + +friend class LiveboxSizeInfo; +}; + +}} // Tizen::Shell +#endif /* _FSHL_LIVEBOX_SIZE_INFO_IMPL_H_ */ diff --git a/src/inc/FShell_TemplateUtil.h b/src/inc/FShell_TemplateUtil.h new file mode 100644 index 0000000..3b96997 --- /dev/null +++ b/src/inc/FShell_TemplateUtil.h @@ -0,0 +1,169 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// All rights reserved. +// +// This software contains confidential and proprietary information +// of Samsung Electronics Co., Ltd. +// The user of this software agrees not to disclose, disseminate or copy such +// Confidential Information and shall use the software only in accordance with +// the terms of the license agreement the user entered into with Samsung. +// + +/** + * @file FAppAppManager.h + * @brief This is the header file for the %AppManager class. + * + * This header file contains the declarations of the %AppManager class. + */ + +#ifndef FAPP_INTERNAL_STRINGKEY_HASHMAP_UTIL_H_ +#define FAPP_INTERNAL_STRINGKEY_HASHMAP_UTIL_H_ + + +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +template void +_DeleteCollection(Tizen::Base::Collection::ICollectionT& col) +{ + Tizen::Base::Collection::IEnumeratorT* pEnum = col.GetEnumeratorN(); + + if (pEnum) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + Type* pElem = null; + pEnum->GetCurrent(pElem); + + delete pElem; + } + + delete pEnum; + } +} + +template void +_DeleteCollectionMapValue(Tizen::Base::Collection::IMapT& col) +{ + Tizen::Base::Collection::IMapEnumeratorT* pEnum = col.GetMapEnumeratorN(); + + if (pEnum) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + ValueType* pValue = null; + pEnum->GetValue(pValue); + + delete pValue; + } + + delete pEnum; + } +} + +template void +_DeleteCollectionMapValue(Tizen::Base::Collection::IMultiMapT& col) +{ + Tizen::Base::Collection::IMapEnumeratorT* pEnum = col.GetMapEnumeratorN(); + + if (pEnum) + { + while (pEnum->MoveNext() == E_SUCCESS) + { + ValueType* pValue = null; + pEnum->GetValue(pValue); + + delete pValue; + } + + delete pEnum; + } +} + +/*// custom deleter of Collection +struct CollectionAllElementDeleter +{ + template + void operator() (Collection* c) + { + c->RemoveAll(true); + delete c; + } +};*/ + +}} // Tizen::Shell + + +namespace Tizen { namespace Base +{ + +template<> +class ComparerT +: public virtual Tizen::Base::Collection::IComparerT +, public Object +{ +public: + ComparerT(void) {} + + virtual ~ComparerT(void) {} + + virtual result Compare(const String& obj1, const String& obj2, int& cmp) const + { + cmp = String::Compare(obj1, obj2); + return E_SUCCESS; + } + +private: + ComparerT(const ComparerT& rhs); + + ComparerT& operator =(const ComparerT& rhs); +}; + +namespace Collection +{ + +template <> +class __HashMapDefaultProviderT +: public IHashCodeProviderT +, public Object +{ + public: + __HashMapDefaultProviderT(void) {} + + virtual ~__HashMapDefaultProviderT(void) {} + + virtual int GetHashCode(const String& obj) const + { + return obj.GetHashCode(); + } +}; + +template<> +class __MultiHashMapDefaultProviderT +: public IHashCodeProviderT +, public Object +{ + public: + __MultiHashMapDefaultProviderT(void) {} + + virtual ~__MultiHashMapDefaultProviderT(void) {} + + virtual int GetHashCode(const String& obj) const + { + return obj.GetHashCode(); + } +}; + + +} // Collection + +}} // Tizen::Base + + + +#endif // FAPP_INTERNAL_STRINGKEY_HASHMAP_UTIL_H_ -- 2.7.4