2 // Open Service Platform
3 // Copyright (c) 2012 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 FApp_AppControlImpl.h
20 * @brief This is the header file for the _AppControlImpl class.
23 #ifndef _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
24 #define _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
26 #include <app_service.h>
29 #include <FBaseObject.h>
30 #include <FAppTypes.h>
31 #include <FOspConfig.h>
32 #include <FAppAppControl.h>
34 #include "FApp_AppManagerImpl.h"
36 namespace Tizen { namespace Base { class String; } }
37 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
39 namespace Tizen { namespace App
43 class IAppControlEventListener;
44 class IAppControlResponseListener;
47 enum _AppControlProperty
49 _APPCONTROL_PROPERTY_NONE = 0x0,
50 _APPCONTROL_PROPERTY_PUBLIC = 0x01,
51 _APPCONTROL_PROPERTY_PERSISTENT_DLL = 0x08,
52 _APPCONTROL_PROPERTY_SLP = 0x100,
53 _APPCONTROL_PROPERTY_OSP = 0x200,
54 _APPCONTROL_PROPERTY_ALIAS = 0x400,
55 _APPCONTROL_PROPERTY_APPID_CHANGE = 0x800,
58 class _OSP_EXPORT_ _AppControlImpl
59 : public Tizen::Base::Object
63 * AppControl delegate constructor
65 static AppControl* CreateN(const Tizen::Base::String& path, const Tizen::Base::String& aId, const Tizen::Base::String& oId, const Tizen::Base::String& name, int prop);
68 * AppControl delegate constructor
70 static AppControl* CreateN(const AppId& appId, const Tizen::Base::String& operationId, bool changeAppId);
73 * AppControl delegate constructor
75 static AppControl* CreateN(const AppControl& ac);
78 * Internal GetImpl() method.
80 static const _AppControlImpl* GetInstance(const AppControl& ac);
83 * Internal GetImpl() method.
85 static _AppControlImpl* GetInstance(AppControl& ac);
88 * Starts the resolved application control. @n
89 * Once the application starts, it goes to the background and the target
90 * application control is displayed.
92 * @return An error code
93 * @param[in] pDataList The data list to deliver to the resolved application control @n
94 * The maximum size of the list is 4096 bytes.
95 * @param[in] pListener The application control callback listener @n
96 * Some application controls need to get the callback result by implementing
97 * the IAppControlEventListener interface.
98 * @exception E_SUCCESS The method is successful.
99 * @exception E_MAX_EXCEEDED The size of @c pDataList has exceeded the maximum limit.
100 * @exception E_OUT_OF_MEMORY The memory is insufficient.
101 * @exception E_OBJ_NOT_FOUND The target application control resource is not found.
102 * @exception E_IN_PROGRESS The application control is in progress: @n
103 * - The application has already started an _AppControlImpl. @n
104 * - The target application has already started.
105 * @exception E_SYSTEM A system error has occurred.
106 * @remarks If the %IAppControlEventListener instance (@c pListener) needs to get the
107 * callback result for an application control, it should be valid till
108 * IAppControlEventListener::OnAppControlCompleted() is invoked.
109 * For example, a form object listener should not be deleted before the
110 * system invokes IAppControlEventListener::OnAppControlCompleted().
112 result Start(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
115 * Starts the found application control. @n
116 * Once the found application starts, the calling application goes to the background and the found
117 * application is displayed.
119 * @return An error code
120 * @param[in] pUriData A pointer to the URI data
121 * @param[in] pDataType A pointer to the MIME type (RFC 2046) data
122 * @param[in] pExtraData The Tizen::Base::String key and Tizen::Base::String value pair map to deliver to the resolved application @n
123 * The maximum size is 16 kilo bytes.
124 * @param[in] pListener The application control callback listener @n
125 * Some application need to get the result by implementing the IAppControlResponseListener interface.
126 * @exception E_SUCCESS The method is successful.
127 * @exception E_MAX_EXCEEDED The size of @c pExtraData has exceeded the maximum limit.
128 * @exception E_OBJ_NOT_FOUND The target application control is not found.
129 * @exception E_IN_PROGRESS The application control is in progress: @n
130 * - The application has already started an %AppControl.
131 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
132 * @remarks If the calling application needs to get some result for application control,
133 * it must be valid till %IAppControlResponseListener::OnAppControlCompleteResponseReceived() is invoked.
134 * For example, a form object listener must not be deleted before the
135 * system invokes %IAppControlResponseListener::OnAppControlCompleteResponseReceived().
136 * @see IAppControlResponseListener, AppManager::FindAppControlN(), AppManager::FindAppControlsN()
138 result Start(const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
141 * Gets the name of the application that provides the features represented by this %_AppControlImpl instance.
143 * @return The name of the application providing this %_AppControlImpl instance
145 Tizen::Base::String GetAppName(void);
148 * Gets the associated application ID. @n
150 * @return The application control ID
152 Tizen::Base::String GetAppId(void) const;
155 * Gets the associated application control provider ID. @n
157 * @return The application control provider ID
159 const Tizen::Base::String& GetAppControlProviderId(void) const;
162 * Gets the associated operation ID. @n
164 * @return The operation ID
166 const Tizen::Base::String& GetOperationId(void) const;
169 * Returns the associated application control categories.
171 * @return A pointer to the list of application control categories, @n
172 * else @c null if an error occurs
173 * @exception E_SUCCESS The method is successful.
174 * @exception E_OUT_OF_MEMORY The memory is insufficient.
175 * @exception E_SYSTEM A system error has occurred.
176 * @remarks The specific error code can be accessed using the GetLastResult() method.
178 Tizen::Base::Collection::IList* GetCategoryListN(void) const;
181 * Stops the activated application control. @n
183 * @return An error code
184 * @exception E_SUCCESS The method is successful.
185 * @exception E_SYSTEM A system error has occurred.
186 * @exception E_INVALID_OPERATION The application control is not permitted to call this method.
187 * @remarks This method is asynchronous.
192 * Finds the matching application control with given operation ID, URI pattern, data type and category and
193 * starts the found one. @n
194 * If there are more than one application controls found, then the selection is shown for user and the one that the user selects is started.
195 * When the found application control is started, the URI pattern, MIME type, and extra data is delivered via IAppControlProviderEventListener.
197 * @return An error code
198 * @param[in] pOperationId The operation ID
199 * @param[in] pUriPattern A URI pattern which is used for application control resolution and to be delivered as the argument
200 * @param[in] pDataType The MIME type (RFC 2046) or file extension @n
201 * The '.' prefix must be used when specifying the file extension.
202 * @param[in] pCategory The application control category
203 * @param[in] pExtraData The extra collection data to be delivered to the resolved application @n
204 * The maximum size is 16 kilo bytes.
205 * @param[in] pListener A listener that gets notified
206 * @exception E_SUCCESS The method is successful.
207 * @exception E_MAX_EXCEEDED The size of @c pDataList has exceeded the maximum limit.
208 * @exception E_OBJ_NOT_FOUND The application control is not found.
209 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
210 * @see IAppControlResponseListener, IAppControlProviderEventListener
212 static result FindAndStart(const Tizen::Base::String& operationId, const Tizen::Base::String* pUriPattern, const Tizen::Base::String* pDataType, const Tizen::Base::String* pCategory, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
215 * Stops the event listener for receiving application control result.
217 * @param[in] pListener The listener to stop receiving the application control result
219 static void StopAppControlResponseListener(IAppControlResponseListener* pListener);
221 static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
223 static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IMap* pData, IAppControlResponseListener* pListener);
225 bool IsPublic(void) const
227 return (_property & _APPCONTROL_PROPERTY_PUBLIC);
230 void SetProperty(int prop)
236 _AppControlImpl(const AppControl& value);
239 * This is the default constructor for this class.
241 _AppControlImpl(void);
243 _AppControlImpl(const _AppControlImpl& rhs);
245 _AppControlImpl& operator =(const _AppControlImpl& rhs);
248 * This is the destructor for this class.
250 virtual ~_AppControlImpl(void);
252 result StartOsp(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
254 result StartOsp(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
256 result StartNative(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
258 result StartNative(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
260 static result InvokeStartAppControl(Tizen::Base::Runtime::_LibraryImpl& lib, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
262 static result InvokeStartAppControl(Tizen::Base::Runtime::_LibraryImpl& lib, int req, const Tizen::Base::String& appId, const Tizen::Base::String& oId, const Tizen::Base::Collection::IList* pList);
264 static result AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop);
266 static result AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop);
269 const AppControl& _appControl;
271 Tizen::Base::String _path;
272 Tizen::Base::String _provider;
273 Tizen::Base::String _opId;
274 Tizen::Base::String _appName;
279 friend class AppControl;
280 friend class _AppArg;
281 }; // _AppControlImpl
285 #endif // _FAPP_INTERNAL_APP_CONTROL_IMPL_H_