2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file FApp_AppControlImpl.h
19 * @brief This is the header file for the _AppControlImpl class.
22 #ifndef _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
23 #define _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
25 #include <app_service.h>
28 #include <FBaseObject.h>
29 #include <FAppTypes.h>
30 #include <FOspConfig.h>
31 #include <FAppAppControl.h>
32 #include <FBaseColArrayListT.h>
34 #include "FApp_AppManagerImpl.h"
35 #include "FApp_IAppControlResponseEventListener.h"
37 namespace Tizen { namespace Base { class String; } }
38 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
40 namespace Tizen { namespace App
44 class IAppControlEventListener;
45 class IAppControlResponseListener;
48 enum _AppControlProperty
50 _APPCONTROL_PROPERTY_NONE = 0x0,
51 _APPCONTROL_PROPERTY_PUBLIC = 0x01,
52 _APPCONTROL_PROPERTY_PERSISTENT_DLL = 0x08,
53 _APPCONTROL_PROPERTY_SLP = 0x100,
54 _APPCONTROL_PROPERTY_OSP = 0x200,
55 _APPCONTROL_PROPERTY_ALIAS = 0x400,
56 _APPCONTROL_PROPERTY_APPID_CHANGE = 0x800,
59 class _OSP_EXPORT_ _AppControlImpl
60 : public Tizen::Base::Object
61 , public Tizen::App::_IAppControlResponseEventListener
62 , virtual public Tizen::Base::Runtime::IEventListener
66 * AppControl delegate constructor
68 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);
71 * AppControl delegate constructor
73 static AppControl* CreateN(const AppId& appId, const Tizen::Base::String& operationId, bool changeAppId);
76 * AppControl delegate constructor
78 static AppControl* CreateN(const AppControl& ac);
81 * Internal GetImpl() method.
83 static const _AppControlImpl* GetInstance(const AppControl& ac);
86 * Internal GetImpl() method.
88 static _AppControlImpl* GetInstance(AppControl& ac);
91 * Starts the resolved application control. @n
92 * Once the application starts, it goes to the background and the target
93 * application control is displayed.
95 * @return An error code
96 * @param[in] pDataList The data list to deliver to the resolved application control @n
97 * The maximum size of the list is 4096 bytes.
98 * @param[in] pListener The application control callback listener @n
99 * Some application controls need to get the callback result by implementing
100 * the IAppControlEventListener interface.
101 * @exception E_SUCCESS The method is successful.
102 * @exception E_MAX_EXCEEDED The size of @c pDataList has exceeded the maximum limit.
103 * @exception E_OUT_OF_MEMORY The memory is insufficient.
104 * @exception E_OBJ_NOT_FOUND The target application control resource is not found.
105 * @exception E_IN_PROGRESS The application control is in progress: @n
106 * - The application has already started an _AppControlImpl. @n
107 * - The target application has already started.
108 * @exception E_SYSTEM A system error has occurred.
109 * @remarks If the %IAppControlEventListener instance (@c pListener) needs to get the
110 * callback result for an application control, it should be valid till
111 * IAppControlEventListener::OnAppControlCompleted() is invoked.
112 * For example, a form object listener should not be deleted before the
113 * system invokes IAppControlEventListener::OnAppControlCompleted().
115 result Start(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
118 * Starts the found application control. @n
119 * Once the found application starts, the calling application goes to the background and the found
120 * application is displayed.
122 * @return An error code
123 * @param[in] pUriData A pointer to the URI data
124 * @param[in] pDataType A pointer to the MIME type (RFC 2046) data
125 * @param[in] pExtraData The Tizen::Base::String key and Tizen::Base::String value pair map to deliver to the resolved application @n
126 * The maximum size is 16 kilo bytes.
127 * @param[in] pListener The application control callback listener @n
128 * Some application need to get the result by implementing the IAppControlResponseListener interface.
129 * @exception E_SUCCESS The method is successful.
130 * @exception E_MAX_EXCEEDED The size of @c pExtraData has exceeded the maximum limit.
131 * @exception E_OBJ_NOT_FOUND The target application control is not found.
132 * @exception E_IN_PROGRESS The application control is in progress: @n
133 * - The application has already started an %AppControl.
134 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
135 * @remarks If the calling application needs to get some result for application control,
136 * it must be valid till %IAppControlResponseListener::OnAppControlCompleteResponseReceived() is invoked.
137 * For example, a form object listener must not be deleted before the
138 * system invokes %IAppControlResponseListener::OnAppControlCompleteResponseReceived().
139 * @see IAppControlResponseListener, AppManager::FindAppControlN(), AppManager::FindAppControlsN()
141 result Start(const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
144 * Gets the name of the application that provides the features represented by this %_AppControlImpl instance.
146 * @return The name of the application providing this %_AppControlImpl instance
148 Tizen::Base::String GetAppName(void);
151 * Gets the associated application ID. @n
153 * @return The application control ID
155 Tizen::Base::String GetAppId(void) const;
158 * Gets the associated application control provider ID. @n
160 * @return The application control provider ID
162 const Tizen::Base::String& GetAppControlProviderId(void) const;
165 * Gets the associated operation ID. @n
167 * @return The operation ID
169 const Tizen::Base::String& GetOperationId(void) const;
172 * Returns the associated application control categories.
174 * @return A pointer to the list of application control categories, @n
175 * else @c null if an error occurs
176 * @exception E_SUCCESS The method is successful.
177 * @exception E_OUT_OF_MEMORY The memory is insufficient.
178 * @exception E_SYSTEM A system error has occurred.
179 * @remarks The specific error code can be accessed using the GetLastResult() method.
181 Tizen::Base::Collection::IList* GetCategoryListN(void) const;
184 * Stops the activated application control. @n
186 * @return An error code
187 * @exception E_SUCCESS The method is successful.
188 * @exception E_SYSTEM A system error has occurred.
189 * @exception E_INVALID_OPERATION The application control is not permitted to call this method.
190 * @remarks This method is asynchronous.
195 * Finds the matching application control with given operation ID, URI pattern, data type and category and
196 * starts the found one. @n
197 * 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.
198 * When the found application control is started, the URI pattern, MIME type, and extra data is delivered via IAppControlProviderEventListener.
200 * @return An error code
201 * @param[in] pOperationId The operation ID
202 * @param[in] pUriPattern A URI pattern which is used for application control resolution and to be delivered as the argument
203 * @param[in] pDataType The MIME type (RFC 2046) or file extension @n
204 * The '.' prefix must be used when specifying the file extension.
205 * @param[in] pCategory The application control category
206 * @param[in] pExtraData The extra collection data to be delivered to the resolved application @n
207 * The maximum size is 16 kilo bytes.
208 * @param[in] pListener A listener that gets notified
209 * @exception E_SUCCESS The method is successful.
210 * @exception E_MAX_EXCEEDED The size of @c pDataList has exceeded the maximum limit.
211 * @exception E_OBJ_NOT_FOUND The application control is not found.
212 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
213 * @see IAppControlResponseListener, IAppControlProviderEventListener
215 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);
218 * Stops the event listener for receiving application control result.
220 * @param[in] pListener The listener to stop receiving the application control result
222 static void StopAppControlResponseListener(IAppControlResponseListener* pListener);
224 static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
226 static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IMap* pData, IAppControlResponseListener* pListener);
228 bool IsPublic(void) const
230 return (_property & _APPCONTROL_PROPERTY_PUBLIC);
233 void SetProperty(int prop)
238 virtual void OnAppControlResponseEventReceivedN(const Tizen::Base::Runtime::IEventArg* arg);
240 _AppControlImpl(const AppControl& value);
243 * This is the default constructor for this class.
245 _AppControlImpl(void);
247 _AppControlImpl(const _AppControlImpl& rhs);
249 _AppControlImpl& operator =(const _AppControlImpl& rhs);
252 * This is the destructor for this class.
254 virtual ~_AppControlImpl(void);
256 result StartOsp(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
258 result StartOsp(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
260 result StartNative(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
262 result StartNative(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
264 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);
266 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);
268 static result AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
270 static result AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
273 const AppControl& _appControl;
275 Tizen::Base::String _path;
276 Tizen::Base::String _provider;
277 Tizen::Base::String _opId;
278 Tizen::Base::String _appName;
284 Tizen::Base::Collection::ArrayListT<int> __appControlResponseEventList;
286 friend class AppControl;
287 friend class _AppArg;
288 }; // _AppControlImpl
292 #endif // _FAPP_INTERNAL_APP_CONTROL_IMPL_H_