7f32f3081b8b6d348b3ab73fd33ec67d10a5fb91
[platform/framework/native/appfw.git] / src / app / inc / FApp_AppInfo.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_AppInfo.h
20  * @brief       This is the header file of the _AppInfo class.
21  */
22
23 #ifndef _FAPP_INTERNAL_APP_INFO_H_
24 #define _FAPP_INTERNAL_APP_INFO_H_
25
26 #include <FBaseObject.h>
27 #include <FOspConfig.h>
28 #include <FAppTypes.h>
29
30 #include <FBaseInternalTypes.h>
31
32 #include "FApp_Types.h"
33
34 namespace Tizen { namespace Base { class String; } }
35
36 namespace Tizen { namespace App
37 {
38
39 /**
40  * @class       _AppInfo
41  */
42 class _OSP_EXPORT_ _AppInfo
43 {
44 public:
45         /**
46          * Retrieves class instance.
47          *
48          * @return      A pointer to the %_AppInfo instance, @n
49          *          else @c null if it fails
50          */
51         _OSP_LOCAL_ static _AppInfo* GetAppInfo(void);
52
53         /**
54          * Gets the Api version of current application.
55          *
56          * @return      The Api version
57          */
58         static Tizen::Base::_ApiVersion GetApiVersion(void);
59
60         /**
61          * Checkes whether the compatibility mode is on or not.
62          *
63          * @return      @true if the compatibility mode is on else false
64          */
65         static bool IsOspCompat(void);
66
67         /**
68          * Sets the Api version of current application.
69          *
70          * @return      An error code
71          * @param[in]   apiVersion      Api version
72          * @exception   E_SUCCESS       The method is successful.
73          * @exception   E_SYSTEM        A system error has occurred.
74          */
75         static result SetApiVersion(Tizen::Base::_ApiVersion apiVersion);
76
77         /**
78          * Gets the current process Id.
79          *
80          * @return      The process Id
81          */
82         static int GetProcessId(void);
83
84         /**
85          * Gets the directory file descriptor of application's root directory where the application is installed.
86          *
87          * @return      The file descriptor of the application's root directory
88          * @remarks     This file descriptor is read only.
89          */
90         static int GetAppRootDirFd(void);
91
92         /**
93          * Gets the application's Id.
94          *
95          * @return      The application Id
96          */
97         static AppId GetApplicationId(void);
98
99         /**
100          * Gets the application's Id.
101          *
102          * @return      The application Id
103          */
104         static AppId GetPackageId(void);
105
106         /**
107          * Gets the application executable name.
108          *
109          */
110         static Tizen::Base::String GetAppExecutableName(void);
111
112         /**
113          * Checkes whether the application is submode or not.
114          *
115          * @return      @true if the compatibility mode is on else false
116          */
117         static bool IsSubMode(void);
118
119         //
120         // This method is for internal use only.
121         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
122         //
123         // Gets the path of application's root directory where the application is installed.
124         //
125         // @return      The path of the application's root directory
126         //
127         static Tizen::Base::String GetAppRootPath(void);
128
129         /**
130          * Gets the application's name.
131          *
132          * @return      The application name
133          */
134         static Tizen::Base::String GetAppName(void);
135
136         /**
137          * Gets the application's version.
138          *
139          * @return      The application version
140          */
141         static Tizen::Base::String GetAppVersion(void);
142
143         /**
144          * Gets the current state of the application.
145          *
146          * @return      The current state of the application
147          */
148         static AppState GetAppState(void);
149
150         /**
151          * Sets the current state of the application.
152          *
153          * @param appState      The current state of the application
154          */
155         static void SetAppState(AppState appState);
156
157         /**
158          * Gets the current type of the application.
159          *
160          * @return      The current type of the application
161          */
162         static int GetAppType(void);
163
164         /**
165          * Sets the current type of the application.
166          *
167          * @param appType       The current type of the application
168          */
169         static void SetAppType(_AppType appType);
170
171         /**
172          * Gets the argument count.
173          *
174          * @return      argc
175          */
176         _OSP_LOCAL_ static int GetArgc(void);
177
178         /**
179          * Gets the argument.
180          *
181          * @return      argv
182          */
183         _OSP_LOCAL_ static char** GetArgv(void);
184
185         /**
186          * Gets the application handler type.
187          *
188          * @return      appHandlerType
189          */
190         _OSP_LOCAL_ static int GetAppHandlerType(void);
191
192         /**
193          * Sets the application handler type.
194          *
195          * @param appHandlerType
196          */
197         _OSP_LOCAL_ static void SetAppHandlerType(int appHandlerType);
198
199         /**
200          * Gets the parent window handle.
201          *
202          * @return      window handle
203          */
204         static unsigned int GetParentWindowHandle(void);
205
206         /**
207          * Sets the parent window handle.
208          */
209         static void SetParentWindowHandle(unsigned int handle);
210
211         /**
212          * Update package info
213          */
214         static void UpdatePackageInfo(bool update);
215
216         _OSP_LOCAL_ result Construct(const char* appId, const char* exeName, int argc, char* pArgv[]);
217
218         _OSP_LOCAL_ result Construct(const char* appId, const char* appRoot, _AppType type = _APP_TYPE_UI_APP);
219
220 private:
221         _OSP_LOCAL_ _AppInfo(void);
222
223         _OSP_LOCAL_ ~_AppInfo(void);
224
225         _AppInfo(const _AppInfo& value);
226
227         _AppInfo& operator =(const _AppInfo& source);
228
229         _OSP_LOCAL_ static Tizen::Base::_ApiVersion GetApiVersionFromStr(const char* pVer);
230
231         _OSP_LOCAL_ result UpdateAppInfoFromPackageInfo(const PackageId& packageId);
232
233 private:
234         AppState __appState;
235         int __appType;
236         int __appRootDirFd;
237         int __appHandlerType;
238         int __parentWindowHandle;
239         Tizen::Base::_ApiVersion __apiVersion;
240         AppId   __appId;
241         PackageId       __packageId;
242         Tizen::Base::String __appExecutableName;
243         Tizen::Base::String __appRootPath;
244         Tizen::Base::String* __pAppName;
245         Tizen::Base::String* __pAppVersion;
246         int __argc;
247         char** __pArgv;
248         bool    __isPackageInfoInitialized;
249         bool    __isOspCompat;
250         bool    __isSubMode;
251 }; // _AppInfo
252
253 }} // Tizen::App
254
255 #endif //_FAPP_INTERNAL_APP_INFO_H_