2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @brief This is the implementation for the App class.
23 #include <FAppAppResource.h>
24 #include <FAppAppRegistry.h>
25 #include <FBaseResult.h>
28 #include <FBaseSysLog.h>
29 #include "FApp_AppInfo.h"
30 #include "FApp_AppImpl.h"
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
35 namespace Tizen { namespace App
40 __pAppImpl = new (std::nothrow) _AppImpl(this);
41 SysAssertf(__pAppImpl != null, "Allocating memory for App instance failed.");
42 SysTryReturnVoidResult(NID_APP, __pAppImpl, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Insufficient memory.");
51 App::GetAppRegistry(void) const
53 return AppRegistry::GetInstance();
57 App::GetAppResource(void) const
59 return AppResource::GetInstance();
63 App::GetAppArgumentListN(void) const
65 SysAssertf(__pAppImpl != null, "Getting App instance failed.");
67 return __pAppImpl->GetAppArgumentListN();
71 App::GetAppState(void) const
73 return _AppInfo::GetAppState();
77 App::GetAppName(void) const
79 if (_AppInfo::GetApiVersion() == _API_VERSION_2_0 && _AppInfo::IsOspCompat())
81 return _AppInfo::GetAppName();
85 return _AppInfo::GetAppExecutableName();
90 App::GetAppDisplayName(void) const
92 return _AppInfo::GetAppName();
96 App::GetAppVersion(void) const
98 return _AppInfo::GetAppVersion();
102 App::GetAppId(void) const
104 return _AppInfo::GetApplicationId();
108 App::GetAppRootPath(void) const
110 return _AppInfo::GetAppRootPath();
114 App::GetAppDataPath(void) const
116 static String appDataPath(_AppInfo::GetAppRootPath() + L"data/");
121 App::GetAppResourcePath(void) const
123 static String appResPath(_AppInfo::GetAppRootPath() + L"res/");
128 App::GetAppSharedPath(void) const
130 static String appSharedPath(_AppInfo::GetAppRootPath() + L"shared/");
131 return appSharedPath;
137 SysTryReturnResult(NID_APP, __pAppImpl != null, E_INVALID_STATE, "Getting App instance failed.");
139 return __pAppImpl->Terminate();
143 App::OnAppInitialized(void)
149 App::OnAppWillTerminate(void)
155 App::OnLowMemory(void)
161 App::OnBatteryLevelChanged(Tizen::System::BatteryLevel batteryLevel)
167 App::SendUserEvent(RequestId requestId, const IList* pArgs)
169 SysAssertf(__pAppImpl != null, "Getting App instance failed.");
171 return __pAppImpl->SendUserEvent(requestId, pArgs, true);
175 App::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
179 pArgs->RemoveAll(true);
185 App::GetInstance(void)
187 _AppImpl* pAppImpl = _AppImpl::GetInstance();
189 if (pAppImpl != null)
191 return pAppImpl->GetAppInstance();