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