2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
20 * @brief This is the implementation for the App class.
24 #include <FAppAppResource.h>
25 #include <FAppAppRegistry.h>
26 #include <FBaseResult.h>
29 #include <FBaseSysLog.h>
30 #include "FApp_AppInfo.h"
31 #include "FApp_AppImpl.h"
33 using namespace Tizen::Base;
34 using namespace Tizen::Base::Collection;
36 namespace Tizen { namespace App
41 __pAppImpl = new (std::nothrow) _AppImpl(this);
42 SysAssertf(__pAppImpl != null, "Allocating memory for App instance failed.");
43 SysTryReturnVoidResult(NID_APP, __pAppImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
52 App::GetAppRegistry(void) const
54 return AppRegistry::GetInstance();
58 App::GetAppResource(void) const
60 return AppResource::GetInstance();
64 App::GetAppArgumentListN(void) const
66 SysAssertf(__pAppImpl != null, "Getting App instance failed.");
68 return __pAppImpl->GetAppArgumentListN();
72 App::GetAppState(void) const
74 return _AppInfo::GetAppState();
78 App::GetAppName(void) const
80 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
82 return _AppInfo::GetAppName();
86 return _AppInfo::GetAppExecutableName();
91 App::GetAppDisplayName(void) const
93 return _AppInfo::GetAppName();
97 App::GetAppVersion(void) const
99 return _AppInfo::GetAppVersion();
103 App::GetAppId(void) const
105 return _AppInfo::GetApplicationId();
109 App::GetAppRootPath(void) const
111 return _AppInfo::GetAppRootPath();
115 App::GetAppDataPath(void) const
117 static String appDataPath(_AppInfo::GetAppRootPath() + L"data/");
122 App::GetAppResourcePath(void) const
124 static String appResPath(_AppInfo::GetAppRootPath() + L"res/");
129 App::GetAppSharedPath(void) const
131 static String appSharedPath(_AppInfo::GetAppRootPath() + L"shared/");
132 return appSharedPath;
138 SysTryReturnResult(NID_APP, __pAppImpl != null, E_INVALID_STATE, "Getting App instance failed.");
140 return __pAppImpl->Terminate();
144 App::OnAppInitialized(void)
150 App::OnAppWillTerminate(void)
156 App::OnLowMemory(void)
162 App::OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel)
168 App::SendUserEvent(RequestId requestId, const IList* pArgs)
170 SysAssertf(__pAppImpl != null, "Getting App instance failed.");
172 return __pAppImpl->SendUserEvent(requestId, pArgs);
176 App::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
180 pArgs->RemoveAll(true);
186 App::GetInstance(void)
188 _AppImpl* pAppImpl = _AppImpl::GetInstance();
190 if (pAppImpl != null)
192 return pAppImpl->GetAppInstance();