Refactor DataControl request list.
[platform/framework/native/appfw.git] / src / app / inc / FApp_AppArg.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file        FApp_AppArg.h
20  * @brief       This is the header file of the _AppArg class.
21  *
22  * This header file contains the declarations of the _AppArg class.
23  */
24
25 #ifndef _FAPP_INTERNAL_APP_ARG_H_
26 #define _FAPP_INTERNAL_APP_ARG_H_
27
28 #include <bundle.h>
29
30 #include <FBaseObject.h>
31 #include <FAppTypes.h>
32
33 #include "FApp_Types.h"
34
35 namespace Tizen { namespace Base { namespace Collection {
36 class ArrayList;
37 class IList;
38 class HashMap;
39 }}}
40
41 namespace Tizen { namespace App
42 {
43
44 class _AppControlImpl;
45 class _SqlDataControlImpl;
46 class _MapDataControlImpl;
47
48 enum _DataControlRequestType
49 {
50         _DATACONTROL_REQUEST_TYPE_UNDEFINED = 0,
51         _DATACONTROL_REQUEST_TYPE_SQL_QUERY,
52         _DATACONTROL_REQUEST_TYPE_SQL_INSERT,
53         _DATACONTROL_REQUEST_TYPE_SQL_UPDATE,
54         _DATACONTROL_REQUEST_TYPE_SQL_DELETE,
55         _DATACONTROL_REQUEST_TYPE_MAP_QUERY,
56         _DATACONTROL_REQUEST_TYPE_MAP_INSERT,
57         _DATACONTROL_REQUEST_TYPE_MAP_UPDATE,
58         _DATACONTROL_REQUEST_TYPE_MAP_DELETE
59 };
60
61 #define OSP_K_LAUNCH_TYPE   "__OSP_LAUNCH_TYPE__"
62 #define OSP_K_ARG           "__OSP_ARGS__"
63 #define OSP_K_COND          "__OSP_COND_NAME__"
64 #define OSP_K_APPID         "__OSP_APPID__"
65 #define OSP_K_REQUEST_ID    "__OSP_REQUEST_ID__"
66 #define OSP_K_APPCONTROL_INTERNAL_OPERATION "__OSP_APPCONTROL_INTERNAL_INTERNAL_OPERATION__"
67 #define OSP_K_DATACONTROL_PROVIDER              "__OSP_DATACONTROL_PROVIDER__"
68 #define OSP_K_DATACONTROL_DATA                  "__OSP_DATACONTROL_DATA__"
69 #define OSP_K_DATACONTROL_REQUEST_TYPE  "__OSP_DATACONTROL_REQUEST_TYPE__"
70
71 /**
72  * @class        _AppArg
73  * @brief
74  * @since 2.1
75  */
76 class _OSP_EXPORT_ _AppArg
77 {
78 public:
79         _AppArg(void);
80
81         ~_AppArg(void);
82
83         result Construct(const Tizen::Base::String& argText);
84
85         result Construct(const Tizen::Base::Collection::IList* pList);
86
87         result Construct(const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
88
89         result Construct(const _AppControlImpl& ac, const Tizen::Base::Collection::IList* pList);
90
91         result Construct(const _AppControlImpl& ac, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pMap);
92
93         result Construct(const _SqlDataControlImpl& dc, _DataControlRequestType requestType, const Tizen::Base::Collection::IList* pList);
94
95         result Construct(const _MapDataControlImpl& dc, _DataControlRequestType requestType, const Tizen::Base::Collection::IList* pList);
96
97         result ConstructResult(const _AppArg& arg, const Tizen::Base::Collection::IList* pList);
98
99         result ConstructResult(const _AppArg& arg, const Tizen::Base::Collection::IMap* pMap);
100
101         result Construct(bundle* b);
102
103         result ConstructForAppLaunchCondition(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList);
104         result ConstructForAppLaunchCondition(const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList, const Tizen::Base::Collection::IMap* pMap);
105
106         Tizen::Base::Collection::ArrayList* GetArgListN(int num) const;
107
108         Tizen::Base::Collection::ArrayList* GetArgListN(void) const;
109
110         Tizen::Base::Collection::HashMap* GetArgMapN(void) const;
111
112         Tizen::Base::String GetValue(const char* key) const;
113
114         bundle* GetBundle(void) const
115         {
116                 return __pBundle;
117         }
118
119         _AppHandler GetHandler(void) const
120         {
121                 return GetHandler(__pBundle);
122         }
123
124         AppId GetCallerAppId(void) const;
125
126         int GetCallerPid(void) const
127         {
128                 return GetCallerPid(__pBundle);
129         }
130
131         AppId GetCalleeAppId(void) const;
132
133         void Print() const
134         {
135                 Print(__pBundle);
136         }
137
138         void UpdateAppId(const AppId& appId)
139         {
140                 UpdateAppId(__pBundle, appId);
141         }
142
143         void UpdateRequestId(int reqId)
144         {
145                 UpdateRequestId(__pBundle, reqId);
146         }
147
148         void UpdateKeyValue(const char* pKey, const Tizen::Base::String& value)
149         {
150                 UpdateKeyValue(__pBundle, pKey, value);
151         }
152
153         result UpdateWindowHandle(long handle)
154         {
155                 return UpdateWindowHandle(__pBundle, handle);
156         }
157
158         static int GetCallerPid(bundle* b);
159
160         static void Print(bundle* b);
161
162         static void PrintSvcHandle(void* svc);
163
164         static _AppHandler GetHandler(bundle* b);
165
166         static bundle* GetBundleFromSvc(void* svc);
167
168         static Tizen::Base::String GetRequestId(int num);
169
170         static int GetRequestId(const Tizen::Base::String& id);
171
172         static void UpdateAppId(bundle* b, const AppId& appid);
173
174         static int GetRequestIdFromBundle(bundle* p);
175
176         static void UpdateRequestId(bundle* b, int reqId);
177
178         static void UpdateKeyValue(bundle* b, const char* pKey, const Tizen::Base::String& value);
179
180         static result UpdateWindowHandle(bundle* b, long handle);
181
182         static Tizen::Base::Collection::ArrayList* GetListN(bundle* b, const char* key);
183
184         static result AddStrMap(bundle* b, const Tizen::Base::Collection::IMap* pMap);
185
186         static result FillMapFromList(Tizen::Base::Collection::IMap* pMap, const Tizen::Base::Collection::IList* pList);
187
188         static result FillLegacyAppControlResult(Tizen::Base::Collection::IList& list, int res, const Tizen::Base::Collection::IMap* pMap, const Tizen::Base::String& aId);
189 private:
190         _AppArg(const _AppArg& value);
191
192         _AppArg& operator =(const _AppArg& source);
193
194         static result CreateLaunchArg(bundle* b, const Tizen::Base::String& arg);
195
196         static result CreateLaunchArg(bundle* b, const Tizen::Base::Collection::IList* pList);
197
198         static result CreateAppControlArg(bundle* b, const _AppControlImpl& ac, const Tizen::Base::Collection::IList* pList);
199
200         static result CreateAppControlArg(bundle* b, const _AppControlImpl& ac, const Tizen::Base::String* pUri, const Tizen::Base::String* pMime, const Tizen::Base::Collection::IMap* pList);
201
202         static result CreateSqlDataControlArg(bundle* b, const _SqlDataControlImpl& dc, _DataControlRequestType requestType, const Tizen::Base::Collection::IList* pList);
203
204         static result CreateMapDataControlArg(bundle* b, const _MapDataControlImpl& dc, _DataControlRequestType requestType, const Tizen::Base::Collection::IList* pList);
205
206         static result CreateAppLaunchConditionArg(bundle* b, const Tizen::Base::String& condition, const Tizen::Base::Collection::IList* pList);
207
208         static result CreateResultArg(bundle* b, const Tizen::Base::Collection::IList* pList);
209
210         static result CreateResultArg(bundle* b, const Tizen::Base::Collection::IMap* pList);
211
212         static result AddStrArray(bundle* b, const char* key, const Tizen::Base::Collection::IList* pList);
213
214         static result AddStrArray(bundle* b, const Tizen::Base::String& key, const Tizen::Base::Collection::IList* pList);
215
216         static bundle* CreateBundleFromSvc(void* svc);
217
218         static inline void AddListFromBundle(Tizen::Base::Collection::ArrayList* pList, bundle* b, const char* key);
219
220         static result SetArgList(bundle* pBundle, Tizen::Base::Collection::ArrayList* pList);
221
222         static result SetArgMap(bundle* pBundle, Tizen::Base::Collection::HashMap* pList);
223
224 private:
225         bundle* __pBundle;
226 }; // _AppArg
227
228 } } // Tizen::App
229
230 #endif //_FAPP_INTERNAL_APP_ARG_H_