Applied sizeof operator on fixed sized array to calculate size.
[platform/framework/native/appfw.git] / src / app / inc / FApp_AppControlImpl.h
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16
17 /**
18  * @file        FApp_AppControlImpl.h
19  * @brief       This is the header file for the _AppControlImpl class.
20  */
21
22 #ifndef _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
23 #define _FAPP_INTERNAL_APP_CONTROL_IMPL_H_
24
25 #include <app_service.h>
26
27 #include <FBaseObject.h>
28 #include <FAppTypes.h>
29 #include <FOspConfig.h>
30 #include <FAppAppControl.h>
31 #include <FBaseColArrayListT.h>
32
33 #include <FBaseRt_LibraryImpl.h>
34
35 #include "FApp_AppManagerImpl.h"
36 #include "FApp_IAppControlResponseEventListener.h"
37
38 typedef struct _bundle_t bundle;
39
40
41 namespace Tizen { namespace Base { class String; } }
42 namespace Tizen { namespace Base { namespace Collection { class IList; } } }
43
44 namespace Tizen { namespace App
45 {
46
47 class AppControl;
48 class IAppControlEventListener;
49 class IAppControlResponseListener;
50 class _AppArg;
51
52 enum _AppControlProperty
53 {
54         _APPCONTROL_PROPERTY_NONE = 0x0,
55         _APPCONTROL_PROPERTY_PUBLIC = 0x01,
56         _APPCONTROL_PROPERTY_PERSISTENT_DLL = 0x08,
57         _APPCONTROL_PROPERTY_SLP = 0x100,
58         _APPCONTROL_PROPERTY_OSP = 0x200,
59         _APPCONTROL_PROPERTY_ALIAS = 0x400,
60         _APPCONTROL_PROPERTY_APPID_CHANGE = 0x800,
61         _APPCONTROL_PROPERTY_SUBMODE = 0x1000,
62         _APPCONTROL_PROPERTY_SERVICE_CALLEE = 0x2000,
63 };
64
65 class _OSP_EXPORT_ _AppControlImpl
66         : public Tizen::Base::Object
67         , public Tizen::App::_IAppControlResponseEventListener
68         , virtual public Tizen::Base::Runtime::IEventListener
69 {
70 public:
71         /**
72          * AppControl delegate constructor
73          */
74         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);
75
76         /**
77          * AppControl delegate constructor
78          */
79         static AppControl* CreateN(const AppId& appId, const Tizen::Base::String& operationId, bool changeAppId);
80
81         /**
82          * AppControl delegate constructor
83          */
84         static AppControl* CreateN(const AppControl& ac);
85
86         /**
87          * Internal GetImpl() method.
88          */
89         static const _AppControlImpl* GetInstance(const AppControl& ac);
90
91         /**
92          * Internal GetImpl() method.
93          */
94         static _AppControlImpl* GetInstance(AppControl& ac);
95
96         /**
97         * Starts the resolved application control. @n
98         * Once the application starts, it goes to the background and the target
99         * application control is displayed.
100         *
101         * @return               An error code
102         * @param[in]    pDataList       The data list to deliver to the resolved application control @n
103         *                                                       The maximum size of the list is 4096 bytes.
104         * @param[in]    pListener       The application control callback listener @n
105         *                                                       Some application controls need to get the callback result by implementing
106         *                                                       the IAppControlEventListener interface.
107         * @exception    E_SUCCESS                               The method is successful.
108         * @exception    E_MAX_EXCEEDED                  The size of @c pDataList has exceeded the maximum limit.
109         * @exception    E_OUT_OF_MEMORY                 The memory is insufficient.
110         * @exception    E_OBJ_NOT_FOUND                 The target application control resource is not found.
111         * @exception    E_IN_PROGRESS                   The application control is in progress: @n
112         *                                       - The application has already started an _AppControlImpl. @n
113         *                                       - The target application has already started.
114         * @exception    E_SYSTEM                                A system error has occurred.
115         * @remarks              If the %IAppControlEventListener instance (@c pListener) needs to get the
116         *               callback result for an application control, it should be valid till
117         *               IAppControlEventListener::OnAppControlCompleted() is invoked.
118         *               For example, a form object listener should not be deleted before the
119         *               system invokes IAppControlEventListener::OnAppControlCompleted().
120         */
121         result Start(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
122
123         /**
124          * Starts the found application control. @n
125          * Once the found application starts, the calling application goes to the background and the found
126          * application is displayed.
127          *
128          * @return      An error code
129          * @param[in]   pUriData    A pointer to the URI data
130          * @param[in]   pDataType   A pointer to the MIME type (RFC 2046) data
131          * @param[in]   pExtraData  The Tizen::Base::String key and Tizen::Base::String value pair map to deliver to the resolved application @n
132          *                          The maximum size is 16 kilo bytes.
133          * @param[in]   pListener   The application control callback listener @n
134          *                          Some application need to get the result by implementing the IAppControlResponseListener interface.
135          * @exception   E_SUCCESS               The method is successful.
136          * @exception   E_MAX_EXCEEDED          The size of @c pExtraData has exceeded the maximum limit.
137          * @exception   E_OBJ_NOT_FOUND         The target application control is not found.
138          * @exception   E_IN_PROGRESS           The application control is in progress: @n
139          *                                       - The application has already started an %AppControl.
140          * @exception   E_SYSTEM                The method cannot proceed due to a severe system error.
141          * @remarks     If the calling application needs to get some result for application control,
142          *              it must be valid till %IAppControlResponseListener::OnAppControlCompleteResponseReceived() is invoked.
143          *              For example, a form object listener must not be deleted before the
144          *              system invokes %IAppControlResponseListener::OnAppControlCompleteResponseReceived().
145          * @see IAppControlResponseListener, AppManager::FindAppControlN(), AppManager::FindAppControlsN()
146          */
147         result Start(const Tizen::Base::String* pUriData, const Tizen::Base::String* pDataType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
148
149         /**
150          * Gets the name of the application that provides the features represented by this %_AppControlImpl instance.
151          *
152          * @return              The name of the application providing this %_AppControlImpl instance
153          */
154         Tizen::Base::String GetAppName(void);
155
156         /**
157          * Gets the associated application ID. @n
158          *
159          * @return              The application control ID
160          */
161         Tizen::Base::String GetAppId(void) const;
162
163         /**
164          * Gets the associated application control provider ID. @n
165          *
166          * @return              The application control provider ID
167          */
168         const Tizen::Base::String& GetAppControlProviderId(void) const;
169
170         /**
171          * Gets the associated operation ID. @n
172          *
173          * @return              The operation ID
174          */
175         const Tizen::Base::String& GetOperationId(void) const;
176
177         /**
178          * Returns the associated application control categories.
179          *
180          * @return      A pointer to the list of application control categories, @n
181               *               else @c null if an error occurs
182          * @exception   E_SUCCESS       The method is successful.
183          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
184          * @exception   E_SYSTEM                        A system error has occurred.
185          * @remarks     The specific error code can be accessed using the GetLastResult() method.
186          */
187         Tizen::Base::Collection::IList* GetCategoryListN(void) const;
188
189         /**
190          * Stops the activated application control. @n
191          *
192          * @return          An error code
193          * @exception E_SUCCESS                        The method is successful.
194          * @exception E_SYSTEM                         A system error has occurred.
195          * @exception E_INVALID_OPERATION        The application control is not permitted to call this method.
196          * @remarks     This method is asynchronous.
197          */
198         result Stop(void);
199
200         /**
201          * Finds the matching application control with given operation ID, URI pattern, data type and category and
202          * starts the found one. @n
203          * 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.
204          * When the found application control is started, the URI pattern, MIME type, and extra data is delivered via IAppControlProviderEventListener.
205          *
206          * @return  An error code
207          * @param[in]   pOperationId   The operation ID
208          * @param[in]   pUriPattern           A URI pattern which is used for application control resolution and to be delivered as the argument
209          * @param[in]   pDataType   The MIME type (RFC 2046) or file extension @n
210          *                          The '.' prefix must be used when specifying the file extension.
211          * @param[in]   pCategory      The application control category
212          * @param[in]   pExtraData     The extra collection data to be delivered to the resolved application @n
213          *                                                   The maximum size is 16 kilo bytes.
214          * @param[in]   pListener   A listener that gets notified
215          * @exception   E_SUCCESS           The method is successful.
216          * @exception   E_MAX_EXCEEDED      The size of @c pDataList has exceeded the maximum limit.
217          * @exception   E_OBJ_NOT_FOUND     The application control is not found.
218          * @exception  E_SYSTEM                              The method cannot proceed due to a severe system error.
219          * @see IAppControlResponseListener, IAppControlProviderEventListener
220          */
221         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);
222
223         /**
224          * Stops the event listener for receiving application control result.
225          *
226          * @param[in]  pListener      The listener to stop receiving the application control result
227          */
228         static void StopAppControlResponseListener(IAppControlResponseListener* pListener);
229
230         static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
231
232         static result StartImplicit(bundle* pBundle, const Tizen::Base::Collection::IMap* pData, IAppControlResponseListener* pListener);
233
234         bool IsPublic(void) const
235         {
236                 return (_property & _APPCONTROL_PROPERTY_PUBLIC);
237         }
238
239         void SetProperty(int prop)
240         {
241                 _property |= prop;
242         }
243
244         virtual void OnAppControlResponseEventReceivedN(const Tizen::Base::Runtime::IEventArg* arg);
245 private:
246         _AppControlImpl(const AppControl& value);
247
248         /**
249          * This is the default constructor for this class.
250          */
251         _AppControlImpl(void);
252
253         _AppControlImpl(const _AppControlImpl& rhs);
254
255         _AppControlImpl& operator =(const _AppControlImpl& rhs);
256
257         /**
258          * This is the destructor for this class.
259          */
260         virtual ~_AppControlImpl(void);
261
262         result StartOsp(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
263
264         result StartOsp(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
265
266         result StartNative(const Tizen::Base::Collection::IList* pDataList, IAppControlEventListener* pListener);
267
268         result StartNative(const Tizen::Base::String* pUriData, const Tizen::Base::String* pMimeType, const Tizen::Base::Collection::IMap* pExtraData, IAppControlResponseListener* pListener);
269
270         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);
271
272         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);
273
274         static result AppControlCbLegacy(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
275
276         static result AppControlCb(void* data, _AppArg* pArg, _AppArg* pResArg, service_result_e res, int prop, int reqId);
277
278 protected:
279         static const unsigned long _LIBRARY_OPTION = Tizen::Base::Runtime::_LIBRARY_LOAD_OPTION_LAZY | Tizen::Base::Runtime::_LIBRARY_LOAD_OPTION_NODELETE;
280
281         const AppControl& _appControl;
282
283         Tizen::Base::String _path;
284         Tizen::Base::String _provider;
285         Tizen::Base::String _opId;
286         Tizen::Base::String _appName;
287         int     _reqId;
288         int     _property;
289         int _processId;
290
291 private:
292         Tizen::Base::Collection::ArrayListT<int> __appControlResponseEventList;
293
294         friend class AppControl;
295         friend class _AppArg;
296 }; // _AppControlImpl
297
298 } } // Tizen::App
299
300 #endif // _FAPP_INTERNAL_APP_CONTROL_IMPL_H_