48bfd3b4bd31306b41f02f3531c77efc0834c36a
[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* GetInstance(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         static bool IsVirtualRoot(void);
67
68         /**
69          * Sets the Api version of current application.
70          *
71          * @return      An error code
72          * @param[in]   apiVersion      Api version
73          * @exception   E_SUCCESS       The method is successful.
74          * @exception   E_SYSTEM        A system error has occurred.
75          */
76         static result SetApiVersion(Tizen::Base::_ApiVersion apiVersion);
77
78         /**
79          * Gets the current process Id.
80          *
81          * @return      The process Id
82          */
83         static int GetProcessId(void);
84
85         /**
86          * Gets the directory file descriptor of application's root directory where the application is installed.
87          *
88          * @return      The file descriptor of the application's root directory
89          * @remarks     This file descriptor is read only.
90          */
91         static int GetAppRootDirFd(void);
92
93         /**
94          * Gets the application's Id.
95          *
96          * @return      The application Id
97          */
98         static AppId GetApplicationId(void);
99
100         /**
101          * Gets the application's Id.
102          *
103          * @return      The application Id
104          */
105         static AppId GetPackageId(void);
106
107         /**
108          * Gets the application executable name.
109          *
110          */
111         static Tizen::Base::String GetAppExecutableName(void);
112
113         /**
114          * Checkes whether the application is submode or not.
115          *
116          * @return      @true if the compatibility mode is on else false
117          */
118         static bool IsSubMode(void);
119
120         //
121         // This method is for internal use only.
122         // Using this method can cause behavioral, security-related, and consistency-related issues in the application.
123         //
124         // Gets the path of application's root directory where the application is installed.
125         //
126         // @return      The path of the application's root directory
127         //
128         static Tizen::Base::String GetAppRootPath(void);
129
130         /**
131          * Gets the application's name.
132          *
133          * @return      The application name
134          */
135         static Tizen::Base::String GetAppName(void);
136
137         /**
138          * Gets the application's version.
139          *
140          * @return      The application version
141          */
142         static Tizen::Base::String GetAppVersion(void);
143
144         /**
145          * Gets the current state of the application.
146          *
147          * @return      The current state of the application
148          */
149         static AppState GetAppState(void);
150
151         /**
152          * Sets the current state of the application.
153          *
154          * @param appState      The current state of the application
155          */
156         static void SetAppState(AppState appState);
157
158         /**
159          * Gets the current type of the application.
160          *
161          * @return      The current type of the application
162          */
163         static int GetAppType(void);
164
165         /**
166          * Sets the current type of the application.
167          *
168          * @param appType       The current type of the application
169          */
170         static void SetAppType(_AppType appType);
171
172         /**
173          * Gets the application handler type.
174          *
175          * @return      appHandlerType
176          */
177         _OSP_LOCAL_ static int GetAppHandlerType(void);
178
179         /**
180          * Sets the application handler type.
181          *
182          * @param appHandlerType
183          */
184         _OSP_LOCAL_ static void SetAppHandlerType(int appHandlerType);
185
186         /**
187          * Gets the parent window handle.
188          *
189          * @return      window handle
190          */
191         static unsigned int GetParentWindowHandle(void);
192
193         /**
194          * Sets the parent window handle.
195          */
196         static void SetParentWindowHandle(unsigned int handle);
197
198         /**
199          * Update package info
200          */
201         static void UpdatePackageInfo(bool update);
202
203         /**
204          * Checkes whether the application is a multi-window mode or not.
205          *
206          * @return      @true if the multi-window mode is on else false
207          */
208         static bool IsMultiWindow(void);
209
210         /**
211          * Sets the multi-window mode.
212          */
213         static void SetMultiWindow(bool enable);
214
215         _OSP_LOCAL_ result Construct(void);
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_ result UpdateAppInfoFromPackageInfo(const PackageId& packageId);
229
230 private:
231         AppState __appState;
232         int __appType;
233         int __appRootDirFd;
234         int __appHandlerType;
235         int __parentWindowHandle;
236         Tizen::Base::String __appRootPath;
237         Tizen::Base::String* __pAppName;
238         Tizen::Base::String* __pAppVersion;
239         bool    __isPackageInfoInitialized;
240         bool    __isSubMode;
241         bool    __isVirtualRoot;
242         bool    __isMultiWindow;
243 }; // _AppInfo
244
245 }} // Tizen::App
246
247 #endif //_FAPP_INTERNAL_APP_INFO_H_