2 // Open Service Platform
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FShellShortcutManager.h
20 * @brief This is the header file for the %ShortcutManager class.
22 * This header file contains the declarations of the %ShortcutManager class.
25 #ifndef _FSHELL_SHORTCUT_MANAGER_H_
26 #define _FSHELL_SHORTCUT_MANAGER_H_
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
30 #include <FAppTypes.h>
33 namespace Tizen { namespace Shell
36 class IShortcutRequestListener;
39 * @class ShortcutManager
40 * @brief This class helps an application to add its shortcut to the Home app.
44 * @final This class is not intended for extension.
46 * The %ShortcutManager class helps an application to add its shortcut to the Home app.
48 class _OSP_EXPORT_ ShortcutManager
49 : public Tizen::Base::Object
54 * Gets the %ShortcutManager instance.
58 * @return A pointer to the %ShortcutManager instance, @n
59 * else @c null if it fails
60 * @exception E_SUCCESS The method is successful.
61 * @exception E_OUT_OF_MEMORY The memory is insufficient.
62 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
63 * @remarks The specific error code can be accessed using the GetLastResult() method.
65 static ShortcutManager* GetInstance(void);
68 * Adds a shortcut to Home app.
72 * @privilege %http::tizen.org/privilege/shortcut.install
74 * @return An error code
75 * @param[in] appId The application ID
76 * @param[in] displayName The display name of shortcut
77 * @param[in] iconPath The icon file path
78 * @param[in] uriData Uri that will be delivered by Tizen::App::IAppControlProviderEventListener::OnAppControlRequestReceived(), when the application is started using a shortcut.
79 * @param[in] allowDuplication Flag to allow duplicate shortcut
81 * @exception E_SUCCESS The method is successful.
82 * @exception E_APP_NOT_INSTALLED The application is not installed.
83 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
84 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
87 * - Icon file should be placed in sub directory of 'shared/res' to be used by the Home app.
88 * For more information on shared directory, see <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/io_overview.htm">I/O Overview</a>
89 * and see <a href="../org.tizen.native.appprogramming/html/app_dev_process/manifest_general.htm">General Information</a> for icon file.
90 * - If @c uriData is specified, application will be started by AppControl with %http://tizen.org/appcontrol/operation/view operation, when it is launched from the Home app using a shortcut.
91 * Or else application will be started by AppControl with default operation(%http://tizen.org/appcontrol/operation/main).
93 * @see Tizen::App::IAppControlEventListener::OnAppControlRequestReceived()
94 * @see IShortcutRequestListener::OnShortcutAddRequested()
96 * The following example demonstrates how to add shortcut.
100 * #include <FShell.h>
102 * using namespace Tizen::App;
103 * using namespace Tizen::Shell;
105 * String displayName = L"Shortcut to my app";
106 * String iconPath = App::GetInstance()->GetAppSharedPath() + L"res/screen-density-xhigh/mainmenu.png";
107 * String uriData = L"myapp://mydata/myitem";
108 * ShortcutManager::GetInstance()->AddShortcut(App::GetInstance()->GetAppId(), displayName, iconPath , uriData);
111 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 );
114 * Removes a shortcut from Home app.
118 * @privilege %http://tizen.org/privilege/shortcut
120 * @return An error code
121 * @param[in] appId The application ID
122 * @param[in] displayName The display name of shortcut
123 * @exception E_SUCCESS The method is successful.
124 * @exception E_APP_NOT_INSTALLED The application is not installed.
125 * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
126 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
127 * @remarks If there are more than one shortcuts with duplicated @c appId and @c displayName in the Home app, all of them will be removed.
129 * @see IShortcutRequestListener::OnShortcutRemoveRequested()
131 result RemoveShortcut(const Tizen::App::AppId& appId, const Tizen::Base::String& displayName);
134 * Adds an IShortcutRequestListener to the %ShortcutManager. @n
135 * The listener gets notified when requested to add a shortcut.
139 * @return An error code
140 * @param[in] listener The event listener to add
141 * @exception E_SUCCESS The method is successful.
142 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
143 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
145 result AddShortcutRequestListener(IShortcutRequestListener& listener);
148 * Removes an IShortcutRequestListener from the %ShortcutManager.
152 * @return An error code
153 * @param[in] listener The event listener to remove
154 * @exception E_SUCCESS The method is successful.
155 * @exception E_OBJ_NOT_FOUND The listener is not found.
156 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
158 result RemoveShortcutRequestListener(IShortcutRequestListener& listener);
162 // This default constructor is intentionally declared as private to implement the %Singleton semantic.
166 ShortcutManager(void);
169 // This destructor is intentionally declared as private to implement the %Singleton semantic.
173 virtual ~ShortcutManager(void);
176 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
180 ShortcutManager& operator =(const ShortcutManager& rhs);
183 // Constructs the instance of this class.
187 // @return An error code
188 // @exception E_SUCCESS The method is successful.
189 // @exception E_SYSTEM The method cannot proceed due to a severe system error.
191 result Construct(void);
193 static void InitSingleton(void);
194 static void DestroySingleton(void);
197 static ShortcutManager* __pTheInstance;
198 friend struct std::default_delete< ShortcutManager >;
199 class _ShortcutManagerImpl* __pShortcutManagerImpl;
203 #endif /* _FSHELL_SHORTCUT_MANAGER_H_ */