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