From a1af4f2c626b82c07e986f835be53528970f08d0 Mon Sep 17 00:00:00 2001 From: "jungmin76.park" Date: Tue, 12 Mar 2013 15:33:23 +0900 Subject: [PATCH] change HomeManager -> ShortcutManager, and apply dynamic singleton idiom for LiveboxManager Change-Id: I19b9a11cd2402eae8b616de3c4a17eef30c06bf5 Signed-off-by: jungmin76.park --- inc/FShellHomeManager.h | 123 ------------- inc/FShellIBadgeEventListener.h | 91 +++++++++ inc/FShellIShortcutRequestListener.h | 133 ++++++++++++++ inc/FShellLiveboxManager.h | 26 ++- inc/FShellLiveboxPopupProvider.h | 12 +- inc/FShellLiveboxProvider.h | 14 +- inc/FShellLiveboxProviderInfo.h | 4 +- inc/FShellLiveboxProviderManager.h | 14 +- inc/FShellLiveboxSizeInfo.h | 4 +- inc/FShellLockManager.h | 2 +- inc/FShellShortcutManager.h | 204 +++++++++++++++++++++ src/CMakeLists.txt | 2 + src/FShellLiveboxManager.cpp | 57 ++++-- src/FShell_LiveboxManagerImpl.cpp | 22 +-- src/FShell_LiveboxProviderManagerImpl.cpp | 2 +- src/core/CMakeLists.txt | 4 +- ...llHomeManager.cpp => FShellShortcutManager.cpp} | 56 ++++-- src/core/FShell_ShortcutManagerImpl.cpp | 156 ++++++++++++++++ src/inc/FShell_ShortcutManagerImpl.h | 127 +++++++++++++ 19 files changed, 846 insertions(+), 207 deletions(-) delete mode 100755 inc/FShellHomeManager.h create mode 100755 inc/FShellIBadgeEventListener.h create mode 100755 inc/FShellIShortcutRequestListener.h mode change 100644 => 100755 inc/FShellLiveboxProviderManager.h create mode 100755 inc/FShellShortcutManager.h mode change 100644 => 100755 src/FShellLiveboxManager.cpp rename src/core/{FShellHomeManager.cpp => FShellShortcutManager.cpp} (55%) create mode 100644 src/core/FShell_ShortcutManagerImpl.cpp create mode 100644 src/inc/FShell_ShortcutManagerImpl.h diff --git a/inc/FShellHomeManager.h b/inc/FShellHomeManager.h deleted file mode 100755 index 7bd44e8..0000000 --- a/inc/FShellHomeManager.h +++ /dev/null @@ -1,123 +0,0 @@ -// -// Open Service Platform -// Copyright (c) 2013 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 FShellHomeManager.h - * @brief This is the header file for the %HomeManager class. - * - * This header file contains the declarations of the %HomeManager class. - */ - -#ifndef _FSHELL_HOME_MANAGER_H_ -#define _FSHELL_HOME_MANAGER_H_ - -#include -#include -#include - -namespace Tizen { namespace Shell -{ - -/* - * @class HomeManager - * @brief Manages information of home screen. - * - * @since 2.1 - * - * @final This class is not intended for extension. - * - * The %HomeManager class manages information of home screen. - */ -class _OSP_EXPORT_ HomeManager - : public Tizen::Base::Object -{ -public: - - /* - * Gets the %HomeManager instance. - * - * @since 2.1 - * - * @return A pointer to the %HomeManager instance, @n - * else @c null if it fails - */ - static HomeManager* GetInstance(void); - - /* - * Request the Home screen to add the spefied shortcut. - * - * @privlevel public - * @privilege http::tizen.org/privilege/homemanager - * - * @since 2.1 - * - * @return An error code - * @param[in] appId The application ID - * @param[in] displayName The display name of shortcut - * @param[in] iconFilePath The icon file path - * @param]in] uriData Uri that will be delivered by IAppControlProviderEventListener::OnAppControlRequestReceived(), when the application start via shortcut. - * - * @exception E_SUCCESS The method is successful. - * @exception E_APP_NOT_INSTALLED The application is not installed. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - * @exception E_SYSTEM The method cannot proceed due to a severe system error. - * - * @remark If uriData is specified, application will be started by AppControl with http://tizen.org/appcontrol/operation/view operation, when it's launched from the Home screen via shortcut. - * Or else application will be started by AppControl with default operation(http://tizen.org/appcontrol/operation/main). - * @see IAppControlEventListener::OnAppControlRequestReceived() - */ - result AddShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName, const Tizen::Base::String& iconFilePath, const Tizen::Base::String& uriData); - -private: - // - // This default constructor is intentionally declared as private to implement the %Singleton semantic. - // - // @since 2.1 - // - HomeManager(); - - // - // This destructor is intentionally declared as private to implement the %Singleton semantic. - // - // @since 2.1 - // - virtual ~HomeManager(); - - // - // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. - // - // @since 2.1 - // - HomeManager& operator =(const HomeManager& rhs); - - // - // Constructs the instance of this class. - // - // @since 2.1 - // - // @return An error code - // @exception E_SUCCESS The method is successful. - // @exception E_SYSTEM The method cannot proceed due to a severe system error. - // - result Construct(); - -private: - class _HomeManagerImpl* __pHomeManagerImpl; -}; - -}} // Tizen::Shell -#endif /* _FSHELL_HOME_MANAGER_H_ */ diff --git a/inc/FShellIBadgeEventListener.h b/inc/FShellIBadgeEventListener.h new file mode 100755 index 0000000..d1e6a0d --- /dev/null +++ b/inc/FShellIBadgeEventListener.h @@ -0,0 +1,91 @@ +// +// Open Service Platform +// Copyright (c) 2013 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.1 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.1 +// +// 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 FShellIBadgeEventListener.h + * @brief This is the header file for the %IBadgeEventListener interface. + * + * This header file contains the declarations of the %IBadgeEventListener interface. + */ + +#ifndef _FSHELL_IBADGE_EVENT_LISTENER_H_ +#define _FSHELL_IBADGE_EVENT_LISTENER_H_ + +#include +#include + +namespace Tizen { namespace Shell +{ + +/** + * @interface IBadgeEventListener + * @brief This interface defines a listener for the Home screen that receives badge updated event. + * + * @since 2.1 + * + * The %IBadgeEventListener interface defines a listener for for the Home screen that receives badge updated event. + */ +class _OSP_EXPORT_ IBadgeEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +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 ~IBadgeEventListener() {} + + /** + * Called when requested to add a shortcut @n + * + * @param[in] appId The application ID that badge number updated + * @param[in] badgeNumber Updated badge number + * @see NotificationManager::Notify() + */ + virtual void OnBadgeUpdated(const Tizen::App::AppId& appId, int badgeNumber) = 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 IBadgeEventListener_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 IBadgeEventListener_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 IBadgeEventListener_Reserved3(void) {} +}; + +}} // Tizen::Shell + +#endif /* _FSHELL_IBADGE_EVENT_LISTENER_H_ */ diff --git a/inc/FShellIShortcutRequestListener.h b/inc/FShellIShortcutRequestListener.h new file mode 100755 index 0000000..2cc5d28 --- /dev/null +++ b/inc/FShellIShortcutRequestListener.h @@ -0,0 +1,133 @@ +// +// Open Service Platform +// Copyright (c) 2013 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 FShellIShortcutRequestListener.h + * @brief This is the header file for the %IShortcutRequestListener interface. + * + * This header file contains the declarations of the %IShortcutRequestListener interface. + */ + +#ifndef _FSHELL_ISHORTCUT_REQUEST_LISTENER_H_ +#define _FSHELL_ISHORTCUT_REQUEST_LISTENER_H_ + +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +/** + * @interface IShortcutRequestListener + * @brief This interface defines a listener for the Home application that receives request to add a shortcut. + * + * @since 2.1 + * + * The %IShortcutRequestListener interface defines a listener for for the Home application that receives request to add a shortcut. + + * The following example demonstrates how to starts the application when added shortcut is selected by user. + * @code +#include +#include + +using namespace Tizen::Shell; +using namespace Tizen::App; + + if( uriData.IsEmpty() ) + { + AppManager::GetInstance()->LaunchApplication(appId, null); + } + else + { + AppControlpAc = AppManager::FindAppControlN(App::GetInstance()->GetAppId(), L"http://tizen.org/appcontrol/operation/view"); + if( pAc ) + { + pAc->Start(*uriData, null, null, null); + delete pAc; + } + } +@endcode + */ +class _OSP_EXPORT_ IShortcutRequestListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +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 ~IShortcutRequestListener(void) {} + + /** + * Called when requested to add the shortcut @n + * + * @param[in] appId The application ID + * @param[in] displayName The display name of shortcut + * @param[in] iconFilePath The icon file path + * @param]in] uriData Uri that will be delivered by IAppControlProviderEventListener::OnAppControlRequestReceived(), when the application is started via shortcut. + * @see ShortcutManager::AddShortcut() + * + * @remarks If uriData is specified, application should be started by AppControl with http://tizen.org/appcontrol/operation/view operation, when it's launched from the Home application via shortcut. + * Or else application should be started by AppControl with default opertaion (http://tizen.org/appcontrol/operation/main). + * For more information on the AppControl class, see Application Controls, and Delivering Launch Arguments. + */ + virtual void OnShortcutAddRequested(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName, const Tizen::Base::String& iconFilePath, const Tizen::Base::String& uriData) = 0; + + /** + * Called when requested to remove the shortcut @n + * + * @param[in] appId The application ID + * @param[in] displayName The display name of shortcut + * + * @remarks If there are one more shortcuts with duplicated appId and displayName, all of them should be removed. + * + * @see ShortcutManager::RemoveShortcut() + */ + virtual void OnShortcutRemoveRequested(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName) = 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 IShortcutReqeustListener_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 IShortcutReqeustListener_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 IShortcutReqeustListener_Reserved3(void) {} +}; + +}} // Tizen::Shell + +#endif /* _FSHELL_ISHORTCUT_REQUEST_LISTENER_H_ */ diff --git a/inc/FShellLiveboxManager.h b/inc/FShellLiveboxManager.h index 3ac4b23..03bf0a9 100755 --- a/inc/FShellLiveboxManager.h +++ b/inc/FShellLiveboxManager.h @@ -59,7 +59,7 @@ public: * @return A pointer to the %LiveboxManager instance, @n * else @c null if it fails */ - static LiveboxManager* GetInstance(); + static LiveboxManager* GetInstance(void); /** * Gets a list of installed LiveboxProviderInfo @@ -73,7 +73,7 @@ public: * @exception E_SYSTEM The method cannot proceed due to a severe system error. * @remarks The specific error code can be accessed using the GetLastResult() method. */ - Tizen::Base::Collection::IList* GetLiveboxProviderInfoListN(); + Tizen::Base::Collection::IList* GetLiveboxProviderInfoListN(void); /** * Gets a LiveboxProviderInfo of the specified Livebox provider. @@ -122,7 +122,7 @@ public: * @exception E_SYSTEM The method cannot proceed due to a severe system error. * * @see ILiveboxAddRequestListener - * @remark Platform does not have the ownership of this pointer, So caller should manage the listener object properly. + * @remarks Platform does not have the ownership of this pointer, So caller should manage the listener object properly. */ result SetLiveboxAddRequestListener(ILiveboxAddRequestListener* pListener); @@ -132,14 +132,21 @@ private: // // @since 2.1 // - LiveboxManager(); + LiveboxManager(void); // // This destructor is intentionally declared as private to implement the %Singleton semantic. // // @since 2.1 // - virtual ~LiveboxManager(); + virtual ~LiveboxManager(void); + + // + // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + LiveboxManager(const LiveboxManager& rhs); // // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @@ -157,11 +164,16 @@ private: // @exception E_SUCCESS The method is successful. // @exception E_SYSTEM The method cannot proceed due to a severe system error. // - result Construct(); + result Construct(void); + static void InitSingleton(void); + static void DestroySingleton(void); + private: - class _LiveboxManagerImpl* __pLiveboxManagerImpl; + + static LiveboxManager* __pTheInstance; friend struct std::default_delete< LiveboxManager >; + class _LiveboxManagerImpl* __pLiveboxManagerImpl; }; }} // Tizen::Shell diff --git a/inc/FShellLiveboxPopupProvider.h b/inc/FShellLiveboxPopupProvider.h index e9a9afe..5784368 100644 --- a/inc/FShellLiveboxPopupProvider.h +++ b/inc/FShellLiveboxPopupProvider.h @@ -49,14 +49,14 @@ protected: * * @since 2.1 */ - LiveboxPopupProvider(); + LiveboxPopupProvider(void); /** * This destructor overrides Tizen::Base::Object::~Object(). * * @since 2.1 */ - virtual ~LiveboxPopupProvider(); + virtual ~LiveboxPopupProvider(void); /** * Called when the Livebox popup provider is required to be created @n @@ -88,8 +88,8 @@ protected: * @exception E_INVALID_ARG The pointer to the LiveboxFrame is null, or not constructed yet. * @exception E_SYSTEM The method cannot proceed due to a severe system error. * - * @remark This function should be called only in OnLiveboxPopupProviderInitializing. - * @remark LiveboxPopup instance ownership is transferred to platform. After LiveboxPopupProvider::OnLiveboxPopupProviderTerminating() is called, LiveboxPopup instance is removed automatically. LiveboxPopup instance reuse is not allowed. + * @remarks This function should be called only in OnLiveboxPopupProviderInitializing. + * @remarks LiveboxPopup instance ownership is transferred to platform. After LiveboxPopupProvider::OnLiveboxPopupProviderTerminating() is called, LiveboxPopup instance is removed automatically. LiveboxPopup instance reuse is not allowed. */ result SetLiveboxPopup(Tizen::Shell::LiveboxPopup* pLiveboxPopup); @@ -100,7 +100,7 @@ protected: * * @return The LiveboxPopup instnace, or null if any LiveboxPopup is set yet. */ - Tizen::Shell::LiveboxPopup* GetLiveboxPopup(); + Tizen::Shell::LiveboxPopup* GetLiveboxPopup(void); /** * Gets the Livebox popup from the Livebox @@ -119,7 +119,7 @@ protected: * @exception E_SUCCESS The method is successful. * @exception E_SYSTEM The method cannot proceed due to a severe system error. */ - result RequestUpdateToLivebox(); + result RequestUpdateToLivebox(void); protected: // diff --git a/inc/FShellLiveboxProvider.h b/inc/FShellLiveboxProvider.h index 42af7e1..222bfe4 100644 --- a/inc/FShellLiveboxProvider.h +++ b/inc/FShellLiveboxProvider.h @@ -50,14 +50,14 @@ protected: * * @since 2.1 */ - LiveboxProvider(); + LiveboxProvider(void); /** * This destructor overrides Tizen::Base::Object::~Object(). * * @since 2.1 */ - virtual ~LiveboxProvider(); + virtual ~LiveboxProvider(void); /** * Called when the Livebox provider is required to be created @n @@ -108,7 +108,7 @@ protected: * * @since 2.1 * - * @remark This function is called after OnLiveboxProviderTerminating called. + * @remarks This function is called after OnLiveboxProviderTerminating called. */ virtual void OnLiveboxProviderRemoved(void) = 0; @@ -121,7 +121,7 @@ protected: * @param[in] userInfo User information to update the Livebox provider@n * This parameter is delivered from LiveboxProvider::RequestUpdate() * - * @Remark This function is called when UpdatePeriod timer is expired or LiveboxManager::RequestUpdate() is called.@n + * @remarks This function is called when UpdatePeriod timer is expired or LiveboxManager::RequestUpdate() is called.@n */ virtual void OnLiveboxProviderUpdating(const Tizen::Base::String& userInfo) = 0; @@ -136,8 +136,8 @@ protected: * @exception E_INVALID_ARG The pointer to the LiveboxFrame is null, or not constructed yet. * @exception E_SYSTEM The method cannot proceed due to a severe system error. * - * @remark This function should be called only in OnLiveboxProviderInitializing. - * @remark LiveboxFrame instance ownership is transferred to platform. After LiveboxProvider::OnLiveboxProviderTerminating() is called, LiveboxPopup instance is removed automatically. LiveboxFrame instance reuse is not allowed. + * @remarks This function should be called only in OnLiveboxProviderInitializing. + * @remarks LiveboxFrame instance ownership is transferred to platform. After LiveboxProvider::OnLiveboxProviderTerminating() is called, LiveboxPopup instance is removed automatically. LiveboxFrame instance reuse is not allowed. */ result SetLiveboxFrame(LiveboxFrame* pLiveboxFrame); @@ -148,7 +148,7 @@ protected: * * @return the LiveboxFrame instnace, or null if any LiveboxFrame isn't set yet. */ - LiveboxFrame* GetLiveboxFrame(); + LiveboxFrame* GetLiveboxFrame(void); /** * Get the LiveboxFrame from the LiveboxProvider diff --git a/inc/FShellLiveboxProviderInfo.h b/inc/FShellLiveboxProviderInfo.h index ebf3c64..663b995 100644 --- a/inc/FShellLiveboxProviderInfo.h +++ b/inc/FShellLiveboxProviderInfo.h @@ -59,7 +59,7 @@ public: * * @since 2.1 */ - virtual ~LiveboxProviderInfo(); + virtual ~LiveboxProviderInfo(void); /** * Gets the application ID. @@ -178,7 +178,7 @@ private: // // @since 2.1 // - LiveboxProviderInfo(); + LiveboxProviderInfo(void); // // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects. diff --git a/inc/FShellLiveboxProviderManager.h b/inc/FShellLiveboxProviderManager.h old mode 100644 new mode 100755 index 48173e9..1377024 --- a/inc/FShellLiveboxProviderManager.h +++ b/inc/FShellLiveboxProviderManager.h @@ -59,7 +59,7 @@ public: * @return A pointer to the %LiveboxProviderManager instance, @n * else @c null if it fails */ - static LiveboxProviderManager* GetInstance(); + static LiveboxProviderManager* GetInstance(void); /** * Requests Livebox service to trigger specified Livebox update @@ -92,7 +92,7 @@ public: * @param[in] viewerAppId The ID of the viewer 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] text Text to represent the Livebox + * @param[in] alternateText Alternate text displayed in the LiveboxView while the LiveboxProvider is initializing or unavailable. * @param[in] userInfo User information for the Livebox provider * * @exception E_SUCCESS The method is successful. @@ -106,10 +106,10 @@ public: * @exception E_CONNECTION_FAILED The viewer application doesn't set a listener to receive this request. * @exception E_SYSTEM The method cannot proceed due to a severe system error. * - * @remark Only Livebox provider that is packaged with the caller application can be added by this API. + * @remarks Only Livebox provider that is packaged with the caller application can be added by this API. * @see SetLiveboxAddRequestListener */ - result AddLivebox(const Tizen::App::AppId& viewerAppId, const Tizen::App::AppId& providerAppId, const Tizen::Base::String& providerName, const Tizen::Base::String& text, const Tizen::Base::String& userInfo); + result AddLivebox(const Tizen::App::AppId& viewerAppId, const Tizen::App::AppId& providerAppId, const Tizen::Base::String& providerName, const Tizen::Base::String& alternateText, const Tizen::Base::String& userInfo); /** * Sets a LiveboxProvider factory. @n @@ -152,14 +152,14 @@ private: // // @since 2.1 // - LiveboxProviderManager(); + LiveboxProviderManager(void); // // This destructor is intentionally declared as private to implement the %Singleton semantic. // // @since 2.1 // - virtual ~LiveboxProviderManager(); + virtual ~LiveboxProviderManager(void); /** * The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. @@ -177,7 +177,7 @@ private: // @exception E_SUCCESS The method is successful. // @exception E_SYSTEM A system error has occurred. // - result Construct(); + result Construct(void); private: class _LiveboxProviderManagerImpl* __pLiveboxProviderManagerImpl; diff --git a/inc/FShellLiveboxSizeInfo.h b/inc/FShellLiveboxSizeInfo.h index cfc15af..bc460f3 100644 --- a/inc/FShellLiveboxSizeInfo.h +++ b/inc/FShellLiveboxSizeInfo.h @@ -49,7 +49,7 @@ public: * * @since 2.1 */ - virtual ~LiveboxSizeInfo(); + virtual ~LiveboxSizeInfo(void); /** * Copying of objects using this copy constructor is allowed. @@ -95,7 +95,7 @@ private: // // @since 2.1 // - LiveboxSizeInfo(); + LiveboxSizeInfo(void); // // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. diff --git a/inc/FShellLockManager.h b/inc/FShellLockManager.h index 0cee1ed..ed4e4a1 100755 --- a/inc/FShellLockManager.h +++ b/inc/FShellLockManager.h @@ -92,7 +92,7 @@ public: * @exception E_INVALID_OPERATION Can't unlock, because secure mode is enabled. * @exception E_SYSTEM The method cannot proceed due to a severe system error. * - * @remark This API call has no effect while secure mode is enabled. + * @remarks This API call has no effect while secure mode is enabled. */ result Unlock(void); diff --git a/inc/FShellShortcutManager.h b/inc/FShellShortcutManager.h new file mode 100755 index 0000000..2dd0ac4 --- /dev/null +++ b/inc/FShellShortcutManager.h @@ -0,0 +1,204 @@ +// +// Open Service Platform +// Copyright (c) 2013 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 FShellShortcutManager.h + * @brief This is the header file for the %ShortcutManager class. + * + * This header file contains the declarations of the %ShortcutManager class. + */ + +#ifndef _FSHELL_SHORTCUT_MANAGER_H_ +#define _FSHELL_SHORTCUT_MANAGER_H_ + +#include +#include +#include +#include + +namespace Tizen { namespace Shell +{ + +/* + * @class ShortcutManager + * @brief Helps an application can add its shortcut to the Home app. + * + * @since 2.1 + * + * @final This class is not intended for extension. + * + * The %ShortcutManager class helps an application can add its shortcut to the Home app. + */ +class _OSP_EXPORT_ ShortcutManager + : public Tizen::Base::Object +{ +public: + + /** + * Gets the %ShortcutManager instance. + * + * @since 2.1 + * + * @return A pointer to the %ShortcutManager instance, @n + * else @c null if it fails + * @exception E_SUCCESS The method is successful. + * @exception E_OUT_OF_MEMORY The memory is insufficient. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * @remarks The specific error code can be accessed using the GetLastResult() method. + */ + static ShortcutManager* GetInstance(void); + + /** + * Request the Home app to add the spefied shortcut. + * + * @privlevel public + * @privilege http::tizen.org/privilege/shortcut + * + * @since 2.1 + * + * @return An error code + * @param[in] appId The application ID + * @param[in] displayName The display name of shortcut + * @param[in] iconPath The icon file path + * @param[in] uriData Uri that will be delivered by IAppControlProviderEventListener::OnAppControlRequestReceived(), when the application is started via shortcut. + * @param[in] allowDuplication Flag to allow duplicate shortcut. + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * + * @remarks Icon file should be placed in sub directory of 'shared/res' to be used by the Home app. + * For more information on shared directory, see I/O Overview. + * For more information on icon file, see General Information. + * + * If uriData is specified, application will be started by AppControl with http://tizen.org/appcontrol/operation/view operation, when it's launched from the Home app via shortcut. + * Or else application will be started by AppControl with default operation(http://tizen.org/appcontrol/operation/main). + * + * @see IAppControlEventListener::OnAppControlRequestReceived() + * @see IShortcutRequestListener::OnShortcutAddRequested() + * + * The following example demonstrates how to add shortcut. + * + * @code + * #include + * #include + * + * using namespace Tizen::App; + * using namespace Tizen::Shell; + * + * String appId = App::GetInstance()->GetAppId(); + * String iconPath = AppManager::GetInstance()->GetAppSharedPath(appId) + L"res/my_icons/my_icon.png"; + * ShortcutManager::GetInstance()->AddShortcut(appId, L"MyApp", iconPath , L"myapp://mydata/myitem"); + * @endcode + */ + result AddShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName, const Tizen::Base::String& iconPath, const Tizen::Base::String& uriData, bool allowDuplication = true ); + + /** + * Requests the Home app to remove the specified shortcut. + * + * @privlevel public + * @privilege http://tizen.org/privilege/shortcut + * + * @since 2.1 + * + * @return An error code + * @param[in] appId The application ID + * @param[in] displayName The display name of shortcut + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * + * @remarks If there are one more shortcuts with duplicated appId and displayName in the Home app, All of them will be removed. + * + * @see IShortcutRequestListener::OnShortcutRemoveRequested() + */ + result RemoveShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName); + + /** + * Adds an IShortcutRequestListener to the %ShortcutManager. @n + * The listener gets notified when requested to add a shortcut. + * + * @since 2.1 + * + * @return An error code + * @param[in] listener The event listener + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_ALREADY_EXIST The listener is already added. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + result AddShortcutRequestListener(IShortcutRequestListener& listener); + + /** + * Removes an IShortcutRequestListener from the %ShortcutManager. @n + * + * @since 2.1 + * + * @return An error code + * @param[in] listener The event listener + * @exception E_SUCCESS The method is successful. + * @exception E_OBJ_NOT_FOUND The listner is not found. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + */ + result RemoveShortcutRequestListener(IShortcutRequestListener& listener); + +private: + // + // This default constructor is intentionally declared as private to implement the %Singleton semantic. + // + // @since 2.1 + // + ShortcutManager(void); + + // + // This destructor is intentionally declared as private to implement the %Singleton semantic. + // + // @since 2.1 + // + virtual ~ShortcutManager(void); + + // + // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects. + // + // @since 2.1 + // + ShortcutManager& operator =(const ShortcutManager& rhs); + + // + // Constructs the instance of this class. + // + // @since 2.1 + // + // @return An error code + // @exception E_SUCCESS The method is successful. + // @exception E_SYSTEM The method cannot proceed due to a severe system error. + // + result Construct(void); + + static void InitSingleton(void); + static void DestroySingleton(void); + +private: + static ShortcutManager* __pTheInstance; + friend struct std::default_delete< ShortcutManager >; + class _ShortcutManagerImpl* __pShortcutManagerImpl; +}; + +}} // Tizen::Shell +#endif /* _FSHELL_SHORTCUT_MANAGER_H_ */ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77394ea..f01bbfd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -110,10 +110,12 @@ ADD_LIBRARY (${this_target} SHARED ${${this_target}_SOURCE_FILES}) ## SET LINKER FLAGS SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") +TARGET_LINK_LIBRARIES(${this_target} "-lpthread" ) 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} "-L/usr/lib/osp -losp-shell-core" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-application" ) TARGET_LINK_LIBRARIES(${this_target} "-lcapi-appfw-app-manager" ) TARGET_LINK_LIBRARIES(${this_target} "-lnotification" ) diff --git a/src/FShellLiveboxManager.cpp b/src/FShellLiveboxManager.cpp old mode 100644 new mode 100755 index e2e730e..bc1d25a --- a/src/FShellLiveboxManager.cpp +++ b/src/FShellLiveboxManager.cpp @@ -20,6 +20,7 @@ * @brief This is the implementation for the LiveboxManager class. */ +#include #include #include @@ -49,6 +50,8 @@ using namespace Tizen::Graphics; namespace Tizen { namespace Shell { +LiveboxManager* LiveboxManager::__pTheInstance = null; + LiveboxManager::LiveboxManager() :__pLiveboxManagerImpl(null) { @@ -58,24 +61,42 @@ LiveboxManager::LiveboxManager() LiveboxManager::~LiveboxManager() { } - -LiveboxManager* -LiveboxManager::GetInstance() -{ - static LiveboxManager* pLiveboxManager = null; - if( pLiveboxManager == null) - { - pLiveboxManager = new (std::nothrow) 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; -} + +void +LiveboxManager::InitSingleton(void) +{ + std::unique_ptr pInst(new (std::nothrow) LiveboxManager()); + SysTryReturnVoidResult(NID_APP, pInst, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + result r = pInst->Construct(); + SysTryReturnVoidResult(NID_APP, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r)); + + __pTheInstance = pInst.release(); + std::atexit(DestroySingleton); +} + +void +LiveboxManager::DestroySingleton(void) +{ + delete __pTheInstance; +} + +LiveboxManager* +LiveboxManager::GetInstance(void) +{ + static pthread_once_t onceBlock = PTHREAD_ONCE_INIT; + if (__pTheInstance == null) + { + ClearLastResult(); + pthread_once(&onceBlock, InitSingleton); + result r = GetLastResult(); + if (IsFailed(r)) + { + onceBlock = PTHREAD_ONCE_INIT; + } + } + return __pTheInstance; +} result LiveboxManager::Construct() diff --git a/src/FShell_LiveboxManagerImpl.cpp b/src/FShell_LiveboxManagerImpl.cpp index d2f97d8..8e129ed 100644 --- a/src/FShell_LiveboxManagerImpl.cpp +++ b/src/FShell_LiveboxManagerImpl.cpp @@ -44,9 +44,9 @@ #include #include +#include "FShell_ShortcutManagerImpl.h" #include "FShell_LiveboxManagerProxy.h" #include "FShell_LiveboxManagerImpl.h" - #include "FShell_LiveboxProviderInfoImpl.h" namespace Tizen { namespace Shell @@ -105,15 +105,11 @@ int GetLiveboxProviderInfoCallback(const char *packageId, const char *pProviderI SysTryReturn(NID_APP, pLiveboxProviderInfos, 0, E_SYSTEM, "[E_SYSTEM] system error."); String providerId(pProviderId); - String appId; String providerName; - _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, appId, providerName); LiveboxProviderInfo* pInfo = _LiveboxProviderInfoImpl::GetLiveboxProviderInfoN(appId, providerName, is_prime); -// _LiveboxProviderInfoImpl::GetImpl(*pInfo)->__isDefault = is_prime; - pLiveboxProviderInfos->Add(*pInfo); return 0; @@ -176,8 +172,10 @@ _LiveboxManagerImpl::GetDefaultLiveboxProviderInfoN(const Tizen::App::PackageId& int ret = livebox_service_get_pkglist(GetDefaultLiveboxProviderInfoCallback, pPackageId.get()); if (ret < 0) { - SysLog(NID_APP, "Failed to invoke livebox_service_get_pkglist, ret (%d)", ret); + SysLog(NID_APP, "There is no Livebox provider specifed, or It's failed to invoke livebox_service_get_pkglist, ret (%d)", ret); + return null; } + String defaultProvider(__tempDefaultProviderResult); if( !defaultProvider.IsEmpty()) { @@ -186,7 +184,6 @@ _LiveboxManagerImpl::GetDefaultLiveboxProviderInfoN(const Tizen::App::PackageId& _LiveboxManagerImpl::ExtractAppIdAndProviderName(__tempDefaultProviderResult, appId, providerName); pInfo = _LiveboxProviderInfoImpl::GetLiveboxProviderInfoN(appId, providerName, true); -// _LiveboxProviderInfoImpl::GetImpl(*pInfo)->__isDefault = true; } return pInfo; } @@ -227,8 +224,9 @@ _LiveboxManagerImpl::IsLiveboxProviderDefault(const Tizen::App::AppId& appId, co } // 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) +int LiveboxRequestHandlerCallback(const char* providerId, const char* text, int type, const char* content_info, const char* icon, int pid, double period, void *data) { + SysLog(NID_APP, "Enter"); SysTryReturn(NID_APP, providerId, 0, E_SYSTEM, "[E_SYSTEM] providerId is null!"); _LiveboxManagerImpl* pLiveboxManager = static_cast<_LiveboxManagerImpl*>(data); @@ -238,18 +236,18 @@ int LiveboxRequestEventHandler(const char* providerId, const char* text, int typ String providerName; _LiveboxManagerImpl::ExtractAppIdAndProviderName(providerId, appId, providerName); - ILiveboxAddRequestListener* pListener = pLiveboxManager->GetAddRequestListener(); + ILiveboxAddRequestListener* pListener = _LiveboxManagerImpl::GetInstance()->GetAddRequestListener(); SysTryReturn(NID_APP, pLiveboxManager, 0, E_SYSTEM, "[E_SYSTEM] pListener is null!"); pListener->OnLiveboxAddRequested(appId, providerName, text, content_info); - return 0; } result _LiveboxManagerImpl::SetLiveboxAddRequestListener(ILiveboxAddRequestListener* pListener) { - int ret = shortcut_set_request_cb(LiveboxRequestEventHandler, this ); - SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "failed to shortcut_set_request_cb (%d)", ret); +// int ret = shortcut_set_request_cb(LiveboxRequestHandlerCallback, this ); +// SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "failed to shortcut_set_request_cb (%d)", ret); + _ShortcutManagerImpl::GetInstance()->SetLiveboxRequestHandlerCallback(LiveboxRequestHandlerCallback); __pLiveboxRequestEventListener = pListener; return E_SUCCESS; diff --git a/src/FShell_LiveboxProviderManagerImpl.cpp b/src/FShell_LiveboxProviderManagerImpl.cpp index e002010..b22f9c0 100644 --- a/src/FShell_LiveboxProviderManagerImpl.cpp +++ b/src/FShell_LiveboxProviderManagerImpl.cpp @@ -294,7 +294,7 @@ _LiveboxProviderManagerImpl::AddLivebox(const Tizen::App::AppId& viewerAppId, co 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); + int ret = add_to_home_livebox(pProviderId.get(), pName.get(), LIVEBOX_TYPE_DEFAULT, pContent.get(), pIcon.get(), -1.0l, AddLiveboxCallback, this); SysTryReturnResult(NID_APP, ret != -ENOTCONN, E_CONNECTION_FAILED, "[E_CONNECTION_FAILED] failed to add_to_home_livebox"); SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "[E_SYSTEM] failed to add_to_home_livebox (%s)", strerror(r)); diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 683b0d7..ae3d2b1 100755 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -35,8 +35,8 @@ SET (${this_target}_SOURCE_FILES FShell_NotificationRequestImpl.cpp FShell_NotificationManagerProxy.cpp FShell_NotificationManagerIpcMessages.cpp -# FShellShortcutManager.cpp - FShellHomeManager.cpp + FShellShortcutManager.cpp + FShell_ShortcutManagerImpl.cpp FShellLockManager.cpp FShell_LockManagerImpl.cpp ) diff --git a/src/core/FShellHomeManager.cpp b/src/core/FShellShortcutManager.cpp similarity index 55% rename from src/core/FShellHomeManager.cpp rename to src/core/FShellShortcutManager.cpp index da752d9..a740b88 100644 --- a/src/core/FShellHomeManager.cpp +++ b/src/core/FShellShortcutManager.cpp @@ -16,8 +16,8 @@ // /** - * @file FShellHomeManager.cpp - * @brief This is the implementation for the HomeManager class. + * @file FShellShortcutManager.cpp + * @brief This is the implementation for the ShortcutManager class. */ #include @@ -25,11 +25,12 @@ #include #include -#include +#include #include #include #include +#include using namespace Tizen::App; using namespace Tizen::Base; @@ -38,43 +39,47 @@ using namespace Tizen::Base; namespace Tizen { namespace Shell { -HomeManager::HomeManager() - :__pHomeManagerImpl(null) +ShortcutManager::ShortcutManager() + :__pShortcutManagerImpl(null) { - } -HomeManager::~HomeManager() +ShortcutManager::~ShortcutManager() { - SysLog(NID_APP, "HomeManager is destroyed."); } -HomeManager* -HomeManager::GetInstance() +ShortcutManager* +ShortcutManager::GetInstance() { - static HomeManager* pHomeManager = null; - if( pHomeManager == null) + static ShortcutManager* pShortcutManager = null; + if( pShortcutManager == null) { - pHomeManager = new (std::nothrow) HomeManager; - SysTryReturn(NID_APP, pHomeManager, null, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY" ); + pShortcutManager = new (std::nothrow) ShortcutManager; + SysTryReturn(NID_APP, pShortcutManager, null, E_OUT_OF_MEMORY, "E_OUT_OF_MEMORY" ); - result r = pHomeManager->Construct(); + result r = pShortcutManager->Construct(); // SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); - SysAssertf(!IsFailed(r), "Failed to construct HomeManager!!"); + SysAssertf(!IsFailed(r), "Failed to construct ShortcutManager!!"); } - return pHomeManager; + return pShortcutManager; } result -HomeManager::Construct() +ShortcutManager::Construct() { + __pShortcutManagerImpl = _ShortcutManagerImpl::GetInstance(); return E_SUCCESS; } result -HomeManager::AddShortcut(const AppId& appId, const String& displayName, const String& iconFilePath, const String& uriData) +ShortcutManager::AddShortcut(const AppId& appId, const String& displayName, const String& iconFilePath, const String& uriData, bool allowDuplication) { + if( allowDuplication ) + { + SysLog(NID_APP, "This feature(allowDuplication) is not yet implemented!"); + } + std::unique_ptr pAppId(_StringConverter::CopyToCharArrayN(appId)); std::unique_ptr pIcon(_StringConverter::CopyToCharArrayN(iconFilePath)); std::unique_ptr pName(_StringConverter::CopyToCharArrayN(displayName)); @@ -87,4 +92,17 @@ HomeManager::AddShortcut(const AppId& appId, const String& displayName, const St return E_SUCCESS; } +result +ShortcutManager::AddShortcutRequestListener(IShortcutRequestListener& listener) +{ + return __pShortcutManagerImpl->AddShortcutRequestListener(listener); +} + +result +ShortcutManager::RemoveShortcutRequestListener(IShortcutRequestListener& listener) +{ + return __pShortcutManagerImpl->RemoveShortcutRequestListener(listener); +} + + }} // Tizen::Shell diff --git a/src/core/FShell_ShortcutManagerImpl.cpp b/src/core/FShell_ShortcutManagerImpl.cpp new file mode 100644 index 0000000..9bb46d5 --- /dev/null +++ b/src/core/FShell_ShortcutManagerImpl.cpp @@ -0,0 +1,156 @@ +// +// Open Service Platform +// Copyright (c) 2013 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_ShortcutManagerImpl.cpp + * @brief This is the implementation for the _ShortcutManagerImpl class. + */ + +#include + +#include + +#include +#include +#include +#include "FShell_ShortcutManagerImpl.h" + +namespace Tizen { namespace Shell +{ + +using namespace Tizen::Base; +using namespace Tizen::Base::Collection; +using namespace Tizen::App; + +request_cb_t __pLiveboxRequestHandlerCallback = null; + +_ShortcutManagerImpl::_ShortcutManagerImpl() +{ +} + +_ShortcutManagerImpl::~_ShortcutManagerImpl() +{ +} + + +_ShortcutManagerImpl* +_ShortcutManagerImpl::GetInstance() +{ + static _ShortcutManagerImpl* __pShortcutManagerImpl = null; + if( __pShortcutManagerImpl == null) + { + __pShortcutManagerImpl = new (std::nothrow)_ShortcutManagerImpl; + SysTryReturn(NID_APP, __pShortcutManagerImpl, null, E_OUT_OF_MEMORY, "Allocating new _LiveboxManagerProxy failed."); + + result r = __pShortcutManagerImpl->Construct(); + SysTryReturn(NID_APP, !IsFailed(r), null, r, "[%s] Propagating.", GetErrorMessage(r)); + } + return __pShortcutManagerImpl; +} + +int ShortcutRequestEventHandlerCB(const char* appId, const char* text, int type, const char* content_info, const char* icon, int pid, double period, void *data) +{ + SysTryReturn(NID_APP, appId, 0, E_SYSTEM, "[E_SYSTEM] appId is null!"); + SysLog(NID_APP, "Tizen::Shell::ShortcutManager - Shortcut request received."); + + _ShortcutManagerImpl* pShortcutManager = static_cast<_ShortcutManagerImpl*>(data); + SysTryReturn(NID_APP, pShortcutManager, 0, E_SYSTEM, "[E_SYSTEM] pShortcutManager is null!"); + + const ArrayListT* pListenerList = pShortcutManager->GetShortcutRequestListenerList(); + IShortcutRequestListener* pListener; + + SysLog(NID_APP, "There is(are) %d request handler(s).", pListenerList->GetCount()); + for(int i = 0; i < pListenerList->GetCount(); i ++) + { + pListener = null; + pListenerList->GetAt(i, pListener); + if( pListener != null) + { + pListener->OnShortcutAddRequested(appId, text, icon, content_info); + } + } + + SysLog(NID_APP, "Successed."); + return 0; +} + +// c - style callback for shortcut_set_request_cb +int ShortcutRequestEventReceiverCB(const char* appId, const char* text, int type, const char* content_info, const char* icon, int pid, double period, void *data) +{ + SysTryReturn(NID_APP, appId, 0, E_SYSTEM, "[E_SYSTEM] providerId is null!"); + + if( type == SHORTCUT_PACKAGE + || type == SHORTCUT_DATA + || type == SHORTCUT_DATA) + { + ShortcutRequestEventHandlerCB(appId, text, type, content_info, icon, pid, period, data); + } + else + { + if( __pLiveboxRequestHandlerCallback != null) + { + SysLog(NID_APP, "Invoking livebox request handler."); + __pLiveboxRequestHandlerCallback(appId, text, type, content_info, icon, pid, period, data); + } + } + + SysLog(NID_APP, "Successed."); + return 0; +} + +result +_ShortcutManagerImpl::Construct() +{ + int ret = shortcut_set_request_cb(ShortcutRequestEventReceiverCB, this ); + SysTryReturnResult(NID_APP, ret == 0, E_SYSTEM, "failed to shortcut_set_request_cb (%d)", ret); + + __shortcutRequestListenerList.Construct(); + SysLog(NID_APP, "Successed."); + + return E_SUCCESS; +} + + +result +_ShortcutManagerImpl::AddShortcutRequestListener(IShortcutRequestListener& listener) +{ + SysTryReturnResult(NID_APP, !__shortcutRequestListenerList.Contains(&listener), E_OBJ_ALREADY_EXIST, "The listener is already added."); + SysLog(NID_APP, "(%x)", &listener); + return __shortcutRequestListenerList.Add(&listener); +} + +result +_ShortcutManagerImpl::RemoveShortcutRequestListener(IShortcutRequestListener& listener) +{ + SysLog(NID_APP, "(%x)", &listener); + return __shortcutRequestListenerList.Remove(&listener); +} + +const Tizen::Base::Collection::ArrayListT* +_ShortcutManagerImpl::GetShortcutRequestListenerList(void) const +{ + return &__shortcutRequestListenerList; +} + +void +_ShortcutManagerImpl::SetLiveboxRequestHandlerCallback(request_cb_t pLiveboxRequestHandlerFn) +{ + __pLiveboxRequestHandlerCallback = pLiveboxRequestHandlerFn; +} + + +}} // Tizen::Shell diff --git a/src/inc/FShell_ShortcutManagerImpl.h b/src/inc/FShell_ShortcutManagerImpl.h new file mode 100644 index 0000000..23d0bf6 --- /dev/null +++ b/src/inc/FShell_ShortcutManagerImpl.h @@ -0,0 +1,127 @@ +// +// Open Service Platform +// Copyright (c) 2013 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_ShortcutManagerImpl.h + * @brief This is the header file for the _ShortcutManagerImpl class. + * + * This header file contains the declarations of the _ShortcutManagerImpl class. + */ + +#ifndef _FSHELL_INTERNAL_SHORTCUT_MANAGERIMPL_H_ +#define _FSHELL_INTERNAL_SHORTCUT_MANAGERIMPL_H_ + +#include +#include +#include + +namespace Tizen { namespace Shell { + + +class _OSP_EXPORT_ _ShortcutManagerImpl + : public Tizen::Base::Object +{ +public: + static _ShortcutManagerImpl* GetInstance(void); + + /** + * Request the Home app to add the spefied shortcut. + * + * @privlevel public + * @privilege http::tizen.org/privilege/shortcut + * + * @since 2.1 + * + * @return An error code + * @param[in] appId The application ID + * @param[in] displayName The display name of shortcut + * @param[in] iconPath The icon file path + * @param[in] uriData Uri that will be delivered by IAppControlProviderEventListener::OnAppControlRequestReceived(), when the application is started via shortcut. + * @param[in] allowDuplication Flag to allow duplicate shortcut. + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * + * @remark Icon file should be placed in sub directory of 'shared/res' to be used by the Home app. + * For more information on shared directory, see I/O Overview. + * For more information on icon file, see General Information. + * + * If uriData is specified, application will be started by AppControl with http://tizen.org/appcontrol/operation/view operation, when it's launched from the Home app via shortcut. + * Or else application will be started by AppControl with default operation(http://tizen.org/appcontrol/operation/main). + * + * @see IAppControlEventListener::OnAppControlRequestReceived() + * @see IShortcutRequestListener::OnShortcutAddRequested() + * + * The following example demonstrates how to add shortcut. + * + * @code + * #include + * #include + * + * using namespace Tizen::App; + * using namespace Tizen::Shell; + * + * String appId = App::GetInstance()->GetAppId(); + * String iconPath = AppManager::GetInstance()->GetAppSharedPath(appId) + L"res/my_icons/my_icon.png"; + * ShortcutManager::GetInstance()->AddShortcut(appId, L"MyApp", iconPath , L"myapp://mydata/myitem"); + * @endcode + */ + result AddShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName, const Tizen::Base::String& iconPath, const Tizen::Base::String& uriData, bool allowDuplication = true ); + + /** + * Requests the Home app to remove the specified shortcut. + * + * @privlevel public + * @privilege http://tizen.org/privilege/shortcut + * + * @since 2.1 + * + * @return An error code + * @param[in] appId The application ID + * @param[in] displayName The display name of shortcut + * + * @exception E_SUCCESS The method is successful. + * @exception E_APP_NOT_INSTALLED The application is not installed. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error. + * + * @remark If there are one more shortcuts with duplicated appId and displayName in the Home app, All of them will be removed. + * + * @see IShortcutRequestListener::OnShortcutRemoveRequested() + */ + result RemoveShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName); + + result AddShortcutRequestListener(IShortcutRequestListener& listener); + result RemoveShortcutRequestListener(IShortcutRequestListener& listener); + + // internal + void SetLiveboxRequestHandlerCallback(int(*PShortcutRequestCallback)(const char *appid, const char *name, int type, const char *content_info, const char *icon, int pid, double period, void *data)); + const Tizen::Base::Collection::ArrayListT* GetShortcutRequestListenerList(void) const; + +private: + _ShortcutManagerImpl(void); + virtual ~_ShortcutManagerImpl(void); + result Construct(void); + +private: + Tizen::Base::Collection::ArrayListT __shortcutRequestListenerList; +}; + +}} // Tizen::Shell +#endif /* _FSHELL_INTERNAL_SHORTCUT_MANAGERIMPL_H_ */ -- 2.7.4